Unverified Commit 84e365da authored by Sergei Morozov's avatar Sergei Morozov

Merge pull request #3553 from morozov/remove-driver-name

Removed Driver::getName()
parents a4158b5c 5857be40
# 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.
......
......@@ -43,15 +43,6 @@ interface Driver
*/
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.
*
......
......@@ -38,14 +38,4 @@ class DB2Driver extends AbstractDB2Driver
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
throw DBALException::driverException($this, $e);
}
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'mysqli';
}
}
......@@ -43,14 +43,4 @@ class Driver extends AbstractOracleDriver
{
return $this->getEasyConnectString($params);
}
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
return 'oci8';
}
}
......@@ -66,14 +66,4 @@ class Driver extends AbstractMySQLDriver
return $dsn;
}
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
return 'pdo_mysql';
}
}
......@@ -58,12 +58,4 @@ class Driver extends AbstractOracleDriver
return $dsn;
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'pdo_oracle';
}
}
......@@ -111,14 +111,4 @@ class Driver extends AbstractPostgreSQLDriver
return $dsn;
}
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
return 'pdo_pgsql';
}
}
......@@ -74,14 +74,4 @@ class Driver extends AbstractSQLiteDriver
return $dsn;
}
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
return 'pdo_sqlite';
}
}
......@@ -87,14 +87,4 @@ class Driver extends AbstractSQLServerDriver
return $connectionOptionsDsn;
}
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
return 'pdo_sqlsrv';
}
}
......@@ -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.
*
......
......@@ -47,14 +47,4 @@ class Driver extends AbstractSQLServerDriver
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;
use Doctrine\DBAL\Driver\PDOPgSql\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractPostgreSQLDriverTest;
use PDO;
use PDOException;
use function defined;
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
*/
public function testConnectionDisablesPreparesOnPhp56() : void
public function testConnectionDisablesPrepares() : void
{
$this->skipWhenNotUsingPhp56AndPdoPgsql();
$connection = $this->createDriver()->connect(
[
'host' => $GLOBALS['db_host'],
......@@ -36,22 +38,16 @@ class DriverTest extends AbstractPostgreSQLDriverTest
);
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() : void
public function testConnectionDoesNotDisablePreparesWhenAttributeDefined() : void
{
$this->skipWhenNotUsingPhp56AndPdoPgsql();
$connection = $this->createDriver()->connect(
[
'host' => $GLOBALS['db_host'],
......@@ -63,25 +59,16 @@ class DriverTest extends AbstractPostgreSQLDriverTest
);
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() : void
public function testConnectionDisablePreparesWhenDisablePreparesIsExplicitlyDefined() : void
{
$this->skipWhenNotUsingPhp56AndPdoPgsql();
$connection = $this->createDriver()->connect(
[
'host' => $GLOBALS['db_host'],
......@@ -93,13 +80,9 @@ class DriverTest extends AbstractPostgreSQLDriverTest
);
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,17 +92,4 @@ class DriverTest extends AbstractPostgreSQLDriverTest
{
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);
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\Schema\Table;
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;
......@@ -341,26 +346,24 @@ EOF
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();
......
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