1 | <?php |
||
2 | |||
3 | namespace Doctrine\Tests\DBAL\Driver\PDOPgSql; |
||
4 | |||
5 | use Doctrine\DBAL\Driver\PDOPgSql\Driver; |
||
6 | use Doctrine\Tests\DBAL\Driver\AbstractPostgreSQLDriverTest; |
||
7 | use PDO; |
||
8 | use PDOException; |
||
9 | |||
10 | class DriverTest extends AbstractPostgreSQLDriverTest |
||
11 | { |
||
12 | public function testReturnsName() |
||
13 | { |
||
14 | self::assertSame('pdo_pgsql', $this->driver->getName()); |
||
15 | } |
||
16 | |||
17 | /** |
||
18 | * @group DBAL-920 |
||
19 | */ |
||
20 | public function testConnectionDisablesPreparesOnPhp56() |
||
21 | { |
||
22 | $this->skipWhenNotUsingPhp56AndPdoPgsql(); |
||
23 | |||
24 | $connection = $this->createDriver()->connect( |
||
25 | array( |
||
26 | 'host' => $GLOBALS['db_host'], |
||
27 | 'port' => $GLOBALS['db_port'] |
||
28 | ), |
||
29 | $GLOBALS['db_username'], |
||
30 | $GLOBALS['db_password'] |
||
31 | ); |
||
32 | |||
33 | self::assertInstanceOf('Doctrine\DBAL\Driver\PDOConnection', $connection); |
||
34 | |||
35 | try { |
||
36 | self::assertTrue($connection->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES)); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
37 | } catch (PDOException $ignored) { |
||
38 | /** @link https://bugs.php.net/bug.php?id=68371 */ |
||
39 | $this->markTestIncomplete('See https://bugs.php.net/bug.php?id=68371'); |
||
40 | } |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @group DBAL-920 |
||
45 | */ |
||
46 | View Code Duplication | public function testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined() |
|
47 | { |
||
48 | $this->skipWhenNotUsingPhp56AndPdoPgsql(); |
||
49 | |||
50 | $connection = $this->createDriver()->connect( |
||
51 | array( |
||
52 | 'host' => $GLOBALS['db_host'], |
||
53 | 'port' => $GLOBALS['db_port'] |
||
54 | ), |
||
55 | $GLOBALS['db_username'], |
||
56 | $GLOBALS['db_password'], |
||
57 | array(PDO::PGSQL_ATTR_DISABLE_PREPARES => false) |
||
0 ignored issues
–
show
|
|||
58 | ); |
||
59 | |||
60 | self::assertInstanceOf('Doctrine\DBAL\Driver\PDOConnection', $connection); |
||
61 | |||
62 | try { |
||
63 | self::assertNotSame(true, $connection->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES)); |
||
64 | } catch (PDOException $ignored) { |
||
65 | /** @link https://bugs.php.net/bug.php?id=68371 */ |
||
66 | $this->markTestIncomplete('See https://bugs.php.net/bug.php?id=68371'); |
||
67 | } |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @group DBAL-920 |
||
72 | */ |
||
73 | View Code Duplication | public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplicitlyDefined() |
|
74 | { |
||
75 | $this->skipWhenNotUsingPhp56AndPdoPgsql(); |
||
76 | |||
77 | $connection = $this->createDriver()->connect( |
||
78 | array( |
||
79 | 'host' => $GLOBALS['db_host'], |
||
80 | 'port' => $GLOBALS['db_port'] |
||
81 | ), |
||
82 | $GLOBALS['db_username'], |
||
83 | $GLOBALS['db_password'], |
||
84 | array(PDO::PGSQL_ATTR_DISABLE_PREPARES => true) |
||
0 ignored issues
–
show
|
|||
85 | ); |
||
86 | |||
87 | self::assertInstanceOf('Doctrine\DBAL\Driver\PDOConnection', $connection); |
||
88 | |||
89 | try { |
||
90 | self::assertTrue($connection->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES)); |
||
91 | } catch (PDOException $ignored) { |
||
92 | /** @link https://bugs.php.net/bug.php?id=68371 */ |
||
93 | $this->markTestIncomplete('See https://bugs.php.net/bug.php?id=68371'); |
||
94 | } |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * {@inheritDoc} |
||
99 | */ |
||
100 | protected function createDriver() |
||
101 | { |
||
102 | return new Driver(); |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * @throws \PHPUnit_Framework_SkippedTestError |
||
107 | */ |
||
108 | private function skipWhenNotUsingPhp56AndPdoPgsql() |
||
109 | { |
||
110 | if (! defined('PDO::PGSQL_ATTR_DISABLE_PREPARES')) { |
||
111 | $this->markTestSkipped('Test requires PHP 5.6+'); |
||
112 | } |
||
113 | |||
114 | if (! (isset($GLOBALS['db_type']) && $GLOBALS['db_type'] === 'pdo_pgsql')) { |
||
115 | $this->markTestSkipped('Test enabled only when using pdo_pgsql specific phpunit.xml'); |
||
116 | } |
||
117 | } |
||
118 | } |
||
119 |