Unverified Commit 9d692758 authored by Sergei Morozov's avatar Sergei Morozov Committed by GitHub

Merge pull request #4127 from morozov/rework-test-extension-detection

Rework extension detection in tests
parents 60f9ff70 4dc7b9ed
......@@ -5,8 +5,10 @@ namespace Doctrine\Tests\DBAL\Driver\IBMDB2;
use Doctrine\DBAL\Driver\IBMDB2\DB2Connection;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use function extension_loaded;
/**
* @requires extension ibm_db2
*/
class DB2ConnectionTest extends DbalTestCase
{
/**
......@@ -18,10 +20,6 @@ class DB2ConnectionTest extends DbalTestCase
protected function setUp() : void
{
if (! extension_loaded('ibm_db2')) {
$this->markTestSkipped('ibm_db2 is not installed.');
}
parent::setUp();
$this->connectionMock = $this->getMockBuilder(DB2Connection::class)
......
......@@ -7,10 +7,12 @@ use Doctrine\DBAL\Driver\Mysqli\MysqliException;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\Tests\DbalFunctionalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use function extension_loaded;
use function restore_error_handler;
use function set_error_handler;
/**
* @requires extension mysqli
*/
class MysqliConnectionTest extends DbalFunctionalTestCase
{
/**
......@@ -22,10 +24,6 @@ class MysqliConnectionTest extends DbalFunctionalTestCase
protected function setUp() : void
{
if (! extension_loaded('mysqli')) {
$this->markTestSkipped('mysqli is not installed.');
}
parent::setUp();
if (! $this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
......
......@@ -5,8 +5,10 @@ namespace Doctrine\Tests\DBAL\Driver\OCI8;
use Doctrine\DBAL\Driver\OCI8\OCI8Connection;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use function extension_loaded;
/**
* @requires extension oci8
*/
class OCI8ConnectionTest extends DbalTestCase
{
/**
......@@ -18,10 +20,6 @@ class OCI8ConnectionTest extends DbalTestCase
protected function setUp() : void
{
if (! extension_loaded('oci8')) {
$this->markTestSkipped('oci8 is not installed.');
}
parent::setUp();
$this->connectionMock = $this->getMockBuilder(OCI8Connection::class)
......
......@@ -7,19 +7,12 @@ use Doctrine\DBAL\Driver\OCI8\OCI8Exception;
use Doctrine\DBAL\Driver\OCI8\OCI8Statement;
use Doctrine\Tests\DbalTestCase;
use ReflectionProperty;
use function extension_loaded;
/**
* @requires extension oci8
*/
class OCI8StatementTest extends DbalTestCase
{
protected function setUp() : void
{
if (! extension_loaded('oci8')) {
$this->markTestSkipped('oci8 is not installed.');
}
parent::setUp();
}
/**
* This scenario shows that when the first parameter is not null
* it properly sets $hasZeroIndex to 1 and calls bindValue starting at 1.
......
......@@ -5,8 +5,10 @@ namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Driver\PDOException;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use function extension_loaded;
/**
* @requires extension pdo
*/
class PDOExceptionTest extends DbalTestCase
{
public const ERROR_CODE = 666;
......@@ -31,10 +33,6 @@ class PDOExceptionTest extends DbalTestCase
protected function setUp() : void
{
if (! extension_loaded('PDO')) {
$this->markTestSkipped('PDO is not installed.');
}
parent::setUp();
$this->wrappedException = new \PDOException(self::MESSAGE, self::SQLSTATE);
......
......@@ -5,8 +5,10 @@ namespace Doctrine\Tests\DBAL\Driver\SQLAnywhere;
use Doctrine\DBAL\Driver\SQLAnywhere\SQLAnywhereConnection;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use function extension_loaded;
/**
* @requires extension sqlanywhere
*/
class SQLAnywhereConnectionTest extends DbalTestCase
{
/**
......@@ -18,10 +20,6 @@ class SQLAnywhereConnectionTest extends DbalTestCase
protected function setUp() : void
{
if (! extension_loaded('sqlanywhere')) {
$this->markTestSkipped('sqlanywhere is not installed.');
}
parent::setUp();
$this->connectionMock = $this->getMockBuilder(SQLAnywhereConnection::class)
......
......@@ -5,7 +5,6 @@ namespace Doctrine\Tests\DBAL\Driver\SQLSrv;
use Doctrine\DBAL\Driver\SQLSrv\SQLSrvConnection;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use function extension_loaded;
class SQLSrvConnectionTest extends DbalTestCase
{
......@@ -16,12 +15,11 @@ class SQLSrvConnectionTest extends DbalTestCase
*/
private $connectionMock;
/**
* @requires extension sqlsrv
*/
protected function setUp() : void
{
if (! extension_loaded('sqlsrv')) {
$this->markTestSkipped('sqlsrv is not installed.');
}
parent::setUp();
$this->connectionMock = $this->getMockBuilder(SQLSrvConnection::class)
......
......@@ -5,16 +5,14 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\IBMDB2;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\IBMDB2\DB2Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
/**
* @requires extension ibm_db2
*/
class DB2DriverTest extends AbstractDriverTest
{
protected function setUp() : void
{
if (! extension_loaded('ibm_db2')) {
$this->markTestSkipped('ibm_db2 is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof DB2Driver) {
......
......@@ -7,16 +7,14 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\IBMDB2;
use Doctrine\DBAL\Driver\IBMDB2\DB2Driver;
use Doctrine\Tests\DbalFunctionalTestCase;
use PHPUnit\Framework\Error\Notice;
use function extension_loaded;
/**
* @requires extension ibm_db2
*/
class DB2StatementTest extends DbalFunctionalTestCase
{
protected function setUp() : void
{
if (! extension_loaded('ibm_db2')) {
$this->markTestSkipped('ibm_db2 is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof DB2Driver) {
......
......@@ -7,17 +7,15 @@ use Doctrine\DBAL\Driver\Mysqli\MysqliConnection;
use Doctrine\DBAL\Driver\Mysqli\MysqliException;
use Doctrine\Tests\DbalFunctionalTestCase;
use Doctrine\Tests\TestUtil;
use function extension_loaded;
use const MYSQLI_OPT_CONNECT_TIMEOUT;
/**
* @requires extension mysqli
*/
class ConnectionTest extends DbalFunctionalTestCase
{
protected function setUp() : void
{
if (! extension_loaded('mysqli')) {
$this->markTestSkipped('mysqli is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof Driver) {
......
......@@ -5,16 +5,14 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\Mysqli;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\Mysqli\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
/**
* @requires extension mysqli
*/
class DriverTest extends AbstractDriverTest
{
protected function setUp() : void
{
if (! extension_loaded('mysqli')) {
$this->markTestSkipped('mysqli is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof Driver) {
......
......@@ -5,16 +5,14 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\OCI8;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
/**
* @requires extension oci8
*/
class DriverTest extends AbstractDriverTest
{
protected function setUp() : void
{
if (! extension_loaded('oci8')) {
$this->markTestSkipped('oci8 is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof Driver) {
......
......@@ -6,8 +6,10 @@ use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\DBAL\Driver\OCI8\OCI8Connection;
use Doctrine\DBAL\Schema\Table;
use Doctrine\Tests\DbalFunctionalTestCase;
use function extension_loaded;
/**
* @requires extension oci8
*/
class OCI8ConnectionTest extends DbalFunctionalTestCase
{
/** @var OCI8Connection */
......@@ -15,10 +17,6 @@ class OCI8ConnectionTest extends DbalFunctionalTestCase
protected function setUp() : void
{
if (! extension_loaded('oci8')) {
$this->markTestSkipped('oci8 is not installed.');
}
parent::setUp();
if (! $this->connection->getDriver() instanceof Driver) {
......
......@@ -4,16 +4,14 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\OCI8;
use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\Tests\DbalFunctionalTestCase;
use function extension_loaded;
/**
* @requires extension oci8
*/
class StatementTest extends DbalFunctionalTestCase
{
protected function setUp() : void
{
if (! extension_loaded('oci8')) {
$this->markTestSkipped('oci8 is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof Driver) {
......
......@@ -9,10 +9,12 @@ 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;
/**
* @requires extension pdo
*/
class PDOConnectionTest extends DbalFunctionalTestCase
{
/**
......@@ -24,10 +26,6 @@ class PDOConnectionTest extends DbalFunctionalTestCase
protected function setUp() : void
{
if (! extension_loaded('PDO')) {
$this->markTestSkipped('PDO is not installed.');
}
parent::setUp();
$this->driverConnection = $this->connection->getWrappedConnection();
......
......@@ -5,16 +5,14 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\PDOMySql;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOMySql\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
/**
* @requires extension pdo_mysql
*/
class DriverTest extends AbstractDriverTest
{
protected function setUp() : void
{
if (! extension_loaded('pdo_mysql')) {
$this->markTestSkipped('pdo_mysql is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof Driver) {
......
......@@ -5,16 +5,14 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\PDOOracle;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOOracle\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
/**
* @requires extension pdo_oci
*/
class DriverTest extends AbstractDriverTest
{
protected function setUp() : void
{
if (! extension_loaded('PDO_OCI')) {
$this->markTestSkipped('PDO_OCI is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof Driver) {
......
......@@ -8,18 +8,16 @@ use Doctrine\DBAL\Driver\PDOPgSql\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use Doctrine\Tests\TestUtil;
use function array_key_exists;
use function extension_loaded;
use function microtime;
use function sprintf;
/**
* @requires extension pdo_pgsql
*/
class DriverTest extends AbstractDriverTest
{
protected function setUp() : void
{
if (! extension_loaded('pdo_pgsql')) {
$this->markTestSkipped('pdo_pgsql is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof Driver) {
......
......@@ -6,16 +6,14 @@ use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\Tests\DbalFunctionalTestCase;
use function extension_loaded;
/**
* @requires extension pdo_pgsql
*/
class PDOPgsqlConnectionTest extends DbalFunctionalTestCase
{
protected function setUp() : void
{
if (! extension_loaded('pdo_pgsql')) {
$this->markTestSkipped('pdo_pgsql is not loaded.');
}
parent::setUp();
if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
......
......@@ -5,16 +5,14 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\PDOSqlite;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOSqlite\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
/**
* @requires extension pdo_sqlite
*/
class DriverTest extends AbstractDriverTest
{
protected function setUp() : void
{
if (! extension_loaded('pdo_sqlite')) {
$this->markTestSkipped('pdo_sqlite is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof Driver) {
......
......@@ -8,16 +8,14 @@ use Doctrine\DBAL\Driver\PDOSqlsrv\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use Doctrine\Tests\TestUtil;
use PDO;
use function extension_loaded;
/**
* @requires extension pdo_sqlsrv
*/
class DriverTest extends AbstractDriverTest
{
protected function setUp() : void
{
if (! extension_loaded('pdo_sqlsrv')) {
$this->markTestSkipped('pdo_sqlsrv is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof Driver) {
......
......@@ -5,16 +5,14 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\SQLAnywhere;
use Doctrine\DBAL\Driver\SQLAnywhere\Driver;
use Doctrine\DBAL\DriverManager;
use Doctrine\Tests\DbalFunctionalTestCase;
use function extension_loaded;
/**
* @requires extension sqlanywhere
*/
class ConnectionTest extends DbalFunctionalTestCase
{
protected function setUp() : void
{
if (! extension_loaded('sqlanywhere')) {
$this->markTestSkipped('sqlanywhere is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof Driver) {
......
......@@ -6,16 +6,14 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\SQLAnywhere\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
/**
* @requires extension sqlanywhere
*/
class DriverTest extends AbstractDriverTest
{
protected function setUp() : void
{
if (! extension_loaded('sqlanywhere')) {
$this->markTestSkipped('sqlanywhere is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof Driver) {
......
......@@ -5,16 +5,14 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\SQLAnywhere;
use Doctrine\DBAL\Driver\SQLAnywhere\Driver;
use Doctrine\DBAL\DriverManager;
use Doctrine\Tests\DbalFunctionalTestCase;
use function extension_loaded;
/**
* @requires extension sqlanywhere
*/
class StatementTest extends DbalFunctionalTestCase
{
protected function setUp() : void
{
if (! extension_loaded('sqlanywhere')) {
$this->markTestSkipped('sqlanywhere is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof Driver) {
......
......@@ -5,16 +5,14 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\SQLSrv;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\SQLSrv\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
/**
* @requires extension sqlsrv
*/
class DriverTest extends AbstractDriverTest
{
protected function setUp() : void
{
if (! extension_loaded('sqlsrv')) {
$this->markTestSkipped('sqlsrv is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof Driver) {
......
......@@ -5,16 +5,14 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\SQLSrv;
use Doctrine\DBAL\Driver\SQLSrv\Driver;
use Doctrine\DBAL\Driver\SQLSrv\SQLSrvException;
use Doctrine\Tests\DbalFunctionalTestCase;
use function extension_loaded;
/**
* @requires extension sqlsrv
*/
class StatementTest extends DbalFunctionalTestCase
{
protected function setUp() : void
{
if (! extension_loaded('sqlsrv')) {
self::markTestSkipped('sqlsrv is not installed.');
}
parent::setUp();
if ($this->connection->getDriver() instanceof Driver) {
......
......@@ -6,16 +6,14 @@ use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\DBAL\Schema\Table;
use Doctrine\Tests\DbalFunctionalTestCase;
use PDO;
use function extension_loaded;
/**
* @requires extension pdo
*/
class PDOStatementTest extends DbalFunctionalTestCase
{
protected function setUp() : void
{
if (! extension_loaded('pdo')) {
$this->markTestSkipped('PDO is not installed');
}
parent::setUp();
if (! $this->connection->getWrappedConnection() instanceof PDOConnection) {
......
......@@ -9,11 +9,7 @@ use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use SQLite3;
use function array_map;
use function dirname;
use function extension_loaded;
use function version_compare;
class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
......@@ -159,34 +155,6 @@ EOS
self::assertFalse($table->getColumn('column_binary')->getFixed());
}
public function testNonDefaultPKOrder() : void
{
if (! extension_loaded('sqlite3')) {
$this->markTestSkipped('This test requires the SQLite3 extension.');
}
$version = SQLite3::version();
if (version_compare($version['versionString'], '3.7.16', '<')) {
$this->markTestSkipped('This version of sqlite doesn\'t return the order of the Primary Key.');
}
$this->connection->exec(<<<EOS
CREATE TABLE non_default_pk_order (
id INTEGER,
other_id INTEGER,
PRIMARY KEY(other_id, id)
)
EOS
);
$tableIndexes = $this->schemaManager->listTableIndexes('non_default_pk_order');
self::assertCount(1, $tableIndexes);
self::assertArrayHasKey('primary', $tableIndexes, 'listTableIndexes() has to return a "primary" array key.');
self::assertEquals(['other_id', 'id'], array_map('strtolower', $tableIndexes['primary']->getColumns()));
}
/**
* @group DBAL-1779
*/
......
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