-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
129 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\DBAL\Driver\PDO; | ||
|
||
use PDO; | ||
|
||
use const PHP_VERSION_ID; | ||
|
||
/** @internal */ | ||
trait PDOConnect | ||
{ | ||
/** @param array<int, mixed> $options */ | ||
private function doConnect( | ||
string $dsn, | ||
string $username, | ||
string $password, | ||
array $options, | ||
): PDO { | ||
// see https://github.com/php/php-src/issues/16314 | ||
if (PHP_VERSION_ID < 80400 || ($options[PDO::ATTR_PERSISTENT] ?? false) === true) { | ||
return new PDO($dsn, $username, $password, $options); | ||
} | ||
|
||
return PDO::connect($dsn, $username, $password, $options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\DBAL\Tests\Functional\Driver\PDO; | ||
|
||
use Doctrine\DBAL\Tests\FunctionalTestCase; | ||
use Doctrine\DBAL\Tests\TestUtil; | ||
use Pdo\Mysql; | ||
use Pdo\Oci; | ||
use Pdo\Pgsql; | ||
use Pdo\Sqlite; | ||
use PHPUnit\Framework\Attributes\RequiresPhp; | ||
|
||
#[RequiresPhp('8.4')] | ||
final class PDOSubclassTest extends FunctionalTestCase | ||
{ | ||
public function testMySQLSubclass(): void | ||
{ | ||
if (! TestUtil::isDriverOneOf('pdo_mysql')) { | ||
self::markTestSkipped('This test requires the pdo_mysql driver.'); | ||
} | ||
|
||
self::assertInstanceOf(Mysql::class, $this->connection->getNativeConnection()); | ||
} | ||
|
||
public function testOCISubclass(): void | ||
{ | ||
if (! TestUtil::isDriverOneOf('pdo_oci')) { | ||
self::markTestSkipped('This test requires the pdo_oci driver.'); | ||
} | ||
|
||
self::assertInstanceOf(Oci::class, $this->connection->getNativeConnection()); | ||
} | ||
|
||
public function testPgSQLSubclass(): void | ||
{ | ||
if (! TestUtil::isDriverOneOf('pdo_pgsql')) { | ||
self::markTestSkipped('This test requires the pdo_pgsql driver.'); | ||
} | ||
|
||
self::assertInstanceOf(Pgsql::class, $this->connection->getNativeConnection()); | ||
} | ||
|
||
public function testSQLiteSubclass(): void | ||
{ | ||
if (! TestUtil::isDriverOneOf('pdo_sqlite')) { | ||
self::markTestSkipped('This test requires the pdo_sqlite driver.'); | ||
} | ||
|
||
self::assertInstanceOf(Sqlite::class, $this->connection->getNativeConnection()); | ||
} | ||
} |