Skip to content

Commit

Permalink
Detect driver in tests based on configured driver name
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Nov 6, 2021
1 parent 3f9b811 commit ca587df
Show file tree
Hide file tree
Showing 27 changed files with 77 additions and 72 deletions.
11 changes: 5 additions & 6 deletions tests/Functional/BlobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

namespace Doctrine\DBAL\Tests\Functional;

use Doctrine\DBAL\Driver\OCI8\Driver as OCI8Driver;
use Doctrine\DBAL\Driver\PDO;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Tests\TestUtil;
use Doctrine\DBAL\Types\Type;

use function fopen;
Expand All @@ -17,7 +16,7 @@ class BlobTest extends FunctionalTestCase
{
protected function setUp(): void
{
if ($this->connection->getDriver() instanceof PDO\OCI\Driver) {
if (TestUtil::isDriverOneOf('pdo_oci')) {
// inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported
// see http://php.net/manual/en/pdo.lobs.php#example-1035
self::markTestSkipped('DBAL doesn\'t support storing LOBs represented as streams using PDO_OCI');
Expand Down Expand Up @@ -50,7 +49,7 @@ public function testInsert(): void
public function testInsertProcessesStream(): void
{
// https://github.com/doctrine/dbal/issues/3290
if ($this->connection->getDriver() instanceof OCI8Driver) {
if (TestUtil::isDriverOneOf('oci8')) {
self::markTestIncomplete('The oci8 driver does not support stream resources as parameters');
}

Expand Down Expand Up @@ -106,7 +105,7 @@ public function testUpdate(): void
public function testUpdateProcessesStream(): void
{
// https://github.com/doctrine/dbal/issues/3290
if ($this->connection->getDriver() instanceof OCI8Driver) {
if (TestUtil::isDriverOneOf('oci8')) {
self::markTestIncomplete('The oci8 driver does not support stream resources as parameters');
}

Expand All @@ -133,7 +132,7 @@ public function testUpdateProcessesStream(): void

public function testBindParamProcessesStream(): void
{
if ($this->connection->getDriver() instanceof OCI8Driver) {
if (TestUtil::isDriverOneOf('oci8')) {
self::markTestIncomplete('The oci8 driver does not support stream resources as parameters');
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Functional/Driver/IBMDB2/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace Doctrine\DBAL\Tests\Functional\Driver\IBMDB2;

use Doctrine\DBAL\Driver\IBMDB2\Connection;
use Doctrine\DBAL\Driver\IBMDB2\Driver;
use Doctrine\DBAL\Driver\IBMDB2\Exception\ConnectionFailed;
use Doctrine\DBAL\Driver\IBMDB2\Exception\PrepareFailed;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Tests\TestUtil;
use ReflectionProperty;

use function db2_close;
Expand All @@ -18,11 +18,11 @@ class ConnectionTest extends FunctionalTestCase
{
protected function setUp(): void
{
if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('ibm_db2')) {
return;
}

$this->markTestSkipped('ibm_db2 only test.');
self::markTestSkipped('This test requires the ibm_db2 driver.');
}

protected function tearDown(): void
Expand Down
5 changes: 3 additions & 2 deletions tests/Functional/Driver/IBMDB2/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\IBMDB2\Driver;
use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest;
use Doctrine\DBAL\Tests\TestUtil;

/**
* @requires extension ibm_db2
Expand All @@ -15,11 +16,11 @@ protected function setUp(): void
{
parent::setUp();

if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('ibm_db2')) {
return;
}

self::markTestSkipped('ibm_db2 only test.');
self::markTestSkipped('This test requires the ibm_db2 driver.');
}

public function testConnectsWithoutDatabaseNameParameter(): void
Expand Down
6 changes: 3 additions & 3 deletions tests/Functional/Driver/IBMDB2/StatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Doctrine\DBAL\Tests\Functional\Driver\IBMDB2;

use Doctrine\DBAL\Driver\IBMDB2\Driver;
use Doctrine\DBAL\Driver\IBMDB2\Exception\StatementError;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Tests\TestUtil;

use const E_ALL;
use const E_NOTICE;
Expand All @@ -19,11 +19,11 @@ class StatementTest extends FunctionalTestCase
{
protected function setUp(): void
{
if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('ibm_db2')) {
return;
}

self::markTestSkipped('ibm_db2 only test.');
self::markTestSkipped('This test requires the ibm_db2 driver.');
}

public function testExecutionErrorsAreNotSuppressed(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Driver/Mysqli/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class ConnectionTest extends FunctionalTestCase
{
protected function setUp(): void
{
if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('mysqli')) {
return;
}

self::markTestSkipped('MySQLi only test.');
self::markTestSkipped('This test requires the mysqli driver.');
}

public function testSupportedDriverOptions(): void
Expand Down
5 changes: 3 additions & 2 deletions tests/Functional/Driver/Mysqli/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\Mysqli\Driver;
use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest;
use Doctrine\DBAL\Tests\TestUtil;

/**
* @requires extension mysqli
Expand All @@ -15,11 +16,11 @@ protected function setUp(): void
{
parent::setUp();

if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('mysqli')) {
return;
}

self::markTestSkipped('MySQLi only test.');
self::markTestSkipped('This test requires the mysqli driver.');
}

protected function createDriver(): DriverInterface
Expand Down
6 changes: 3 additions & 3 deletions tests/Functional/Driver/OCI8/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Doctrine\DBAL\Tests\Functional\Driver\OCI8;

use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Tests\TestUtil;

/**
* @requires extension oci8
Expand All @@ -13,11 +13,11 @@ class ConnectionTest extends FunctionalTestCase
{
protected function setUp(): void
{
if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('oci8')) {
return;
}

self::markTestSkipped('oci8 only test.');
self::markTestSkipped('This test requires the oci8 driver.');
}

public function testLastInsertIdAcceptsFqn(): void
Expand Down
5 changes: 3 additions & 2 deletions tests/Functional/Driver/OCI8/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest;
use Doctrine\DBAL\Tests\TestUtil;

/**
* @requires extension oci8
Expand All @@ -15,11 +16,11 @@ protected function setUp(): void
{
parent::setUp();

if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('oci8')) {
return;
}

self::markTestSkipped('oci8 only test.');
self::markTestSkipped('This test requires the oci8 driver.');
}

public function testConnectsWithoutDatabaseNameParameter(): void
Expand Down
5 changes: 2 additions & 3 deletions tests/Functional/Driver/OCI8/ResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Doctrine\DBAL\Tests\Functional\Driver\OCI8;

use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Tests\TestUtil;
Expand Down Expand Up @@ -32,11 +31,11 @@ protected function setUp(): void
{
$this->connectionParams = TestUtil::getConnectionParams();

if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('oci8')) {
return;
}

self::markTestSkipped('oci8 only test.');
self::markTestSkipped('This test requires the oci8 driver.');
}

protected function tearDown(): void
Expand Down
6 changes: 3 additions & 3 deletions tests/Functional/Driver/OCI8/StatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Doctrine\DBAL\Tests\Functional\Driver\OCI8;

use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Tests\TestUtil;

/**
* @requires extension oci8
Expand All @@ -12,11 +12,11 @@ class StatementTest extends FunctionalTestCase
{
protected function setUp(): void
{
if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('oci8')) {
return;
}

self::markTestSkipped('oci8 only test.');
self::markTestSkipped('This test requires the oci8 driver.');
}

/**
Expand Down
5 changes: 3 additions & 2 deletions tests/Functional/Driver/PDO/MySQL/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDO\MySQL\Driver;
use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest;
use Doctrine\DBAL\Tests\TestUtil;

/**
* @requires extension pdo_mysql
Expand All @@ -15,11 +16,11 @@ protected function setUp(): void
{
parent::setUp();

if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('pdo_mysql')) {
return;
}

self::markTestSkipped('pdo_mysql only test.');
self::markTestSkipped('This test requires the pdo_mysql driver.');
}

protected function createDriver(): DriverInterface
Expand Down
5 changes: 3 additions & 2 deletions tests/Functional/Driver/PDO/OCI/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDO\OCI\Driver;
use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest;
use Doctrine\DBAL\Tests\TestUtil;

/**
* @requires extension pdo_oci
Expand All @@ -15,11 +16,11 @@ protected function setUp(): void
{
parent::setUp();

if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('pdo_oci')) {
return;
}

self::markTestSkipped('PDO_OCI only test.');
self::markTestSkipped('This test requires the pdo_oci driver.');
}

public function testConnectsWithoutDatabaseNameParameter(): void
Expand Down
6 changes: 3 additions & 3 deletions tests/Functional/Driver/PDO/PgSQL/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Doctrine\DBAL\Tests\Functional\Driver\PDO\PgSQL;

use Doctrine\DBAL\Driver\PDO\PgSQL\Driver;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Tests\TestUtil;

/**
* @requires extension pdo_pgsql
Expand All @@ -13,11 +13,11 @@ class ConnectionTest extends FunctionalTestCase
{
protected function setUp(): void
{
if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('pdo_pgsql')) {
return;
}

self::markTestSkipped('pdo_pgsql only test.');
self::markTestSkipped('This test requires the pdo_pgsql driver.');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Driver/PDO/PgSQL/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ protected function setUp(): void
{
parent::setUp();

if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('pdo_pgsql')) {
return;
}

self::markTestSkipped('pdo_pgsql only test.');
self::markTestSkipped('This test requires the pdo_pgsql driver.');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Driver/PDO/SQLSrv/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ protected function setUp(): void
{
parent::setUp();

if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('pdo_sqlsrv')) {
return;
}

self::markTestSkipped('pdo_sqlsrv only test.');
self::markTestSkipped('This test requires the pdo_sqlsrv driver.');
}

protected function createDriver(): DriverInterface
Expand Down
5 changes: 3 additions & 2 deletions tests/Functional/Driver/PDO/SQLite/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDO\SQLite\Driver;
use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest;
use Doctrine\DBAL\Tests\TestUtil;

/**
* @requires extension pdo_sqlite
Expand All @@ -15,11 +16,11 @@ protected function setUp(): void
{
parent::setUp();

if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('pdo_sqlite')) {
return;
}

self::markTestSkipped('pdo_sqlite only test.');
self::markTestSkipped('This test requires the pdo_sqlite driver.');
}

public function testReturnsDatabaseNameWithoutDatabaseNameParameter(): void
Expand Down
5 changes: 3 additions & 2 deletions tests/Functional/Driver/SQLSrv/DriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\SQLSrv\Driver;
use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest;
use Doctrine\DBAL\Tests\TestUtil;

/**
* @requires extension sqlsrv
Expand All @@ -15,11 +16,11 @@ protected function setUp(): void
{
parent::setUp();

if ($this->connection->getDriver() instanceof Driver) {
if (TestUtil::isDriverOneOf('sqlsrv')) {
return;
}

self::markTestSkipped('sqlsrv only test.');
self::markTestSkipped('This test requires the sqlsrv driver.');
}

protected function createDriver(): DriverInterface
Expand Down
Loading

0 comments on commit ca587df

Please sign in to comment.