false, 'host' => 'foo\SQLSERVER', 'login' => 'Administrator', 'password' => 'blablabla', 'database' => 'bar', 'encoding' => 'a-language', 'flags' => [1 => true, 2 => false], 'init' => ['Execute this', 'this too'], 'settings' => ['config1' => 'value1', 'config2' => 'value2'], ]; $driver = $this->getMock( 'Cake\Database\Driver\Sqlserver', ['_connect', 'connection'], [$config] ); $expected = $config; $expected['dsn'] = 'sqlsrv:server=foo\SQLSERVER;Database=bar'; $expected['flags'] += [ PDO::ATTR_PERSISTENT => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::SQLSRV_ATTR_ENCODING => 'a-language' ]; $connection = $this->getMock('stdClass', ['exec', 'quote']); $connection->expects($this->any()) ->method('quote') ->will($this->onConsecutiveCalls( $this->returnArgument(0), $this->returnArgument(0), $this->returnArgument(0) )); $connection->expects($this->at(1))->method('exec')->with('Execute this'); $connection->expects($this->at(2))->method('exec')->with('this too'); $connection->expects($this->at(3))->method('exec')->with('SET config1 value1'); $connection->expects($this->at(4))->method('exec')->with('SET config2 value2'); $driver->connection($connection); $driver->expects($this->once())->method('_connect') ->with($expected); $driver->expects($this->any())->method('connection') ->will($this->returnValue($connection)); $driver->connect(); } }