From 40f26b140793e13e706225e92444cfd85543b51a Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 23 May 2019 13:27:41 -0700 Subject: [PATCH] Removed Driver::getName() The method is not used for anything else than skipping tests for specific drivers. Cross-driver portability should be established by drivers, not outside of them based on their name. --- UPGRADE.md | 4 + lib/Doctrine/DBAL/Driver.php | 7 -- lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php | 8 -- lib/Doctrine/DBAL/Driver/Mysqli/Driver.php | 8 -- lib/Doctrine/DBAL/Driver/OCI8/Driver.php | 8 -- lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php | 8 -- lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php | 8 -- lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php | 8 -- lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php | 8 -- lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php | 8 -- .../DBAL/Driver/SQLAnywhere/Driver.php | 8 -- lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php | 8 -- .../DBAL/Driver/IBMDB2/DB2DriverTest.php | 21 ------ .../Tests/DBAL/Driver/Mysqli/DriverTest.php | 21 ------ .../Tests/DBAL/Driver/OCI8/DriverTest.php | 21 ------ .../Tests/DBAL/Driver/PDOMySql/DriverTest.php | 21 ------ .../DBAL/Driver/PDOOracle/DriverTest.php | 21 ------ .../Tests/DBAL/Driver/PDOPgSql/DriverTest.php | 74 +++++-------------- .../DBAL/Driver/PDOSqlite/DriverTest.php | 21 ------ .../DBAL/Driver/PDOSqlsrv/DriverTest.php | 21 ------ .../DBAL/Driver/SQLAnywhere/DriverTest.php | 21 ------ .../Tests/DBAL/Driver/SQLSrv/DriverTest.php | 21 ------ .../Functional/Driver/PDOConnectionTest.php | 32 ++++---- .../SchemaManagerFunctionalTestCase.php | 17 ++++- .../Tests/DBAL/Functional/StatementTest.php | 43 ++++++----- 25 files changed, 79 insertions(+), 367 deletions(-) delete mode 100644 tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Driver/Mysqli/DriverTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Driver/OCI8/DriverTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/DriverTest.php delete mode 100644 tests/Doctrine/Tests/DBAL/Driver/SQLSrv/DriverTest.php diff --git a/UPGRADE.md b/UPGRADE.md index 89890985d1b..6eacb660d63 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.0 +## BC BREAK: `Doctrine\DBAL\Driver::getName()` removed + +The `Doctrine\DBAL\Driver::getName()` has been removed. + ## BC BREAK Removed previously deprecated features * Removed `json_array` type and all associated hacks. diff --git a/lib/Doctrine/DBAL/Driver.php b/lib/Doctrine/DBAL/Driver.php index 56a757ce616..622dfa12a3c 100644 --- a/lib/Doctrine/DBAL/Driver.php +++ b/lib/Doctrine/DBAL/Driver.php @@ -41,13 +41,6 @@ public function getDatabasePlatform(); */ public function getSchemaManager(Connection $conn); - /** - * Gets the name of the driver. - * - * @return string The name of the driver. - */ - public function getName(); - /** * Gets the name of the database connected to for this driver. * diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php index 188e08d8caf..3040a147eac 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php @@ -38,12 +38,4 @@ public function connect(array $params, $username = null, $password = null, array return new DB2Connection($params, (string) $username, (string) $password, $driverOptions); } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'ibm_db2'; - } } diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php b/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php index 52a61293fea..df37df4bdd5 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php @@ -20,12 +20,4 @@ public function connect(array $params, $username = null, $password = null, array throw DBALException::driverException($this, $e); } } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'mysqli'; - } } diff --git a/lib/Doctrine/DBAL/Driver/OCI8/Driver.php b/lib/Doctrine/DBAL/Driver/OCI8/Driver.php index 4d9341cd580..fa53b3e175b 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/Driver.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/Driver.php @@ -43,12 +43,4 @@ protected function _constructDsn(array $params) { return $this->getEasyConnectString($params); } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'oci8'; - } } diff --git a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php index 15ff50bdd10..7236c11568b 100644 --- a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php @@ -66,12 +66,4 @@ protected function constructPdoDsn(array $params) return $dsn; } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'pdo_mysql'; - } } diff --git a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php index 5825606fcc0..78b31ab9908 100644 --- a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php @@ -58,12 +58,4 @@ private function constructPdoDsn(array $params) return $dsn; } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'pdo_oracle'; - } } diff --git a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php index 43085c56095..7c18d962f47 100644 --- a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php @@ -111,12 +111,4 @@ private function _constructPdoDsn(array $params) return $dsn; } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'pdo_pgsql'; - } } diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php index ba86e3c8d92..61f28dbb44e 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php @@ -74,12 +74,4 @@ protected function _constructPdoDsn(array $params) return $dsn; } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'pdo_sqlite'; - } } diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php index 3b1b90345c4..4e8905dc4bf 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php @@ -87,12 +87,4 @@ private function getConnectionOptionsDsn(array $connectionOptions) : string return $connectionOptionsDsn; } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'pdo_sqlsrv'; - } } diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php index 09a1a8f92fb..8c653fb8fbb 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php @@ -40,14 +40,6 @@ public function connect(array $params, $username = null, $password = null, array } } - /** - * {@inheritdoc} - */ - public function getName() - { - return 'sqlanywhere'; - } - /** * Build the connection string for given connection parameters and driver options. * diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php b/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php index 20e2d99f545..922a7e14fa6 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php @@ -47,12 +47,4 @@ public function connect(array $params, $username = null, $password = null, array return new SQLSrvConnection($serverName, $driverOptions); } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'sqlsrv'; - } } diff --git a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php deleted file mode 100644 index 07c80865902..00000000000 --- a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php +++ /dev/null @@ -1,21 +0,0 @@ -driver->getName()); - } - - protected function createDriver() - { - return new DB2Driver(); - } -} diff --git a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/DriverTest.php deleted file mode 100644 index 657944bd266..00000000000 --- a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/DriverTest.php +++ /dev/null @@ -1,21 +0,0 @@ -driver->getName()); - } - - protected function createDriver() - { - return new Driver(); - } -} diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/DriverTest.php deleted file mode 100644 index f6b6ed25405..00000000000 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/DriverTest.php +++ /dev/null @@ -1,21 +0,0 @@ -driver->getName()); - } - - protected function createDriver() - { - return new Driver(); - } -} diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php deleted file mode 100644 index 8e9273d476c..00000000000 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php +++ /dev/null @@ -1,21 +0,0 @@ -driver->getName()); - } - - protected function createDriver() - { - return new Driver(); - } -} diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php deleted file mode 100644 index a322c116409..00000000000 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php +++ /dev/null @@ -1,21 +0,0 @@ -driver->getName()); - } - - protected function createDriver() - { - return new Driver(); - } -} diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php index 00d75b90cb0..2de04bdd6b3 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php @@ -8,24 +8,25 @@ use Doctrine\DBAL\Driver\PDOPgSql\Driver; use Doctrine\Tests\DBAL\Driver\AbstractPostgreSQLDriverTest; use PDO; -use PDOException; -use PHPUnit_Framework_SkippedTestError; -use function defined; class DriverTest extends AbstractPostgreSQLDriverTest { - public function testReturnsName() + protected function setUp() : void { - self::assertSame('pdo_pgsql', $this->driver->getName()); + parent::setUp(); + + if (isset($GLOBALS['db_type']) && $GLOBALS['db_type'] === 'pdo_pgsql') { + return; + } + + $this->markTestSkipped('Test enabled only when using pdo_pgsql specific phpunit.xml'); } /** * @group DBAL-920 */ - public function testConnectionDisablesPreparesOnPhp56() + public function testConnectionDisablesPrepares() { - $this->skipWhenNotUsingPhp56AndPdoPgsql(); - $connection = $this->createDriver()->connect( [ 'host' => $GLOBALS['db_host'], @@ -36,22 +37,16 @@ public function testConnectionDisablesPreparesOnPhp56() ); self::assertInstanceOf(PDOConnection::class, $connection); - - try { - self::assertTrue($connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES)); - } catch (PDOException $ignored) { - /** @link https://bugs.php.net/bug.php?id=68371 */ - $this->markTestIncomplete('See https://bugs.php.net/bug.php?id=68371'); - } + self::assertTrue( + $connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES) + ); } /** * @group DBAL-920 */ - public function testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined() + public function testConnectionDoesNotDisablePreparesWhenAttributeDefined() { - $this->skipWhenNotUsingPhp56AndPdoPgsql(); - $connection = $this->createDriver()->connect( [ 'host' => $GLOBALS['db_host'], @@ -63,25 +58,16 @@ public function testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined( ); self::assertInstanceOf(PDOConnection::class, $connection); - - try { - self::assertNotSame( - true, - $connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES) - ); - } catch (PDOException $ignored) { - /** @link https://bugs.php.net/bug.php?id=68371 */ - $this->markTestIncomplete('See https://bugs.php.net/bug.php?id=68371'); - } + self::assertNotTrue( + $connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES) + ); } /** * @group DBAL-920 */ - public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplicitlyDefined() + public function testConnectionDisablePreparesWhenDisablePreparesIsExplicitlyDefined() { - $this->skipWhenNotUsingPhp56AndPdoPgsql(); - $connection = $this->createDriver()->connect( [ 'host' => $GLOBALS['db_host'], @@ -93,13 +79,9 @@ public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplici ); self::assertInstanceOf(PDOConnection::class, $connection); - - try { - self::assertTrue($connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES)); - } catch (PDOException $ignored) { - /** @link https://bugs.php.net/bug.php?id=68371 */ - $this->markTestIncomplete('See https://bugs.php.net/bug.php?id=68371'); - } + self::assertTrue( + $connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES) + ); } /** @@ -109,20 +91,4 @@ protected function createDriver() { return new Driver(); } - - /** - * @throws PHPUnit_Framework_SkippedTestError - */ - private function skipWhenNotUsingPhp56AndPdoPgsql() - { - if (! defined('PDO::PGSQL_ATTR_DISABLE_PREPARES')) { - $this->markTestSkipped('Test requires PHP 5.6+'); - } - - if (isset($GLOBALS['db_type']) && $GLOBALS['db_type'] === 'pdo_pgsql') { - return; - } - - $this->markTestSkipped('Test enabled only when using pdo_pgsql specific phpunit.xml'); - } } diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php deleted file mode 100644 index 5bbc56021c0..00000000000 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php +++ /dev/null @@ -1,21 +0,0 @@ -driver->getName()); - } - - protected function createDriver() - { - return new Driver(); - } -} diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php deleted file mode 100644 index ef308d8d1d7..00000000000 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php +++ /dev/null @@ -1,21 +0,0 @@ -driver->getName()); - } - - protected function createDriver() - { - return new Driver(); - } -} diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/DriverTest.php deleted file mode 100644 index 5325a97a599..00000000000 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/DriverTest.php +++ /dev/null @@ -1,21 +0,0 @@ -driver->getName()); - } - - protected function createDriver() - { - return new Driver(); - } -} diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/DriverTest.php deleted file mode 100644 index e496acfca40..00000000000 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/DriverTest.php +++ /dev/null @@ -1,21 +0,0 @@ -driver->getName()); - } - - protected function createDriver() - { - return new Driver(); - } -} diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php index ab14c753ce8..e446b8e1381 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php @@ -6,8 +6,12 @@ use Doctrine\DBAL\Driver\PDOConnection; use Doctrine\DBAL\Driver\PDOException; +use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; +use Doctrine\DBAL\Driver\PDOPgSql\Driver as PDOPgSQLDriver; +use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSRVDriver; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; +use function get_class; use function sprintf; /** @@ -66,10 +70,24 @@ public function testThrowsWrappedExceptionOnExec() public function testThrowsWrappedExceptionOnPrepare() { - if ($this->connection->getDriver()->getName() === 'pdo_sqlsrv') { + $driver = $this->connection->getDriver(); + + if ($driver instanceof PDOSQLSRVDriver) { $this->markTestSkipped('pdo_sqlsrv does not allow setting PDO::ATTR_EMULATE_PREPARES at connection level.'); } + // Some PDO adapters do not check the query server-side + // even though emulated prepared statements are disabled, + // so an exception is thrown only eventually. + if ($driver instanceof PDOOracleDriver + || $driver instanceof PDOPgSQLDriver + ) { + self::markTestSkipped(sprintf( + 'The underlying implementation of the "%s" driver does not check the query to be prepared server-side.', + get_class($driver) + )); + } + // Emulated prepared statements have to be disabled for this test // so that PDO actually communicates with the database server to check the query. $this->driverConnection @@ -79,18 +97,6 @@ public function testThrowsWrappedExceptionOnPrepare() $this->expectException(PDOException::class); $this->driverConnection->prepare('foo'); - - // Some PDO adapters like PostgreSQL do not check the query server-side - // even though emulated prepared statements are disabled, - // so an exception is thrown only eventually. - // Skip the test otherwise. - $this->markTestSkipped( - sprintf( - 'The PDO adapter %s does not check the query to be prepared server-side, ' . - 'so no assertions can be made.', - $this->connection->getDriver()->getName() - ) - ); } public function testThrowsWrappedExceptionOnQuery() diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php index 553c7d543bb..cfc69a2846c 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -43,6 +43,7 @@ use function end; use function explode; use function in_array; +use function sprintf; use function str_replace; use function strcasecmp; use function strlen; @@ -133,8 +134,12 @@ public function testDropsDatabaseWithActiveConnections() */ public function testDropAndCreateSequence() { - if (! $this->connection->getDatabasePlatform()->supportsSequences()) { - $this->markTestSkipped($this->connection->getDriver()->getName() . ' does not support sequences.'); + $platform = $this->connection->getDatabasePlatform(); + + if (! $platform->supportsSequences()) { + $this->markTestSkipped( + sprintf('The "%s" platform does not support sequences.', $platform->getName()) + ); } $name = 'dropcreate_sequences_test_seq'; @@ -161,8 +166,12 @@ static function (AbstractAsset $item) use ($name) : bool { public function testListSequences() { - if (! $this->connection->getDatabasePlatform()->supportsSequences()) { - $this->markTestSkipped($this->connection->getDriver()->getName() . ' does not support sequences.'); + $platform = $this->connection->getDatabasePlatform(); + + if (! $platform->supportsSequences()) { + $this->markTestSkipped( + sprintf('The "%s" platform does not support sequences.', $platform->getName()) + ); } $sequence = new Sequence('list_sequences_test_seq', 20, 10); diff --git a/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php index 58bd96db631..d6a2bbb7286 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php @@ -5,8 +5,12 @@ namespace Doctrine\Tests\DBAL\Functional; use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Driver\IBMDB2\DB2Driver; use Doctrine\DBAL\Driver\PDOConnection; +use Doctrine\DBAL\Driver\PDOMySql\Driver as PDOMySQLDriver; use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; +use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSRVDriver; +use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSRVDriver; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\ParameterType; @@ -14,6 +18,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalFunctionalTestCase; use function base64_decode; +use function get_class; use function sprintf; use function stream_get_contents; @@ -332,26 +337,24 @@ public function testFetchInColumnMode() : void public function testExecWithRedundantParameters() : void { - $driver = $this->connection->getDriver()->getName(); - - switch ($driver) { - case 'pdo_mysql': - case 'pdo_oracle': - case 'pdo_sqlsrv': - self::markTestSkipped(sprintf( - 'PDOStatement::execute() implemented in the "%s" driver does not report redundant parameters', - $driver - )); - - return; - case 'ibm_db2': - self::markTestSkipped('db2_execute() does not report redundant parameters'); - - return; - case 'sqlsrv': - self::markTestSkipped('sqlsrv_prepare() does not report redundant parameters'); - - return; + $driver = $this->connection->getDriver(); + + if ($driver instanceof PDOMySQLDriver + || $driver instanceof PDOOracleDriver + || $driver instanceof PDOSQLSRVDriver + ) { + self::markTestSkipped(sprintf( + 'The underlying implementation of the "%s" driver does not report redundant parameters', + get_class($driver) + )); + } + + if ($driver instanceof DB2Driver) { + self::markTestSkipped('db2_execute() does not report redundant parameters'); + } + + if ($driver instanceof SQLSRVDriver) { + self::markTestSkipped('sqlsrv_prepare() does not report redundant parameters'); } $platform = $this->connection->getDatabasePlatform();