1 | <?php |
||
2 | |||
3 | namespace Doctrine\Tests\DBAL\Driver; |
||
4 | |||
5 | use Doctrine\DBAL\Connection; |
||
6 | use Doctrine\DBAL\Platforms\PostgreSqlPlatform; |
||
7 | use Doctrine\DBAL\Schema\PostgreSqlSchemaManager; |
||
8 | |||
9 | class AbstractPostgreSQLDriverTest extends AbstractDriverTest |
||
10 | { |
||
11 | public function testReturnsDatabaseName() |
||
12 | { |
||
13 | parent::testReturnsDatabaseName(); |
||
14 | |||
15 | $database = 'bloo'; |
||
16 | $params = array( |
||
17 | 'user' => 'foo', |
||
18 | 'password' => 'bar', |
||
19 | ); |
||
20 | |||
21 | $statement = $this->createMock('Doctrine\Tests\Mocks\DriverResultStatementMock'); |
||
22 | |||
23 | $statement->expects($this->once()) |
||
24 | ->method('fetchColumn') |
||
25 | ->will($this->returnValue($database)); |
||
26 | |||
27 | $connection = $this->getConnectionMock(); |
||
28 | |||
29 | $connection->expects($this->once()) |
||
30 | ->method('getParams') |
||
31 | ->will($this->returnValue($params)); |
||
32 | |||
33 | $connection->expects($this->once()) |
||
34 | ->method('query') |
||
35 | ->will($this->returnValue($statement)); |
||
36 | |||
37 | self::assertSame($database, $this->driver->getDatabase($connection)); |
||
38 | } |
||
39 | |||
40 | protected function createDriver() |
||
41 | { |
||
42 | return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractPostgreSQLDriver'); |
||
0 ignored issues
–
show
|
|||
43 | } |
||
44 | |||
45 | protected function createPlatform() |
||
46 | { |
||
47 | return new PostgreSqlPlatform(); |
||
48 | } |
||
49 | |||
50 | protected function createSchemaManager(Connection $connection) |
||
51 | { |
||
52 | return new PostgreSqlSchemaManager($connection); |
||
53 | } |
||
54 | |||
55 | protected function getDatabasePlatformsForVersions() |
||
56 | { |
||
57 | return array( |
||
58 | array('9.0.9', 'Doctrine\DBAL\Platforms\PostgreSqlPlatform'), |
||
59 | array('9.1', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'), |
||
60 | array('9.1.0', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'), |
||
61 | array('9.1.1', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'), |
||
62 | array('9.1.9', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'), |
||
63 | array('9.2', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'), |
||
64 | array('9.2.0', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'), |
||
65 | array('9.2.1', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'), |
||
66 | array('9.3.6', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'), |
||
67 | array('9.4', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'), |
||
68 | array('9.4.0', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'), |
||
69 | array('9.4.1', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'), |
||
70 | array('10', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'), |
||
71 | ); |
||
72 | } |
||
73 | |||
74 | protected function getExceptionConversionData() |
||
75 | { |
||
76 | return array( |
||
77 | self::EXCEPTION_CONNECTION => array( |
||
78 | array(null, '7', 'SQLSTATE[08006]'), |
||
79 | ), |
||
80 | self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => array( |
||
81 | array(null, '23503', null), |
||
82 | ), |
||
83 | self::EXCEPTION_INVALID_FIELD_NAME => array( |
||
84 | array(null, '42703', null), |
||
85 | ), |
||
86 | self::EXCEPTION_NON_UNIQUE_FIELD_NAME => array( |
||
87 | array(null, '42702', null), |
||
88 | ), |
||
89 | self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => array( |
||
90 | array(null, '23502', null), |
||
91 | ), |
||
92 | self::EXCEPTION_SYNTAX_ERROR => array( |
||
93 | array(null, '42601', null), |
||
94 | ), |
||
95 | self::EXCEPTION_TABLE_EXISTS => array( |
||
96 | array(null, '42P07', null), |
||
97 | ), |
||
98 | self::EXCEPTION_TABLE_NOT_FOUND => array( |
||
99 | array(null, '42P01', null), |
||
100 | ), |
||
101 | self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => array( |
||
102 | array(null, '23505', null), |
||
103 | ), |
||
104 | self::EXCEPTION_DEADLOCK => array( |
||
105 | array(null, '40001', null), |
||
106 | array(null, '40P01', null), |
||
107 | ), |
||
108 | ); |
||
109 | } |
||
110 | } |
||
111 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: