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