1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Doctrine\Tests\DBAL\Driver; |
4
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Connection; |
6
|
|
|
use Doctrine\DBAL\Driver\AbstractSQLServerDriver; |
7
|
|
|
use Doctrine\DBAL\Driver\Connection as DriverConnection; |
8
|
|
|
use Doctrine\DBAL\Platforms\SQLServer2008Platform; |
9
|
|
|
use Doctrine\DBAL\Schema\SQLServerSchemaManager; |
10
|
|
|
|
11
|
|
|
class AbstractSQLServerDriverTest extends AbstractDriverTest |
12
|
|
|
{ |
13
|
|
|
protected function createDriver() |
14
|
|
|
{ |
15
|
|
|
return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractSQLServerDriver'); |
|
|
|
|
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
protected function createPlatform() |
19
|
|
|
{ |
20
|
|
|
return new SQLServer2008Platform(); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
protected function createSchemaManager(Connection $connection) |
24
|
|
|
{ |
25
|
|
|
return new SQLServerSchemaManager($connection); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
protected function getDatabasePlatformsForVersions() |
29
|
|
|
{ |
30
|
|
|
return array( |
31
|
|
|
array('9', 'Doctrine\DBAL\Platforms\SQLServerPlatform'), |
32
|
|
|
array('9.00', 'Doctrine\DBAL\Platforms\SQLServerPlatform'), |
33
|
|
|
array('9.00.0', 'Doctrine\DBAL\Platforms\SQLServerPlatform'), |
34
|
|
|
array('9.00.1398', 'Doctrine\DBAL\Platforms\SQLServerPlatform'), |
35
|
|
|
array('9.00.1398.99', 'Doctrine\DBAL\Platforms\SQLServerPlatform'), |
36
|
|
|
array('9.00.1399', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), |
37
|
|
|
array('9.00.1399.0', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), |
38
|
|
|
array('9.00.1399.99', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), |
39
|
|
|
array('9.00.1400', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), |
40
|
|
|
array('9.10', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), |
41
|
|
|
array('9.10.9999', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), |
42
|
|
|
array('10.00.1599', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), |
43
|
|
|
array('10.00.1599.99', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), |
44
|
|
|
array('10.00.1600', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), |
45
|
|
|
array('10.00.1600.0', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), |
46
|
|
|
array('10.00.1600.99', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), |
47
|
|
|
array('10.00.1601', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), |
48
|
|
|
array('10.10', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), |
49
|
|
|
array('10.10.9999', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), |
50
|
|
|
array('11.00.2099', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), |
51
|
|
|
array('11.00.2099.99', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), |
52
|
|
|
array('11.00.2100', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'), |
53
|
|
|
array('11.00.2100.0', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'), |
54
|
|
|
array('11.00.2100.99', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'), |
55
|
|
|
array('11.00.2101', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'), |
56
|
|
|
array('12', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'), |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
protected function getDriver() : AbstractSQLServerDriver |
61
|
|
|
{ |
62
|
|
|
return static::createDriver(); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
protected function checkForSkippingTest(AbstractSQLServerDriver $driver) : void |
66
|
|
|
{ |
67
|
|
|
$this->markTestSkipped('The test is only for the sqlsrv and the pdo_sqlsrv drivers'); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param mixed[] $driverOptions |
72
|
|
|
*/ |
73
|
|
|
protected function getConnection(AbstractSQLServerDriver $driver, array $driverOptions) : DriverConnection |
74
|
|
|
{ |
75
|
|
|
return $driver->connect( |
76
|
|
|
[ |
77
|
|
|
'host' => $GLOBALS['db_host'], |
78
|
|
|
'port' => $GLOBALS['db_port'], |
79
|
|
|
], |
80
|
|
|
$GLOBALS['db_username'], |
81
|
|
|
$GLOBALS['db_password'], |
82
|
|
|
$driverOptions |
83
|
|
|
); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function testConnectionOptions() : void |
87
|
|
|
{ |
88
|
|
|
$driver = $this->getDriver(); |
89
|
|
|
$this->checkForSkippingTest($driver); |
90
|
|
|
$connection = $this->getConnection($driver, ['APP' => 'APP_NAME']); |
91
|
|
|
$result = $connection->query('select APP_NAME() as app')->fetch(); |
92
|
|
|
|
93
|
|
|
self::assertSame('APP_NAME', $result['app']); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: