Deprecated 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 e07dad91
# Upgrade to 2.10
## Deprecated `Doctrine\DBAL\Driver::getName()`
Relying on the name of the driver is discouraged. For referencing the driver, use its class name.
## Deprecated usage of user-provided `PDO` instance
The usage of user-provided `PDO` instance is deprecated. The known use cases are:
......
......@@ -42,6 +42,8 @@ interface Driver
/**
* Gets the name of the driver.
*
* @deprecated
*
* @return string The name of the driver.
*/
public function getName();
......
......@@ -49,6 +49,8 @@ class Driver extends \Doctrine\DBAL\Driver\PDOMySql\Driver
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
......
......@@ -39,6 +39,8 @@ class DB2Driver extends AbstractDB2Driver
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
......
......@@ -44,6 +44,8 @@ class Driver extends AbstractOracleDriver
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
......
......@@ -49,6 +49,8 @@ class Driver extends AbstractDB2Driver
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
......
......@@ -62,6 +62,8 @@ class Driver extends AbstractMySQLDriver
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
......
......@@ -108,6 +108,8 @@ class Driver extends AbstractPostgreSQLDriver
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
......
......@@ -73,6 +73,8 @@ class Driver extends AbstractSQLiteDriver
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
......
......@@ -83,6 +83,8 @@ class Driver extends AbstractSQLServerDriver
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
......
......@@ -40,6 +40,8 @@ class Driver extends AbstractSQLAnywhereDriver
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
......
......@@ -48,6 +48,8 @@ class Driver extends AbstractSQLServerDriver
/**
* {@inheritdoc}
*
* @deprecated
*/
public function getName()
{
......
......@@ -4,9 +4,13 @@ namespace Doctrine\Tests\DBAL\Functional\Driver;
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 extension_loaded;
use function get_class;
use function sprintf;
class PDOConnectionTest extends DbalFunctionalTestCase
......@@ -66,10 +70,24 @@ class PDOConnectionTest extends DbalFunctionalTestCase
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->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
......@@ -77,18 +95,6 @@ class PDOConnectionTest extends DbalFunctionalTestCase
$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()
......
......@@ -40,6 +40,7 @@ use function current;
use function end;
use function explode;
use function in_array;
use function sprintf;
use function str_replace;
use function strcasecmp;
use function strlen;
......@@ -130,8 +131,12 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
*/
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';
......@@ -158,8 +163,12 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
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);
......
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