Skip to content

Commit

Permalink
Merge pull request #3553 from morozov/remove-driver-name
Browse files Browse the repository at this point in the history
Removed Driver::getName()
  • Loading branch information
morozov authored May 24, 2019
2 parents d1c6699 + 40f26b1 commit 0723eeb
Show file tree
Hide file tree
Showing 25 changed files with 79 additions and 367 deletions.
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
7 changes: 0 additions & 7 deletions lib/Doctrine/DBAL/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
8 changes: 0 additions & 8 deletions lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
8 changes: 0 additions & 8 deletions lib/Doctrine/DBAL/Driver/Mysqli/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
8 changes: 0 additions & 8 deletions lib/Doctrine/DBAL/Driver/OCI8/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,4 @@ protected function _constructDsn(array $params)
{
return $this->getEasyConnectString($params);
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'oci8';
}
}
8 changes: 0 additions & 8 deletions lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,4 @@ protected function constructPdoDsn(array $params)

return $dsn;
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'pdo_mysql';
}
}
8 changes: 0 additions & 8 deletions lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,4 @@ private function constructPdoDsn(array $params)

return $dsn;
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'pdo_oracle';
}
}
8 changes: 0 additions & 8 deletions lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,4 @@ private function _constructPdoDsn(array $params)

return $dsn;
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'pdo_pgsql';
}
}
8 changes: 0 additions & 8 deletions lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,4 @@ protected function _constructPdoDsn(array $params)

return $dsn;
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'pdo_sqlite';
}
}
8 changes: 0 additions & 8 deletions lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,4 @@ private function getConnectionOptionsDsn(array $connectionOptions) : string

return $connectionOptionsDsn;
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'pdo_sqlsrv';
}
}
8 changes: 0 additions & 8 deletions lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
8 changes: 0 additions & 8 deletions lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
21 changes: 0 additions & 21 deletions tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php

This file was deleted.

21 changes: 0 additions & 21 deletions tests/Doctrine/Tests/DBAL/Driver/Mysqli/DriverTest.php

This file was deleted.

21 changes: 0 additions & 21 deletions tests/Doctrine/Tests/DBAL/Driver/OCI8/DriverTest.php

This file was deleted.

21 changes: 0 additions & 21 deletions tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php

This file was deleted.

21 changes: 0 additions & 21 deletions tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php

This file was deleted.

74 changes: 20 additions & 54 deletions tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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'],
Expand All @@ -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'],
Expand All @@ -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)
);
}

/**
Expand All @@ -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');
}
}
Loading

0 comments on commit 0723eeb

Please sign in to comment.