Unverified Commit 98c23feb authored by Sergei Morozov's avatar Sergei Morozov

Merge branch '2.11.x' into 3.0.x

parents 99c1b213 cedf3a28
...@@ -319,22 +319,49 @@ Please use other database client applications for import, e.g.: ...@@ -319,22 +319,49 @@ Please use other database client applications for import, e.g.:
# Upgrade to 2.11 # Upgrade to 2.11
## PDO-related classes outside of the PDO namespace are deprecated
The following outside of the PDO namespace have been deprecated in favor of their counterparts in the PDO namespace:
- `PDOMySql\Driver``PDO\MySQL\Driver`
- `PDOOracle\Driver``PDO\OCI\Driver`
- `PDOPgSql\Driver``PDO\PgSQL\Driver`
- `PDOSqlite\Driver``PDO\SQLite\Driver`
- `PDOSqlsrv\Driver``PDO\SQLSrv\Driver`
- `PDOSqlsrv\Connection``PDO\SQLSrv\Connection`
- `PDOSqlsrv\Statement``PDO\SQLSrv\Statement`
## Deprecations in driver-level exception handling
1. The `ExceptionConverterDriver` interface and the usage of the `convertException()` method on the `Driver` objects are deprecated.
2. The `driverException()` and `driverExceptionDuringQuery()` factory methods of the `DBALException` class are deprecated.
3. Relying on the wrapper layer handling non-driver exceptions is deprecated.
## `DBALException` factory method deprecations
1. `DBALException::invalidPlatformType()` is deprecated as unused as of v2.7.0.
2. `DBALException::invalidPdoInstance()` as passing a PDO instance via configuration is deprecated.
## `AbstractPlatform::fixSchemaElementName()` is deprecated.
The method is not used anywhere except for tests.
##`ServerInfoAwareConnection::requiresQueryForServerVersion()` is deprecated. ##`ServerInfoAwareConnection::requiresQueryForServerVersion()` is deprecated.
The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been deprecated as an implementation detail which is the same for almost all supported drivers. The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been deprecated as an implementation detail which is the same for almost all supported drivers.
## Statement constructors are marked internal ## Connection and Statement constructors are marked internal
1. Driver connection objects can be only created by the corresponding drivers.
2. Wrapper connection objects can be only created by the driver manager.
3. The driver and wrapper connection objects can be only created by the corresponding connection objects.
The driver and wrapper statement objects can be only created by the corresponding connection objects. Additionally, the `SQLSrv\LastInsertId` class has been marked internal.
## The `PingableConnection` interface is deprecated ## The `PingableConnection` interface is deprecated
The wrapper connection will automatically handle the lost connection if the driver supports reporting it. The wrapper connection will automatically handle the lost connection if the driver supports reporting it.
## The `ExceptionConverterDriver` interface is deprecated
All drivers will have to implement the exception conversion API.
## `DriverException::getErrorCode()` is deprecated ## `DriverException::getErrorCode()` is deprecated
The `DriverException::getErrorCode()` is deprecated as redundant and inconsistently supported by drivers. Use `::getCode()` or `::getSQLState()` instead. The `DriverException::getErrorCode()` is deprecated as redundant and inconsistently supported by drivers. Use `::getCode()` or `::getSQLState()` instead.
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "93f2611cd4d28a1389369449c8b5fa5f", "content-hash": "0007c1323fe50966aa611c51b733e37b",
"packages": [ "packages": [
{ {
"name": "composer/package-versions-deprecated", "name": "composer/package-versions-deprecated",
...@@ -477,22 +477,22 @@ ...@@ -477,22 +477,22 @@
}, },
{ {
"name": "dealerdirect/phpcodesniffer-composer-installer", "name": "dealerdirect/phpcodesniffer-composer-installer",
"version": "v0.6.2", "version": "v0.7.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
"reference": "8001af8eb107fbfcedc31a8b51e20b07d85b457a" "reference": "e8d808670b8f882188368faaf1144448c169c0b7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/8001af8eb107fbfcedc31a8b51e20b07d85b457a", "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/e8d808670b8f882188368faaf1144448c169c0b7",
"reference": "8001af8eb107fbfcedc31a8b51e20b07d85b457a", "reference": "e8d808670b8f882188368faaf1144448c169c0b7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"composer-plugin-api": "^1.0", "composer-plugin-api": "^1.0 || ^2.0",
"php": "^5.3|^7", "php": ">=5.3",
"squizlabs/php_codesniffer": "^2|^3" "squizlabs/php_codesniffer": "^2 || ^3 || 4.0.x-dev"
}, },
"require-dev": { "require-dev": {
"composer/composer": "*", "composer/composer": "*",
...@@ -539,26 +539,26 @@ ...@@ -539,26 +539,26 @@
"stylecheck", "stylecheck",
"tests" "tests"
], ],
"time": "2020-01-29T20:22:20+00:00" "time": "2020-06-25T14:57:39+00:00"
}, },
{ {
"name": "doctrine/coding-standard", "name": "doctrine/coding-standard",
"version": "8.0.0", "version": "8.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/coding-standard.git", "url": "https://github.com/doctrine/coding-standard.git",
"reference": "742200e29fb8ffd58ba9abec8a9ec33db0884677" "reference": "637003febec655f1b27f4301b44bf2264be57434"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/coding-standard/zipball/742200e29fb8ffd58ba9abec8a9ec33db0884677", "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/637003febec655f1b27f4301b44bf2264be57434",
"reference": "742200e29fb8ffd58ba9abec8a9ec33db0884677", "reference": "637003febec655f1b27f4301b44bf2264be57434",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2", "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7",
"php": "^7.2 || ^8.0", "php": "^7.2 || ^8.0",
"slevomat/coding-standard": "^6.3.8", "slevomat/coding-standard": "^6.3.9",
"squizlabs/php_codesniffer": "^3.5.5" "squizlabs/php_codesniffer": "^3.5.5"
}, },
"type": "phpcodesniffer-standard", "type": "phpcodesniffer-standard",
...@@ -595,7 +595,7 @@ ...@@ -595,7 +595,7 @@
"standard", "standard",
"style" "style"
], ],
"time": "2020-06-02T17:58:43+00:00" "time": "2020-07-05T20:35:22+00:00"
}, },
{ {
"name": "doctrine/instantiator", "name": "doctrine/instantiator",
......
...@@ -148,6 +148,8 @@ class Connection implements DriverConnection ...@@ -148,6 +148,8 @@ class Connection implements DriverConnection
/** /**
* Initializes a new instance of the Connection class. * Initializes a new instance of the Connection class.
* *
* @internal The connection can be only instantiated by the driver manager.
*
* @param mixed[] $params The connection parameters. * @param mixed[] $params The connection parameters.
* @param Driver $driver The driver to use. * @param Driver $driver The driver to use.
* @param Configuration|null $config The configuration, optional. * @param Configuration|null $config The configuration, optional.
......
...@@ -94,6 +94,8 @@ class PrimaryReadReplicaConnection extends Connection ...@@ -94,6 +94,8 @@ class PrimaryReadReplicaConnection extends Connection
/** /**
* Creates Primary Replica Connection. * Creates Primary Replica Connection.
* *
* @internal The connection can be only instantiated by the driver manager.
*
* @param mixed[] $params * @param mixed[] $params
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
......
...@@ -28,6 +28,9 @@ class DBALException extends Exception ...@@ -28,6 +28,9 @@ class DBALException extends Exception
return new self(sprintf("Operation '%s' is not supported by platform.", $method)); return new self(sprintf("Operation '%s' is not supported by platform.", $method));
} }
/**
* @deprecated Use {@link invalidPlatformType()} instead.
*/
public static function invalidPlatformSpecified(): self public static function invalidPlatformSpecified(): self
{ {
return new self( return new self(
...@@ -80,6 +83,8 @@ class DBALException extends Exception ...@@ -80,6 +83,8 @@ class DBALException extends Exception
} }
/** /**
* @deprecated Passing a PDO instance in connection parameters is deprecated.
*
* @return DBALException * @return DBALException
*/ */
public static function invalidPdoInstance() public static function invalidPdoInstance()
......
...@@ -36,6 +36,8 @@ final class Connection implements ServerInfoAwareConnection ...@@ -36,6 +36,8 @@ final class Connection implements ServerInfoAwareConnection
private $conn = null; private $conn = null;
/** /**
* @internal The connection can be only instantiated by its driver.
*
* @param array<string,mixed> $driverOptions * @param array<string,mixed> $driverOptions
* *
* @throws Exception * @throws Exception
......
...@@ -26,6 +26,8 @@ final class Connection implements ServerInfoAwareConnection ...@@ -26,6 +26,8 @@ final class Connection implements ServerInfoAwareConnection
private $conn; private $conn;
/** /**
* @internal The connection can be only instantiated by its driver.
*
* @param iterable<Initializer> $preInitializers * @param iterable<Initializer> $preInitializers
* @param iterable<Initializer> $postInitializers * @param iterable<Initializer> $postInitializers
* *
......
...@@ -37,6 +37,8 @@ final class Connection implements ConnectionInterface, ServerInfoAwareConnection ...@@ -37,6 +37,8 @@ final class Connection implements ConnectionInterface, ServerInfoAwareConnection
/** /**
* Creates a Connection to an Oracle Database using oci8 extension. * Creates a Connection to an Oracle Database using oci8 extension.
* *
* @internal The connection can be only instantiated by its driver.
*
* @param string $username * @param string $username
* @param string $password * @param string $password
* @param string $db * @param string $db
......
...@@ -19,6 +19,8 @@ final class Connection implements ServerInfoAwareConnection ...@@ -19,6 +19,8 @@ final class Connection implements ServerInfoAwareConnection
private $connection; private $connection;
/** /**
* @internal The connection can be only instantiated by its driver.
*
* @param string $dsn * @param string $dsn
* @param string|null $user * @param string|null $user
* @param string|null $password * @param string|null $password
......
...@@ -31,6 +31,8 @@ final class Connection implements ServerInfoAwareConnection ...@@ -31,6 +31,8 @@ final class Connection implements ServerInfoAwareConnection
protected $lastInsertId; protected $lastInsertId;
/** /**
* @internal The connection can be only instantiated by its driver.
*
* @param string $serverName * @param string $serverName
* @param mixed[] $connectionOptions * @param mixed[] $connectionOptions
* *
......
...@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Driver\SQLSrv; ...@@ -4,6 +4,8 @@ namespace Doctrine\DBAL\Driver\SQLSrv;
/** /**
* Last Id Data Container. * Last Id Data Container.
*
* @internal
*/ */
final class LastInsertId final class LastInsertId
{ {
......
...@@ -20,7 +20,7 @@ interface Statement ...@@ -20,7 +20,7 @@ interface Statement
* this will be a parameter name of the form :name. For a prepared statement * this will be a parameter name of the form :name. For a prepared statement
* using question mark placeholders, this will be the 1-indexed position of the parameter. * using question mark placeholders, this will be the 1-indexed position of the parameter.
* @param mixed $value The value to bind to the parameter. * @param mixed $value The value to bind to the parameter.
* @param int $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType} * @param int $type Explicit data type for the parameter using the {@link ParameterType}
* constants. * constants.
* *
* @return bool TRUE on success or FALSE on failure. * @return bool TRUE on success or FALSE on failure.
...@@ -47,7 +47,7 @@ interface Statement ...@@ -47,7 +47,7 @@ interface Statement
* this will be a parameter name of the form :name. For a prepared statement using * this will be a parameter name of the form :name. For a prepared statement using
* question mark placeholders, this will be the 1-indexed position of the parameter. * question mark placeholders, this will be the 1-indexed position of the parameter.
* @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter. * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
* @param int $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType} * @param int $type Explicit data type for the parameter using the {@link ParameterType}
* constants. * constants.
* @param int|null $length You must specify maxlength when using an OUT bind * @param int|null $length You must specify maxlength when using an OUT bind
* so that PHP allocates enough memory to hold the returned value. * so that PHP allocates enough memory to hold the returned value.
......
...@@ -3153,8 +3153,7 @@ abstract class AbstractPlatform ...@@ -3153,8 +3153,7 @@ abstract class AbstractPlatform
* Whether this platform can emulate schemas. * Whether this platform can emulate schemas.
* *
* Platforms that either support or emulate schemas don't automatically * Platforms that either support or emulate schemas don't automatically
* filter a schema for the namespaced elements in {@link * filter a schema for the namespaced elements in {@link AbstractManager::createSchema()}.
* AbstractManager#createSchema}.
* *
* @return bool * @return bool
*/ */
...@@ -3385,6 +3384,8 @@ abstract class AbstractPlatform ...@@ -3385,6 +3384,8 @@ abstract class AbstractPlatform
* Makes any fixes to a name of a schema element (table, sequence, ...) that are required * Makes any fixes to a name of a schema element (table, sequence, ...) that are required
* by restrictions of the platform, like a maximum length. * by restrictions of the platform, like a maximum length.
* *
* @deprecated
*
* @param string $schemaElementName * @param string $schemaElementName
* *
* @return string * @return string
......
...@@ -584,6 +584,22 @@ END;'; ...@@ -584,6 +584,22 @@ END;';
return $identifier->isQuoted() ? $identifier : new Identifier(strtoupper($name)); return $identifier->isQuoted() ? $identifier : new Identifier(strtoupper($name));
} }
/**
* Adds suffix to identifier,
*
* if the new string exceeds max identifier length,
* keeps $suffix, cuts from $identifier as much as the part exceeding.
*/
private function addSuffix(string $identifier, string $suffix): string
{
$maxPossibleLengthWithoutSuffix = $this->getMaxIdentifierLength() - strlen($suffix);
if (strlen($identifier) > $maxPossibleLengthWithoutSuffix) {
$identifier = substr($identifier, 0, $maxPossibleLengthWithoutSuffix);
}
return $identifier . $suffix;
}
/** /**
* Returns the autoincrement primary key identifier name for the given table identifier. * Returns the autoincrement primary key identifier name for the given table identifier.
* *
...@@ -596,7 +612,7 @@ END;'; ...@@ -596,7 +612,7 @@ END;';
*/ */
private function getAutoincrementIdentifierName(Identifier $table) private function getAutoincrementIdentifierName(Identifier $table)
{ {
$identifierName = $table->getName() . '_AI_PK'; $identifierName = $this->addSuffix($table->getName(), '_AI_PK');
return $table->isQuoted() return $table->isQuoted()
? $this->quoteSingleIdentifier($identifierName) ? $this->quoteSingleIdentifier($identifierName)
...@@ -969,7 +985,7 @@ SQL ...@@ -969,7 +985,7 @@ SQL
$table = new Identifier($tableName); $table = new Identifier($tableName);
// No usage of column name to preserve BC compatibility with <2.5 // No usage of column name to preserve BC compatibility with <2.5
$identitySequenceName = $table->getName() . '_SEQ'; $identitySequenceName = $this->addSuffix($table->getName(), '_SEQ');
if ($table->isQuoted()) { if ($table->isQuoted()) {
$identitySequenceName = '"' . $identitySequenceName . '"'; $identitySequenceName = '"' . $identitySequenceName . '"';
...@@ -1074,6 +1090,8 @@ SQL ...@@ -1074,6 +1090,8 @@ SQL
/** /**
* {@inheritDoc} * {@inheritDoc}
*
* @deprecated
*/ */
public function fixSchemaElementName($schemaElementName) public function fixSchemaElementName($schemaElementName)
{ {
......
...@@ -648,9 +648,8 @@ SQL ...@@ -648,9 +648,8 @@ SQL
* Checks whether a given column diff is a logically unchanged binary type column. * Checks whether a given column diff is a logically unchanged binary type column.
* *
* Used to determine whether a column alteration for a binary type column can be skipped. * Used to determine whether a column alteration for a binary type column can be skipped.
* Doctrine's {@link \Doctrine\DBAL\Types\BinaryType} and {@link \Doctrine\DBAL\Types\BlobType} * Doctrine's {@link BinaryType} and {@link BlobType} are mapped to the same database column type on this platform
* are mapped to the same database column type on this platform as this platform * as this platform does not have a native VARBINARY/BINARY column type. Therefore the comparator
* does not have a native VARBINARY/BINARY column type. Therefore the {@link \Doctrine\DBAL\Schema\Comparator}
* might detect differences for binary type columns which do not have to be propagated * might detect differences for binary type columns which do not have to be propagated
* to database as there actually is no difference at database level. * to database as there actually is no difference at database level.
* *
......
...@@ -268,7 +268,7 @@ class QueryBuilder ...@@ -268,7 +268,7 @@ class QueryBuilder
* *
* @param string|int $key The parameter position or name. * @param string|int $key The parameter position or name.
* @param mixed $value The parameter value. * @param mixed $value The parameter value.
* @param string|int|null $type One of the {@link \Doctrine\DBAL\ParameterType} constants. * @param string|int|null $type One of the {@link ParameterType} constants.
* *
* @return $this This QueryBuilder instance. * @return $this This QueryBuilder instance.
*/ */
......
...@@ -165,7 +165,7 @@ class SQLParserUtils ...@@ -165,7 +165,7 @@ class SQLParserUtils
array_slice($types, 0, $needle), array_slice($types, 0, $needle),
$count > 0 ? $count > 0 ?
// array needles are at {@link \Doctrine\DBAL\ParameterType} constants // array needles are at {@link \Doctrine\DBAL\ParameterType} constants
// + {@link Doctrine\DBAL\Connection::ARRAY_PARAM_OFFSET} // + {@link \Doctrine\DBAL\Connection::ARRAY_PARAM_OFFSET}
array_fill(0, $count, $types[$needle] - Connection::ARRAY_PARAM_OFFSET) : array_fill(0, $count, $types[$needle] - Connection::ARRAY_PARAM_OFFSET) :
[], [],
array_slice($types, $needle + 1) array_slice($types, $needle + 1)
......
...@@ -129,13 +129,13 @@ abstract class Type ...@@ -129,13 +129,13 @@ abstract class Type
private static function createTypeRegistry(): TypeRegistry private static function createTypeRegistry(): TypeRegistry
{ {
$registry = new TypeRegistry(); $instances = [];
foreach (self::BUILTIN_TYPES_MAP as $name => $class) { foreach (self::BUILTIN_TYPES_MAP as $name => $class) {
$registry->register($name, new $class()); $instances[$name] = new $class();
} }
return $registry; return new TypeRegistry($instances);
} }
/** /**
...@@ -199,7 +199,7 @@ abstract class Type ...@@ -199,7 +199,7 @@ abstract class Type
* Gets the (preferred) binding type for values of this type that * Gets the (preferred) binding type for values of this type that
* can be used when binding parameters to prepared statements. * can be used when binding parameters to prepared statements.
* *
* This method should return one of the {@link \Doctrine\DBAL\ParameterType} constants. * This method should return one of the {@link ParameterType} constants.
* *
* @return int * @return int
*/ */
......
...@@ -18,7 +18,15 @@ use function in_array; ...@@ -18,7 +18,15 @@ use function in_array;
final class TypeRegistry final class TypeRegistry
{ {
/** @var array<string, Type> Map of type names and their corresponding flyweight objects. */ /** @var array<string, Type> Map of type names and their corresponding flyweight objects. */
private $instances = []; private $instances;
/**
* @param array<string, Type> $instances
*/
public function __construct(array $instances = [])
{
$this->instances = $instances;
}
/** /**
* Finds a type by the given name. * Finds a type by the given name.
......
...@@ -6,19 +6,11 @@ use Doctrine\DBAL\Driver\Mysqli\Driver; ...@@ -6,19 +6,11 @@ use Doctrine\DBAL\Driver\Mysqli\Driver;
use Doctrine\DBAL\Driver\Mysqli\Exception\HostRequired; use Doctrine\DBAL\Driver\Mysqli\Exception\HostRequired;
use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\FunctionalTestCase;
use function extension_loaded; /**
* @requires extension mysqli
*/
class ConnectionTest extends FunctionalTestCase class ConnectionTest extends FunctionalTestCase
{ {
protected function setUp(): void
{
if (! extension_loaded('mysqli')) {
self::markTestSkipped('mysqli is not installed.');
}
parent::setUp();
}
public function testHostnameIsRequiredForPersistentConnection(): void public function testHostnameIsRequiredForPersistentConnection(): void
{ {
$this->expectException(HostRequired::class); $this->expectException(HostRequired::class);
......
...@@ -10,16 +10,14 @@ use Doctrine\DBAL\Tests\FunctionalTestCase; ...@@ -10,16 +10,14 @@ use Doctrine\DBAL\Tests\FunctionalTestCase;
use ReflectionProperty; use ReflectionProperty;
use function db2_close; use function db2_close;
use function extension_loaded;
/**
* @require extension ibm_db2
*/
class ConnectionTest extends FunctionalTestCase class ConnectionTest extends FunctionalTestCase
{ {
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('ibm_db2')) {
$this->markTestSkipped('ibm_db2 is not installed.');
}
parent::setUp(); parent::setUp();
if ($this->connection->getDriver() instanceof Driver) { if ($this->connection->getDriver() instanceof Driver) {
......
...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver as DriverInterface; ...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\IBMDB2\Driver; use Doctrine\DBAL\Driver\IBMDB2\Driver;
use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest; use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest;
use function extension_loaded; /**
* @requires extension ibm_db2
*/
class DriverTest extends AbstractDriverTest class DriverTest extends AbstractDriverTest
{ {
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('ibm_db2')) {
self::markTestSkipped('ibm_db2 is not installed.');
}
parent::setUp(); parent::setUp();
if ($this->connection->getDriver() instanceof Driver) { if ($this->connection->getDriver() instanceof Driver) {
......
...@@ -8,20 +8,17 @@ use Doctrine\DBAL\Driver\IBMDB2\Driver; ...@@ -8,20 +8,17 @@ use Doctrine\DBAL\Driver\IBMDB2\Driver;
use Doctrine\DBAL\Driver\IBMDB2\Exception\StatementError; use Doctrine\DBAL\Driver\IBMDB2\Exception\StatementError;
use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\FunctionalTestCase;
use function extension_loaded;
use const E_ALL; use const E_ALL;
use const E_NOTICE; use const E_NOTICE;
use const E_WARNING; use const E_WARNING;
/**
* @require extension ibm_db2
*/
class StatementTest extends FunctionalTestCase class StatementTest extends FunctionalTestCase
{ {
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('ibm_db2')) {
self::markTestSkipped('ibm_db2 is not installed.');
}
parent::setUp(); parent::setUp();
if ($this->connection->getDriver() instanceof Driver) { if ($this->connection->getDriver() instanceof Driver) {
......
...@@ -9,18 +9,16 @@ use Doctrine\DBAL\Tests\FunctionalTestCase; ...@@ -9,18 +9,16 @@ use Doctrine\DBAL\Tests\FunctionalTestCase;
use Doctrine\DBAL\Tests\TestUtil; use Doctrine\DBAL\Tests\TestUtil;
use function array_merge; use function array_merge;
use function extension_loaded;
use const MYSQLI_OPT_CONNECT_TIMEOUT; use const MYSQLI_OPT_CONNECT_TIMEOUT;
/**
* @require extension mysqli
*/
class ConnectionTest extends FunctionalTestCase class ConnectionTest extends FunctionalTestCase
{ {
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('mysqli')) {
self::markTestSkipped('mysqli is not installed.');
}
parent::setUp(); parent::setUp();
if ($this->connection->getDriver() instanceof Driver) { if ($this->connection->getDriver() instanceof Driver) {
......
...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver as DriverInterface; ...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\Mysqli\Driver; use Doctrine\DBAL\Driver\Mysqli\Driver;
use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest; use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest;
use function extension_loaded; /**
* @requires extension mysqli
*/
class DriverTest extends AbstractDriverTest class DriverTest extends AbstractDriverTest
{ {
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('mysqli')) {
self::markTestSkipped('mysqli is not installed.');
}
parent::setUp(); parent::setUp();
if ($this->connection->getDriver() instanceof Driver) { if ($this->connection->getDriver() instanceof Driver) {
......
...@@ -7,8 +7,9 @@ use Doctrine\DBAL\Driver\OCI8\Driver; ...@@ -7,8 +7,9 @@ use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\FunctionalTestCase;
use function extension_loaded; /**
* @requires extension oci8
*/
class ConnectionTest extends FunctionalTestCase class ConnectionTest extends FunctionalTestCase
{ {
/** @var Connection */ /** @var Connection */
...@@ -16,10 +17,6 @@ class ConnectionTest extends FunctionalTestCase ...@@ -16,10 +17,6 @@ class ConnectionTest extends FunctionalTestCase
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('oci8')) {
self::markTestSkipped('oci8 is not installed.');
}
parent::setUp(); parent::setUp();
if (! $this->connection->getDriver() instanceof Driver) { if (! $this->connection->getDriver() instanceof Driver) {
......
...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver as DriverInterface; ...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\OCI8\Driver; use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest; use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest;
use function extension_loaded; /**
* @requires extension oci8
*/
class DriverTest extends AbstractDriverTest class DriverTest extends AbstractDriverTest
{ {
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('oci8')) {
self::markTestSkipped('oci8 is not installed.');
}
parent::setUp(); parent::setUp();
if ($this->connection->getDriver() instanceof Driver) { if ($this->connection->getDriver() instanceof Driver) {
......
...@@ -5,16 +5,13 @@ namespace Doctrine\DBAL\Tests\Functional\Driver\OCI8; ...@@ -5,16 +5,13 @@ namespace Doctrine\DBAL\Tests\Functional\Driver\OCI8;
use Doctrine\DBAL\Driver\OCI8\Driver; use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\FunctionalTestCase;
use function extension_loaded; /**
* @requires extension oci8
*/
class StatementTest extends FunctionalTestCase class StatementTest extends FunctionalTestCase
{ {
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('oci8')) {
self::markTestSkipped('oci8 is not installed.');
}
parent::setUp(); parent::setUp();
if ($this->connection->getDriver() instanceof Driver) { if ($this->connection->getDriver() instanceof Driver) {
......
...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver as DriverInterface; ...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDO\MySQL\Driver; use Doctrine\DBAL\Driver\PDO\MySQL\Driver;
use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest; use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest;
use function extension_loaded; /**
* @requires extension pdo_mysql
*/
class DriverTest extends AbstractDriverTest class DriverTest extends AbstractDriverTest
{ {
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('pdo_mysql')) {
self::markTestSkipped('pdo_mysql is not installed.');
}
parent::setUp(); parent::setUp();
if ($this->connection->getDriver() instanceof Driver) { if ($this->connection->getDriver() instanceof Driver) {
......
...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver as DriverInterface; ...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDO\OCI\Driver; use Doctrine\DBAL\Driver\PDO\OCI\Driver;
use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest; use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest;
use function extension_loaded; /**
* @requires extension pdo_oci
*/
class DriverTest extends AbstractDriverTest class DriverTest extends AbstractDriverTest
{ {
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('PDO_OCI')) {
self::markTestSkipped('PDO_OCI is not installed.');
}
parent::setUp(); parent::setUp();
if ($this->connection->getDriver() instanceof Driver) { if ($this->connection->getDriver() instanceof Driver) {
......
...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver\PDO\PgSQL\Driver; ...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver\PDO\PgSQL\Driver;
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\FunctionalTestCase;
use function extension_loaded; /**
* @requires extension pdo_pgsql
*/
class ConnectionTest extends FunctionalTestCase class ConnectionTest extends FunctionalTestCase
{ {
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('pdo_pgsql')) {
self::markTestSkipped('pdo_pgsql is not loaded.');
}
parent::setUp(); parent::setUp();
if ($this->connection->getDriver() instanceof Driver) { if ($this->connection->getDriver() instanceof Driver) {
......
...@@ -9,18 +9,16 @@ use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest; ...@@ -9,18 +9,16 @@ use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest;
use Doctrine\DBAL\Tests\TestUtil; use Doctrine\DBAL\Tests\TestUtil;
use function array_key_exists; use function array_key_exists;
use function extension_loaded;
use function microtime; use function microtime;
use function sprintf; use function sprintf;
/**
* @requires extension pdo_pgsql
*/
class DriverTest extends AbstractDriverTest class DriverTest extends AbstractDriverTest
{ {
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('pdo_pgsql')) {
self::markTestSkipped('pdo_pgsql is not installed.');
}
parent::setUp(); parent::setUp();
if ($this->connection->getDriver() instanceof Driver) { if ($this->connection->getDriver() instanceof Driver) {
......
...@@ -10,16 +10,14 @@ use Doctrine\DBAL\Tests\TestUtil; ...@@ -10,16 +10,14 @@ use Doctrine\DBAL\Tests\TestUtil;
use PDO; use PDO;
use function array_merge; use function array_merge;
use function extension_loaded;
/**
* @requires extension pdo_sqlsrv
*/
class DriverTest extends AbstractDriverTest class DriverTest extends AbstractDriverTest
{ {
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('pdo_sqlsrv')) {
self::markTestSkipped('pdo_sqlsrv is not installed.');
}
parent::setUp(); parent::setUp();
if ($this->connection->getDriver() instanceof Driver) { if ($this->connection->getDriver() instanceof Driver) {
......
...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver as DriverInterface; ...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDO\SQLite\Driver; use Doctrine\DBAL\Driver\PDO\SQLite\Driver;
use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest; use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest;
use function extension_loaded; /**
* @requires extension pdo_sqlite
*/
class DriverTest extends AbstractDriverTest class DriverTest extends AbstractDriverTest
{ {
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('pdo_sqlite')) {
self::markTestSkipped('pdo_sqlite is not installed.');
}
parent::setUp(); parent::setUp();
if ($this->connection->getDriver() instanceof Driver) { if ($this->connection->getDriver() instanceof Driver) {
......
...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver as DriverInterface; ...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\SQLSrv\Driver; use Doctrine\DBAL\Driver\SQLSrv\Driver;
use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest; use Doctrine\DBAL\Tests\Functional\Driver\AbstractDriverTest;
use function extension_loaded; /**
* @requires extension sqlsrv
*/
class DriverTest extends AbstractDriverTest class DriverTest extends AbstractDriverTest
{ {
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('sqlsrv')) {
self::markTestSkipped('sqlsrv is not installed.');
}
parent::setUp(); parent::setUp();
if ($this->connection->getDriver() instanceof Driver) { if ($this->connection->getDriver() instanceof Driver) {
......
...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver\Exception; ...@@ -6,16 +6,13 @@ use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\SQLSrv\Driver; use Doctrine\DBAL\Driver\SQLSrv\Driver;
use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\FunctionalTestCase;
use function extension_loaded; /**
* @requires extension sqlsrv
*/
class StatementTest extends FunctionalTestCase class StatementTest extends FunctionalTestCase
{ {
protected function setUp(): void protected function setUp(): void
{ {
if (! extension_loaded('sqlsrv')) {
self::markTestSkipped('sqlsrv is not installed.');
}
parent::setUp(); parent::setUp();
if ($this->connection->getDriver() instanceof Driver) { if ($this->connection->getDriver() instanceof Driver) {
......
<?php
namespace Doctrine\DBAL\Tests\Functional\Platform;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use function str_repeat;
/**
* This class holds tests that make sure generated SQL statements respect to platform restrictions
* like maximum element name length
*/
class PlatformRestrictionsTest extends FunctionalTestCase
{
/**
* Tests element names that are at the boundary of the identifier length limit.
* Ensures generated auto-increment identifier name respects to platform restrictions.
*/
public function testMaxIdentifierLengthLimitWithAutoIncrement(): void
{
$platform = $this->connection->getDatabasePlatform();
$tableName = str_repeat('x', $platform->getMaxIdentifierLength());
$columnName = str_repeat('y', $platform->getMaxIdentifierLength());
$table = new Table($tableName);
$table->addColumn($columnName, 'integer', ['autoincrement' => true]);
$table->setPrimaryKey([$columnName]);
$this->connection->getSchemaManager()->dropAndCreateTable($table);
$createdTable = $this->connection->getSchemaManager()->listTableDetails($tableName);
$this->assertTrue($createdTable->hasColumn($columnName));
$this->assertTrue($createdTable->hasPrimaryKey());
}
}
...@@ -9,12 +9,8 @@ use Doctrine\DBAL\Schema\Table; ...@@ -9,12 +9,8 @@ use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\BlobType; use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
use SQLite3;
use function array_map;
use function dirname; use function dirname;
use function extension_loaded;
use function version_compare;
class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
{ {
...@@ -157,34 +153,6 @@ EOS ...@@ -157,34 +153,6 @@ EOS
self::assertFalse($table->getColumn('column_binary')->getFixed()); self::assertFalse($table->getColumn('column_binary')->getFixed());
} }
public function testNonDefaultPKOrder(): void
{
if (! extension_loaded('sqlite3')) {
self::markTestSkipped('This test requires the SQLite3 extension.');
}
$version = SQLite3::version();
if (version_compare($version['versionString'], '3.7.16', '<')) {
self::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 * @group DBAL-1779
*/ */
......
...@@ -31,9 +31,10 @@ class TypeRegistryTest extends TestCase ...@@ -31,9 +31,10 @@ class TypeRegistryTest extends TestCase
$this->testType = new BlobType(); $this->testType = new BlobType();
$this->otherTestType = new BinaryType(); $this->otherTestType = new BinaryType();
$this->registry = new TypeRegistry(); $this->registry = new TypeRegistry([
$this->registry->register(self::TEST_TYPE_NAME, $this->testType); self::TEST_TYPE_NAME => $this->testType,
$this->registry->register(self::OTHER_TEST_TYPE_NAME, $this->otherTestType); self::OTHER_TEST_TYPE_NAME => $this->otherTestType,
]);
} }
public function testGet(): void public function testGet(): void
......
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