doctrine /
dbal
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Doctrine\DBAL\Tests\Driver\PDOPgSql; |
||
| 6 | |||
| 7 | use Doctrine\DBAL\Driver as DriverInterface; |
||
| 8 | use Doctrine\DBAL\Driver\PDOConnection; |
||
| 9 | use Doctrine\DBAL\Driver\PDOPgSql\Driver; |
||
| 10 | use Doctrine\DBAL\Tests\Driver\AbstractPostgreSQLDriverTest; |
||
| 11 | use PDO; |
||
| 12 | |||
| 13 | class DriverTest extends AbstractPostgreSQLDriverTest |
||
| 14 | { |
||
| 15 | protected function setUp() : void |
||
| 16 | { |
||
| 17 | parent::setUp(); |
||
| 18 | |||
| 19 | if (isset($GLOBALS['db_type']) && $GLOBALS['db_type'] === 'pdo_pgsql') { |
||
| 20 | return; |
||
| 21 | } |
||
| 22 | |||
| 23 | self::markTestSkipped('Test enabled only when using pdo_pgsql specific phpunit.xml'); |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @group DBAL-920 |
||
| 28 | */ |
||
| 29 | public function testConnectionDisablesPrepares() : void |
||
| 30 | { |
||
| 31 | $connection = $this->createDriver()->connect( |
||
| 32 | [ |
||
| 33 | 'host' => $GLOBALS['db_host'], |
||
| 34 | 'port' => $GLOBALS['db_port'], |
||
| 35 | ], |
||
| 36 | $GLOBALS['db_username'], |
||
| 37 | $GLOBALS['db_password'] |
||
| 38 | ); |
||
| 39 | |||
| 40 | self::assertInstanceOf(PDOConnection::class, $connection); |
||
| 41 | self::assertTrue( |
||
| 42 | $connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES) |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 43 | ); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @group DBAL-920 |
||
| 48 | */ |
||
| 49 | public function testConnectionDoesNotDisablePreparesWhenAttributeDefined() : void |
||
| 50 | { |
||
| 51 | $connection = $this->createDriver()->connect( |
||
| 52 | [ |
||
| 53 | 'host' => $GLOBALS['db_host'], |
||
| 54 | 'port' => $GLOBALS['db_port'], |
||
| 55 | ], |
||
| 56 | $GLOBALS['db_username'], |
||
| 57 | $GLOBALS['db_password'], |
||
| 58 | [PDO::PGSQL_ATTR_DISABLE_PREPARES => false] |
||
|
0 ignored issues
–
show
|
|||
| 59 | ); |
||
| 60 | |||
| 61 | self::assertInstanceOf(PDOConnection::class, $connection); |
||
| 62 | self::assertNotTrue( |
||
| 63 | $connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES) |
||
| 64 | ); |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @group DBAL-920 |
||
| 69 | */ |
||
| 70 | public function testConnectionDisablePreparesWhenDisablePreparesIsExplicitlyDefined() : void |
||
| 71 | { |
||
| 72 | $connection = $this->createDriver()->connect( |
||
| 73 | [ |
||
| 74 | 'host' => $GLOBALS['db_host'], |
||
| 75 | 'port' => $GLOBALS['db_port'], |
||
| 76 | ], |
||
| 77 | $GLOBALS['db_username'], |
||
| 78 | $GLOBALS['db_password'], |
||
| 79 | [PDO::PGSQL_ATTR_DISABLE_PREPARES => true] |
||
|
0 ignored issues
–
show
|
|||
| 80 | ); |
||
| 81 | |||
| 82 | self::assertInstanceOf(PDOConnection::class, $connection); |
||
| 83 | self::assertTrue( |
||
| 84 | $connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES) |
||
| 85 | ); |
||
| 86 | } |
||
| 87 | |||
| 88 | protected function createDriver() : DriverInterface |
||
| 89 | { |
||
| 90 | return new Driver(); |
||
| 91 | } |
||
| 92 | } |
||
| 93 |