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.
parent a4158b5c
# Upgrade to 3.0 # 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 ## BC BREAK Removed previously deprecated features
* Removed `json_array` type and all associated hacks. * Removed `json_array` type and all associated hacks.
......
...@@ -43,15 +43,6 @@ interface Driver ...@@ -43,15 +43,6 @@ interface Driver
*/ */
public function getSchemaManager(Connection $conn); public function getSchemaManager(Connection $conn);
/**
* Gets the name of the driver.
*
* @deprecated
*
* @return string The name of the driver.
*/
public function getName();
/** /**
* Gets the name of the database connected to for this driver. * Gets the name of the database connected to for this driver.
* *
......
...@@ -38,14 +38,4 @@ class DB2Driver extends AbstractDB2Driver ...@@ -38,14 +38,4 @@ class DB2Driver extends AbstractDB2Driver
return new DB2Connection($params, (string) $username, (string) $password, $driverOptions); return new DB2Connection($params, (string) $username, (string) $password, $driverOptions);
} }
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
return 'ibm_db2';
}
} }
...@@ -20,12 +20,4 @@ class Driver extends AbstractMySQLDriver ...@@ -20,12 +20,4 @@ class Driver extends AbstractMySQLDriver
throw DBALException::driverException($this, $e); throw DBALException::driverException($this, $e);
} }
} }
/**
* {@inheritdoc}
*/
public function getName()
{
return 'mysqli';
}
} }
...@@ -43,14 +43,4 @@ class Driver extends AbstractOracleDriver ...@@ -43,14 +43,4 @@ class Driver extends AbstractOracleDriver
{ {
return $this->getEasyConnectString($params); return $this->getEasyConnectString($params);
} }
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
return 'oci8';
}
} }
...@@ -66,14 +66,4 @@ class Driver extends AbstractMySQLDriver ...@@ -66,14 +66,4 @@ class Driver extends AbstractMySQLDriver
return $dsn; return $dsn;
} }
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
return 'pdo_mysql';
}
} }
...@@ -58,12 +58,4 @@ class Driver extends AbstractOracleDriver ...@@ -58,12 +58,4 @@ class Driver extends AbstractOracleDriver
return $dsn; return $dsn;
} }
/**
* {@inheritdoc}
*/
public function getName()
{
return 'pdo_oracle';
}
} }
...@@ -111,14 +111,4 @@ class Driver extends AbstractPostgreSQLDriver ...@@ -111,14 +111,4 @@ class Driver extends AbstractPostgreSQLDriver
return $dsn; return $dsn;
} }
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
return 'pdo_pgsql';
}
} }
...@@ -74,14 +74,4 @@ class Driver extends AbstractSQLiteDriver ...@@ -74,14 +74,4 @@ class Driver extends AbstractSQLiteDriver
return $dsn; return $dsn;
} }
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
return 'pdo_sqlite';
}
} }
...@@ -87,14 +87,4 @@ class Driver extends AbstractSQLServerDriver ...@@ -87,14 +87,4 @@ class Driver extends AbstractSQLServerDriver
return $connectionOptionsDsn; return $connectionOptionsDsn;
} }
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
return 'pdo_sqlsrv';
}
} }
...@@ -40,16 +40,6 @@ class Driver extends AbstractSQLAnywhereDriver ...@@ -40,16 +40,6 @@ class Driver extends AbstractSQLAnywhereDriver
} }
} }
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
return 'sqlanywhere';
}
/** /**
* Build the connection string for given connection parameters and driver options. * Build the connection string for given connection parameters and driver options.
* *
......
...@@ -47,14 +47,4 @@ class Driver extends AbstractSQLServerDriver ...@@ -47,14 +47,4 @@ class Driver extends AbstractSQLServerDriver
return new SQLSrvConnection($serverName, $driverOptions); return new SQLSrvConnection($serverName, $driverOptions);
} }
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
return 'sqlsrv';
}
} }
<?php
declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Driver\IBMDB2;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\IBMDB2\DB2Driver;
use Doctrine\Tests\DBAL\Driver\AbstractDB2DriverTest;
class DB2DriverTest extends AbstractDB2DriverTest
{
public function testReturnsName() : void
{
self::assertSame('ibm_db2', $this->driver->getName());
}
protected function createDriver() : DriverInterface
{
return new DB2Driver();
}
}
<?php
declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Driver\Mysqli;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\Mysqli\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractMySQLDriverTest;
class DriverTest extends AbstractMySQLDriverTest
{
public function testReturnsName() : void
{
self::assertSame('mysqli', $this->driver->getName());
}
protected function createDriver() : DriverInterface
{
return new Driver();
}
}
<?php
declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Driver\OCI8;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractOracleDriverTest;
class DriverTest extends AbstractOracleDriverTest
{
public function testReturnsName() : void
{
self::assertSame('oci8', $this->driver->getName());
}
protected function createDriver() : DriverInterface
{
return new Driver();
}
}
<?php
declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Driver\PDOMySql;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOMySql\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractMySQLDriverTest;
class DriverTest extends AbstractMySQLDriverTest
{
public function testReturnsName() : void
{
self::assertSame('pdo_mysql', $this->driver->getName());
}
protected function createDriver() : DriverInterface
{
return new Driver();
}
}
<?php
declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Driver\PDOOracle;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOOracle\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractOracleDriverTest;
class DriverTest extends AbstractOracleDriverTest
{
public function testReturnsName() : void
{
self::assertSame('pdo_oracle', $this->driver->getName());
}
protected function createDriver() : DriverInterface
{
return new Driver();
}
}
...@@ -9,23 +9,25 @@ use Doctrine\DBAL\Driver\PDOConnection; ...@@ -9,23 +9,25 @@ use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\DBAL\Driver\PDOPgSql\Driver; use Doctrine\DBAL\Driver\PDOPgSql\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractPostgreSQLDriverTest; use Doctrine\Tests\DBAL\Driver\AbstractPostgreSQLDriverTest;
use PDO; use PDO;
use PDOException;
use function defined;
class DriverTest extends AbstractPostgreSQLDriverTest class DriverTest extends AbstractPostgreSQLDriverTest
{ {
public function testReturnsName() : void 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 * @group DBAL-920
*/ */
public function testConnectionDisablesPreparesOnPhp56() : void public function testConnectionDisablesPrepares() : void
{ {
$this->skipWhenNotUsingPhp56AndPdoPgsql();
$connection = $this->createDriver()->connect( $connection = $this->createDriver()->connect(
[ [
'host' => $GLOBALS['db_host'], 'host' => $GLOBALS['db_host'],
...@@ -36,22 +38,16 @@ class DriverTest extends AbstractPostgreSQLDriverTest ...@@ -36,22 +38,16 @@ class DriverTest extends AbstractPostgreSQLDriverTest
); );
self::assertInstanceOf(PDOConnection::class, $connection); self::assertInstanceOf(PDOConnection::class, $connection);
self::assertTrue(
try { $connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES)
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');
}
} }
/** /**
* @group DBAL-920 * @group DBAL-920
*/ */
public function testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined() : void public function testConnectionDoesNotDisablePreparesWhenAttributeDefined() : void
{ {
$this->skipWhenNotUsingPhp56AndPdoPgsql();
$connection = $this->createDriver()->connect( $connection = $this->createDriver()->connect(
[ [
'host' => $GLOBALS['db_host'], 'host' => $GLOBALS['db_host'],
...@@ -63,25 +59,16 @@ class DriverTest extends AbstractPostgreSQLDriverTest ...@@ -63,25 +59,16 @@ class DriverTest extends AbstractPostgreSQLDriverTest
); );
self::assertInstanceOf(PDOConnection::class, $connection); self::assertInstanceOf(PDOConnection::class, $connection);
self::assertNotTrue(
try { $connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES)
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');
}
} }
/** /**
* @group DBAL-920 * @group DBAL-920
*/ */
public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplicitlyDefined() : void public function testConnectionDisablePreparesWhenDisablePreparesIsExplicitlyDefined() : void
{ {
$this->skipWhenNotUsingPhp56AndPdoPgsql();
$connection = $this->createDriver()->connect( $connection = $this->createDriver()->connect(
[ [
'host' => $GLOBALS['db_host'], 'host' => $GLOBALS['db_host'],
...@@ -93,13 +80,9 @@ class DriverTest extends AbstractPostgreSQLDriverTest ...@@ -93,13 +80,9 @@ class DriverTest extends AbstractPostgreSQLDriverTest
); );
self::assertInstanceOf(PDOConnection::class, $connection); self::assertInstanceOf(PDOConnection::class, $connection);
self::assertTrue(
try { $connection->getWrappedConnection()->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES)
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');
}
} }
/** /**
...@@ -109,17 +92,4 @@ class DriverTest extends AbstractPostgreSQLDriverTest ...@@ -109,17 +92,4 @@ class DriverTest extends AbstractPostgreSQLDriverTest
{ {
return new Driver(); return new Driver();
} }
private function skipWhenNotUsingPhp56AndPdoPgsql() : void
{
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');
}
} }
<?php
declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Driver\PDOSqlite;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOSqlite\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractSQLiteDriverTest;
class DriverTest extends AbstractSQLiteDriverTest
{
public function testReturnsName() : void
{
self::assertSame('pdo_sqlite', $this->driver->getName());
}
protected function createDriver() : DriverInterface
{
return new Driver();
}
}
<?php
declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Driver\PDOSqlsrv;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOSqlsrv\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractSQLServerDriverTest;
class DriverTest extends AbstractSQLServerDriverTest
{
public function testReturnsName() : void
{
self::assertSame('pdo_sqlsrv', $this->driver->getName());
}
protected function createDriver() : DriverInterface
{
return new Driver();
}
}
<?php
declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Driver\SQLAnywhere;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\SQLAnywhere\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractSQLAnywhereDriverTest;
class DriverTest extends AbstractSQLAnywhereDriverTest
{
public function testReturnsName() : void
{
self::assertSame('sqlanywhere', $this->driver->getName());
}
protected function createDriver() : DriverInterface
{
return new Driver();
}
}
<?php
declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Driver\SQLSrv;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\SQLSrv\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractSQLServerDriverTest;
class DriverTest extends AbstractSQLServerDriverTest
{
public function testReturnsName() : void
{
self::assertSame('sqlsrv', $this->driver->getName());
}
protected function createDriver() : DriverInterface
{
return new Driver();
}
}
...@@ -5,8 +5,12 @@ declare(strict_types=1); ...@@ -5,8 +5,12 @@ declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Functional; namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\IBMDB2\DB2Driver;
use Doctrine\DBAL\Driver\PDOConnection; 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\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\Driver\Statement;
use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
...@@ -14,6 +18,7 @@ use Doctrine\DBAL\Schema\Table; ...@@ -14,6 +18,7 @@ use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalFunctionalTestCase; use Doctrine\Tests\DbalFunctionalTestCase;
use function base64_decode; use function base64_decode;
use function get_class;
use function sprintf; use function sprintf;
use function stream_get_contents; use function stream_get_contents;
...@@ -341,26 +346,24 @@ EOF ...@@ -341,26 +346,24 @@ EOF
public function testExecWithRedundantParameters() : void public function testExecWithRedundantParameters() : void
{ {
$driver = $this->connection->getDriver()->getName(); $driver = $this->connection->getDriver();
switch ($driver) { if ($driver instanceof PDOMySQLDriver
case 'pdo_mysql': || $driver instanceof PDOOracleDriver
case 'pdo_oracle': || $driver instanceof PDOSQLSRVDriver
case 'pdo_sqlsrv': ) {
self::markTestSkipped(sprintf( self::markTestSkipped(sprintf(
'PDOStatement::execute() implemented in the "%s" driver does not report redundant parameters', 'The underlying implementation of the "%s" driver does not report redundant parameters',
$driver get_class($driver)
)); ));
}
return;
case 'ibm_db2': if ($driver instanceof DB2Driver) {
self::markTestSkipped('db2_execute() does not report redundant parameters'); self::markTestSkipped('db2_execute() does not report redundant parameters');
}
return;
case 'sqlsrv': if ($driver instanceof SQLSRVDriver) {
self::markTestSkipped('sqlsrv_prepare() does not report redundant parameters'); self::markTestSkipped('sqlsrv_prepare() does not report redundant parameters');
return;
} }
$platform = $this->connection->getDatabasePlatform(); $platform = $this->connection->getDatabasePlatform();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment