diff --git a/.travis.yml b/.travis.yml
index 9ca1ebe5509..0162cd7808d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -442,7 +442,7 @@ jobs:
git fetch origin $TRAVIS_BRANCH;
fi
- git merge-base origin/$TRAVIS_BRANCH $TRAVIS_PULL_REQUEST_SHA || git fetch origin +refs/pull/$TRAVIS_PULL_REQUEST/merge --unshallow
- - wget https://github.com/diff-sniffer/git/releases/download/0.1.0/git-phpcs.phar
+ - wget https://github.com/diff-sniffer/git/releases/download/0.2.0/git-phpcs.phar
- php git-phpcs.phar origin/$TRAVIS_BRANCH...$TRAVIS_PULL_REQUEST_SHA
- stage: Coding standard
diff --git a/composer.json b/composer.json
index ab00c8cddf4..c0a35f4d9cb 100644
--- a/composer.json
+++ b/composer.json
@@ -27,7 +27,7 @@
"doctrine/event-manager": "^1.0"
},
"require-dev": {
- "doctrine/coding-standard": "^4.0",
+ "doctrine/coding-standard": "^5.0",
"jetbrains/phpstorm-stubs": "^2018.1.2",
"phpstan/phpstan": "^0.10.1",
"phpunit/phpunit": "^7.1.2",
diff --git a/composer.lock b/composer.lock
index 8eb6bc50ee9..0ac48fe1249 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "c1b5ddb5a1259c7ac793dd9c6e6d657a",
+ "content-hash": "a6e554864457c4bf9babe37f88174255",
"packages": [
{
"name": "doctrine/cache",
@@ -270,28 +270,28 @@
},
{
"name": "doctrine/coding-standard",
- "version": "4.0.0",
+ "version": "5.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/coding-standard.git",
- "reference": "0469c18a1a4724c278f2879c0dd7b1fa860b52de"
+ "reference": "bb8de042a25c4fb59a2c55c350dc55cc00227a8c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/0469c18a1a4724c278f2879c0dd7b1fa860b52de",
- "reference": "0469c18a1a4724c278f2879c0dd7b1fa860b52de",
+ "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/bb8de042a25c4fb59a2c55c350dc55cc00227a8c",
+ "reference": "bb8de042a25c4fb59a2c55c350dc55cc00227a8c",
"shasum": ""
},
"require": {
- "dealerdirect/phpcodesniffer-composer-installer": "^0.4.2",
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
"php": "^7.1",
- "slevomat/coding-standard": "^4.5.0",
- "squizlabs/php_codesniffer": "^3.2.3"
+ "slevomat/coding-standard": "^4.8.0",
+ "squizlabs/php_codesniffer": "^3.3.2"
},
"type": "phpcodesniffer-standard",
"extra": {
"branch-alias": {
- "dev-master": "3.0.x-dev"
+ "dev-master": "5.0.x-dev"
}
},
"autoload": {
@@ -313,18 +313,21 @@
"email": "st.mueller@dzh-online.de"
}
],
- "description": "Doctrine Coding Standard",
- "homepage": "http://www.doctrine-project.org",
+ "description": "The Doctrine Coding Standard is a set of PHPCS rules applied to all Doctrine projects.",
+ "homepage": "https://www.doctrine-project.org/projects/coding-standard.html",
"keywords": [
+ "checks",
"code",
"coding",
"cs",
"doctrine",
+ "rules",
"sniffer",
+ "sniffs",
"standard",
"style"
],
- "time": "2018-03-03T23:49:15+00:00"
+ "time": "2018-09-24T19:08:56+00:00"
},
{
"name": "doctrine/instantiator",
@@ -2519,30 +2522,29 @@
},
{
"name": "slevomat/coding-standard",
- "version": "4.5.2",
+ "version": "4.8.3",
"source": {
"type": "git",
"url": "https://github.com/slevomat/coding-standard.git",
- "reference": "1e609159241fa90d5a429f185b2ea9b881340a7c"
+ "reference": "32e1ca205fc34920f323582ed29c0602e3897ae3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/1e609159241fa90d5a429f185b2ea9b881340a7c",
- "reference": "1e609159241fa90d5a429f185b2ea9b881340a7c",
+ "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/32e1ca205fc34920f323582ed29c0602e3897ae3",
+ "reference": "32e1ca205fc34920f323582ed29c0602e3897ae3",
"shasum": ""
},
"require": {
"php": "^7.1",
- "squizlabs/php_codesniffer": "^3.2.3"
+ "squizlabs/php_codesniffer": "^3.3.0"
},
"require-dev": {
"jakub-onderka/php-parallel-lint": "1.0.0",
- "phing/phing": "2.16",
+ "phing/phing": "2.16.1",
"phpstan/phpstan": "0.9.2",
"phpstan/phpstan-phpunit": "0.9.4",
"phpstan/phpstan-strict-rules": "0.9",
- "phpunit/php-code-coverage": "6.0.1",
- "phpunit/phpunit": "7.0.2"
+ "phpunit/phpunit": "7.3.5"
},
"type": "phpcodesniffer-standard",
"autoload": {
@@ -2555,20 +2557,20 @@
"MIT"
],
"description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.",
- "time": "2018-03-08T08:14:33+00:00"
+ "time": "2018-09-25T21:21:11+00:00"
},
{
"name": "squizlabs/php_codesniffer",
- "version": "3.2.3",
+ "version": "3.3.2",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
- "reference": "4842476c434e375f9d3182ff7b89059583aa8b27"
+ "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/4842476c434e375f9d3182ff7b89059583aa8b27",
- "reference": "4842476c434e375f9d3182ff7b89059583aa8b27",
+ "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6ad28354c04b364c3c71a34e4a18b629cc3b231e",
+ "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e",
"shasum": ""
},
"require": {
@@ -2606,7 +2608,7 @@
"phpcs",
"standards"
],
- "time": "2018-02-20T21:35:23+00:00"
+ "time": "2018-09-23T23:08:17+00:00"
},
{
"name": "symfony/console",
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index 7385edd063d..2367364b58f 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -35,4 +35,9 @@
tests/Doctrine/Tests/DBAL/Tools/TestAsset/*
+
+
+
+ tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
+
diff --git a/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php b/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php
index 5bc77c911c3..1d500046260 100644
--- a/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php
+++ b/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php
@@ -12,36 +12,26 @@ class QueryCacheProfileTest extends DbalTestCase
private const LIFETIME = 3600;
private const CACHE_KEY = 'user_specified_cache_key';
- /**
- * @var QueryCacheProfile
- */
+ /** @var QueryCacheProfile */
private $queryCacheProfile;
- /**
- * @var string
- */
+ /** @var string */
private $query = 'SELECT * FROM foo WHERE bar = ?';
- /**
- * @var int[]
- */
+ /** @var int[] */
private $params = [666];
- /**
- * @var string[]
- */
+ /** @var string[] */
private $types = [ParameterType::INTEGER];
- /**
- * @var string[]
- */
+ /** @var string[] */
private $connectionParams = [
- 'dbname' => 'database_name',
- 'user' => 'database_user',
- 'password' => 'database_password',
- 'host' => 'database_host',
- 'driver' => 'database_driver',
- ];
+ 'dbname' => 'database_name',
+ 'user' => 'database_user',
+ 'password' => 'database_password',
+ 'host' => 'database_host',
+ 'driver' => 'database_driver',
+ ];
protected function setUp()
{
@@ -50,7 +40,7 @@ protected function setUp()
public function testShouldUseTheGivenCacheKeyIfPresent()
{
- list($cacheKey) = $this->queryCacheProfile->generateCacheKeys(
+ [$cacheKey] = $this->queryCacheProfile->generateCacheKeys(
$this->query,
$this->params,
$this->types,
@@ -64,7 +54,7 @@ public function testShouldGenerateAnAutomaticKeyIfNoKeyHasBeenGiven()
{
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);
- list($cacheKey) = $this->queryCacheProfile->generateCacheKeys(
+ [$cacheKey] = $this->queryCacheProfile->generateCacheKeys(
$this->query,
$this->params,
$this->types,
@@ -84,7 +74,7 @@ public function testShouldGenerateDifferentKeysForSameQueryAndParamsAndDifferent
{
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);
- list($firstCacheKey) = $this->queryCacheProfile->generateCacheKeys(
+ [$firstCacheKey] = $this->queryCacheProfile->generateCacheKeys(
$this->query,
$this->params,
$this->types,
@@ -93,7 +83,7 @@ public function testShouldGenerateDifferentKeysForSameQueryAndParamsAndDifferent
$this->connectionParams['host'] = 'a_different_host';
- list($secondCacheKey) = $this->queryCacheProfile->generateCacheKeys(
+ [$secondCacheKey] = $this->queryCacheProfile->generateCacheKeys(
$this->query,
$this->params,
$this->types,
@@ -107,7 +97,7 @@ public function testConnectionParamsShouldBeHashed()
{
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);
- list($cacheKey, $queryString) = $this->queryCacheProfile->generateCacheKeys(
+ [$cacheKey, $queryString] = $this->queryCacheProfile->generateCacheKeys(
$this->query,
$this->params,
$this->types,
@@ -128,14 +118,14 @@ public function testShouldGenerateSameKeysIfNoneOfTheParamsChanges()
{
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);
- list($firstCacheKey) = $this->queryCacheProfile->generateCacheKeys(
+ [$firstCacheKey] = $this->queryCacheProfile->generateCacheKeys(
$this->query,
$this->params,
$this->types,
$this->connectionParams
);
- list($secondCacheKey) = $this->queryCacheProfile->generateCacheKeys(
+ [$secondCacheKey] = $this->queryCacheProfile->generateCacheKeys(
$this->query,
$this->params,
$this->types,
diff --git a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php
index 4379b3b35a9..8310ea15c66 100644
--- a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php
+++ b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\Tests\DBAL;
@@ -24,15 +7,13 @@
/**
* Unit tests for the configuration container.
- *
- * @author Steve Müller
*/
class ConfigurationTest extends DbalTestCase
{
/**
* The configuration container instance under test.
*
- * @var \Doctrine\DBAL\Configuration
+ * @var Configuration
*/
protected $config;
diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php
index 819dd71f487..52e95cfc528 100644
--- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php
@@ -12,44 +12,51 @@
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\Connection as DriverConnection;
+use Doctrine\DBAL\Driver\Statement;
+use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use Doctrine\DBAL\FetchMode;
+use Doctrine\DBAL\Logging\DebugStack;
+use Doctrine\DBAL\Logging\EchoSQLLogger;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\Tests\DbalTestCase;
use Doctrine\Tests\Mocks\DriverMock;
+use Doctrine\Tests\Mocks\DriverStatementMock;
+use Doctrine\Tests\Mocks\ServerInfoAwareConnectionMock;
use Doctrine\Tests\Mocks\VersionAwarePlatformDriverMock;
+use Exception;
+use PHPUnit_Framework_MockObject_MockObject;
+use ReflectionObject;
+use stdClass;
use function call_user_func_array;
/**
* @requires extension pdo_mysql
*/
-class ConnectionTest extends \Doctrine\Tests\DbalTestCase
+class ConnectionTest extends DbalTestCase
{
- /**
- * @var \Doctrine\DBAL\Connection
- */
- protected $_conn = null;
+ /** @var Connection */
+ private $connection;
- /**
- * @var string[]
- */
- protected $params = array(
+ /** @var string[] */
+ protected $params = [
'driver' => 'pdo_mysql',
'host' => 'localhost',
'user' => 'root',
'password' => 'password',
- 'port' => '1234'
- );
+ 'port' => '1234',
+ ];
protected function setUp()
{
- $this->_conn = \Doctrine\DBAL\DriverManager::getConnection($this->params);
+ $this->connection = DriverManager::getConnection($this->params);
}
public function getExecuteUpdateMockConnection()
{
- $driverMock = $this->createMock(\Doctrine\DBAL\Driver::class);
+ $driverMock = $this->createMock(Driver::class);
$driverMock->expects($this->any())
->method('connect')
@@ -57,101 +64,99 @@ public function getExecuteUpdateMockConnection()
$this->createMock(DriverConnection::class)
));
- $conn = $this->getMockBuilder(Connection::class)
+ return $this->getMockBuilder(Connection::class)
->setMethods(['executeUpdate'])
->setConstructorArgs([['platform' => new Mocks\MockPlatform()], $driverMock])
->getMock();
-
- return $conn;
}
public function testIsConnected()
{
- self::assertFalse($this->_conn->isConnected());
+ self::assertFalse($this->connection->isConnected());
}
public function testNoTransactionActiveByDefault()
{
- self::assertFalse($this->_conn->isTransactionActive());
+ self::assertFalse($this->connection->isTransactionActive());
}
- public function testCommitWithNoActiveTransaction_ThrowsException()
+ public function testCommitWithNoActiveTransactionThrowsException()
{
$this->expectException(ConnectionException::class);
- $this->_conn->commit();
+ $this->connection->commit();
}
- public function testRollbackWithNoActiveTransaction_ThrowsException()
+ public function testRollbackWithNoActiveTransactionThrowsException()
{
$this->expectException(ConnectionException::class);
- $this->_conn->rollBack();
+ $this->connection->rollBack();
}
- public function testSetRollbackOnlyNoActiveTransaction_ThrowsException()
+ public function testSetRollbackOnlyNoActiveTransactionThrowsException()
{
$this->expectException(ConnectionException::class);
- $this->_conn->setRollbackOnly();
+ $this->connection->setRollbackOnly();
}
- public function testIsRollbackOnlyNoActiveTransaction_ThrowsException()
+ public function testIsRollbackOnlyNoActiveTransactionThrowsException()
{
$this->expectException(ConnectionException::class);
- $this->_conn->isRollbackOnly();
+ $this->connection->isRollbackOnly();
}
public function testGetConfiguration()
{
- $config = $this->_conn->getConfiguration();
+ $config = $this->connection->getConfiguration();
- self::assertInstanceOf('Doctrine\DBAL\Configuration', $config);
+ self::assertInstanceOf(Configuration::class, $config);
}
public function testGetHost()
{
- self::assertEquals('localhost', $this->_conn->getHost());
+ self::assertEquals('localhost', $this->connection->getHost());
}
public function testGetPort()
{
- self::assertEquals('1234', $this->_conn->getPort());
+ self::assertEquals('1234', $this->connection->getPort());
}
public function testGetUsername()
{
- self::assertEquals('root', $this->_conn->getUsername());
+ self::assertEquals('root', $this->connection->getUsername());
}
public function testGetPassword()
{
- self::assertEquals('password', $this->_conn->getPassword());
+ self::assertEquals('password', $this->connection->getPassword());
}
public function testGetDriver()
{
- self::assertInstanceOf('Doctrine\DBAL\Driver\PDOMySql\Driver', $this->_conn->getDriver());
+ self::assertInstanceOf(\Doctrine\DBAL\Driver\PDOMySql\Driver::class, $this->connection->getDriver());
}
public function testGetEventManager()
{
- self::assertInstanceOf('Doctrine\Common\EventManager', $this->_conn->getEventManager());
+ self::assertInstanceOf(EventManager::class, $this->connection->getEventManager());
}
public function testConnectDispatchEvent()
{
$listenerMock = $this->getMockBuilder('ConnectDispatchEventListener')
- ->setMethods(array('postConnect'))
+ ->setMethods(['postConnect'])
->getMock();
$listenerMock->expects($this->once())->method('postConnect');
$eventManager = new EventManager();
- $eventManager->addEventListener(array(Events::postConnect), $listenerMock);
+ $eventManager->addEventListener([Events::postConnect], $listenerMock);
- $driverMock = $this->createMock('Doctrine\DBAL\Driver');
- $driverMock->expects(($this->at(0)))
+ $driverMock = $this->createMock(Driver::class);
+ $driverMock->expects($this->at(0))
->method('connect');
$platform = new Mocks\MockPlatform();
- $conn = new Connection(array('platform' => $platform), $driverMock, new Configuration(), $eventManager);
+ $conn = new Connection(['platform' => $platform], $driverMock, new Configuration(), $eventManager);
$conn->connect();
}
@@ -159,7 +164,7 @@ public function testEventManagerPassedToPlatform()
{
$driverMock = new DriverMock();
$connection = new Connection($this->params, $driverMock);
- self::assertInstanceOf('Doctrine\Common\EventManager', $connection->getDatabasePlatform()->getEventManager());
+ self::assertInstanceOf(EventManager::class, $connection->getDatabasePlatform()->getEventManager());
self::assertSame($connection->getEventManager(), $connection->getDatabasePlatform()->getEventManager());
}
@@ -173,23 +178,23 @@ public function testDriverExceptionIsWrapped($method)
$this->expectException(DBALException::class);
$this->expectExceptionMessage("An exception occurred while executing 'MUUHAAAAHAAAA':\n\nSQLSTATE[HY000]: General error: 1 near \"MUUHAAAAHAAAA\"");
- $con = \Doctrine\DBAL\DriverManager::getConnection(array(
+ $connection = DriverManager::getConnection([
'driver' => 'pdo_sqlite',
'memory' => true,
- ));
+ ]);
- $con->$method('MUUHAAAAHAAAA');
+ $connection->$method('MUUHAAAAHAAAA');
}
public function getQueryMethods()
{
- return array(
- array('exec'),
- array('query'),
- array('executeQuery'),
- array('executeUpdate'),
- array('prepare'),
- );
+ return [
+ ['exec'],
+ ['query'],
+ ['executeQuery'],
+ ['executeUpdate'],
+ ['prepare'],
+ ];
}
/**
@@ -199,9 +204,9 @@ public function getQueryMethods()
*/
public function testEchoSQLLogger()
{
- $logger = new \Doctrine\DBAL\Logging\EchoSQLLogger();
- $this->_conn->getConfiguration()->setSQLLogger($logger);
- self::assertSame($logger, $this->_conn->getConfiguration()->getSQLLogger());
+ $logger = new EchoSQLLogger();
+ $this->connection->getConfiguration()->setSQLLogger($logger);
+ self::assertSame($logger, $this->connection->getConfiguration()->getSQLLogger());
}
/**
@@ -211,9 +216,9 @@ public function testEchoSQLLogger()
*/
public function testDebugSQLStack()
{
- $logger = new \Doctrine\DBAL\Logging\DebugStack();
- $this->_conn->getConfiguration()->setSQLLogger($logger);
- self::assertSame($logger, $this->_conn->getConfiguration()->getSQLLogger());
+ $logger = new DebugStack();
+ $this->connection->getConfiguration()->setSQLLogger($logger);
+ self::assertSame($logger, $this->connection->getConfiguration()->getSQLLogger());
}
/**
@@ -221,7 +226,7 @@ public function testDebugSQLStack()
*/
public function testIsAutoCommit()
{
- self::assertTrue($this->_conn->isAutoCommit());
+ self::assertTrue($this->connection->isAutoCommit());
}
/**
@@ -229,10 +234,10 @@ public function testIsAutoCommit()
*/
public function testSetAutoCommit()
{
- $this->_conn->setAutoCommit(false);
- self::assertFalse($this->_conn->isAutoCommit());
- $this->_conn->setAutoCommit(0);
- self::assertFalse($this->_conn->isAutoCommit());
+ $this->connection->setAutoCommit(false);
+ self::assertFalse($this->connection->isAutoCommit());
+ $this->connection->setAutoCommit(0);
+ self::assertFalse($this->connection->isAutoCommit());
}
/**
@@ -240,13 +245,13 @@ public function testSetAutoCommit()
*/
public function testConnectStartsTransactionInNoAutoCommitMode()
{
- $driverMock = $this->createMock('Doctrine\DBAL\Driver');
+ $driverMock = $this->createMock(Driver::class);
$driverMock->expects($this->any())
->method('connect')
->will($this->returnValue(
$this->createMock(DriverConnection::class)
));
- $conn = new Connection(array('platform' => new Mocks\MockPlatform()), $driverMock);
+ $conn = new Connection(['platform' => new Mocks\MockPlatform()], $driverMock);
$conn->setAutoCommit(false);
@@ -262,13 +267,13 @@ public function testConnectStartsTransactionInNoAutoCommitMode()
*/
public function testCommitStartsTransactionInNoAutoCommitMode()
{
- $driverMock = $this->createMock('Doctrine\DBAL\Driver');
+ $driverMock = $this->createMock(Driver::class);
$driverMock->expects($this->any())
->method('connect')
->will($this->returnValue(
$this->createMock(DriverConnection::class)
));
- $conn = new Connection(array('platform' => new Mocks\MockPlatform()), $driverMock);
+ $conn = new Connection(['platform' => new Mocks\MockPlatform()], $driverMock);
$conn->setAutoCommit(false);
$conn->connect();
@@ -282,13 +287,13 @@ public function testCommitStartsTransactionInNoAutoCommitMode()
*/
public function testRollBackStartsTransactionInNoAutoCommitMode()
{
- $driverMock = $this->createMock('Doctrine\DBAL\Driver');
+ $driverMock = $this->createMock(Driver::class);
$driverMock->expects($this->any())
->method('connect')
->will($this->returnValue(
$this->createMock(DriverConnection::class)
));
- $conn = new Connection(array('platform' => new Mocks\MockPlatform()), $driverMock);
+ $conn = new Connection(['platform' => new Mocks\MockPlatform()], $driverMock);
$conn->setAutoCommit(false);
$conn->connect();
@@ -302,13 +307,13 @@ public function testRollBackStartsTransactionInNoAutoCommitMode()
*/
public function testSwitchingAutoCommitModeCommitsAllCurrentTransactions()
{
- $driverMock = $this->createMock('Doctrine\DBAL\Driver');
+ $driverMock = $this->createMock(Driver::class);
$driverMock->expects($this->any())
->method('connect')
->will($this->returnValue(
$this->createMock(DriverConnection::class)
));
- $conn = new Connection(array('platform' => new Mocks\MockPlatform()), $driverMock);
+ $conn = new Connection(['platform' => new Mocks\MockPlatform()], $driverMock);
$conn->connect();
$conn->beginTransaction();
@@ -332,7 +337,7 @@ public function testEmptyInsert()
->method('executeUpdate')
->with('INSERT INTO footable () VALUES ()');
- $conn->insert('footable', array());
+ $conn->insert('footable', []);
}
/**
@@ -475,12 +480,8 @@ public function testDeleteWithIsNull()
->method('executeUpdate')
->with(
'DELETE FROM TestTable WHERE id IS NULL AND name = ?',
- [
- 'foo',
- ],
- [
- 'string',
- ]
+ ['foo'],
+ ['string']
);
$conn->delete(
@@ -503,7 +504,7 @@ public function testFetchAssoc()
$types = [ParameterType::INTEGER];
$result = [];
- $driverMock = $this->createMock('Doctrine\DBAL\Driver');
+ $driverMock = $this->createMock(Driver::class);
$driverMock->expects($this->any())
->method('connect')
@@ -511,17 +512,17 @@ public function testFetchAssoc()
$this->createMock(DriverConnection::class)
));
- $driverStatementMock = $this->createMock('Doctrine\Tests\Mocks\DriverStatementMock');
+ $driverStatementMock = $this->createMock(DriverStatementMock::class);
$driverStatementMock->expects($this->once())
->method('fetch')
->with(FetchMode::ASSOCIATIVE)
->will($this->returnValue($result));
- /** @var \PHPUnit_Framework_MockObject_MockObject|\Doctrine\DBAL\Connection $conn */
- $conn = $this->getMockBuilder('Doctrine\DBAL\Connection')
- ->setMethods(array('executeQuery'))
- ->setConstructorArgs(array(array('platform' => new Mocks\MockPlatform()), $driverMock))
+ /** @var PHPUnit_Framework_MockObject_MockObject|Connection $conn */
+ $conn = $this->getMockBuilder(Connection::class)
+ ->setMethods(['executeQuery'])
+ ->setConstructorArgs([['platform' => new Mocks\MockPlatform()], $driverMock])
->getMock();
$conn->expects($this->once())
@@ -539,7 +540,7 @@ public function testFetchArray()
$types = [ParameterType::INTEGER];
$result = [];
- $driverMock = $this->createMock('Doctrine\DBAL\Driver');
+ $driverMock = $this->createMock(Driver::class);
$driverMock->expects($this->any())
->method('connect')
@@ -547,17 +548,17 @@ public function testFetchArray()
$this->createMock(DriverConnection::class)
));
- $driverStatementMock = $this->createMock('Doctrine\Tests\Mocks\DriverStatementMock');
+ $driverStatementMock = $this->createMock(DriverStatementMock::class);
$driverStatementMock->expects($this->once())
->method('fetch')
->with(FetchMode::NUMERIC)
->will($this->returnValue($result));
- /** @var \PHPUnit_Framework_MockObject_MockObject|\Doctrine\DBAL\Connection $conn */
- $conn = $this->getMockBuilder('Doctrine\DBAL\Connection')
- ->setMethods(array('executeQuery'))
- ->setConstructorArgs(array(array('platform' => new Mocks\MockPlatform()), $driverMock))
+ /** @var PHPUnit_Framework_MockObject_MockObject|Connection $conn */
+ $conn = $this->getMockBuilder(Connection::class)
+ ->setMethods(['executeQuery'])
+ ->setConstructorArgs([['platform' => new Mocks\MockPlatform()], $driverMock])
->getMock();
$conn->expects($this->once())
@@ -576,7 +577,7 @@ public function testFetchColumn()
$column = 0;
$result = [];
- $driverMock = $this->createMock('Doctrine\DBAL\Driver');
+ $driverMock = $this->createMock(Driver::class);
$driverMock->expects($this->any())
->method('connect')
@@ -584,17 +585,17 @@ public function testFetchColumn()
$this->createMock(DriverConnection::class)
));
- $driverStatementMock = $this->createMock('Doctrine\Tests\Mocks\DriverStatementMock');
+ $driverStatementMock = $this->createMock(DriverStatementMock::class);
$driverStatementMock->expects($this->once())
->method('fetchColumn')
->with($column)
->will($this->returnValue($result));
- /** @var \PHPUnit_Framework_MockObject_MockObject|\Doctrine\DBAL\Connection $conn */
- $conn = $this->getMockBuilder('Doctrine\DBAL\Connection')
- ->setMethods(array('executeQuery'))
- ->setConstructorArgs(array(array('platform' => new Mocks\MockPlatform()), $driverMock))
+ /** @var PHPUnit_Framework_MockObject_MockObject|Connection $conn */
+ $conn = $this->getMockBuilder(Connection::class)
+ ->setMethods(['executeQuery'])
+ ->setConstructorArgs([['platform' => new Mocks\MockPlatform()], $driverMock])
->getMock();
$conn->expects($this->once())
@@ -608,16 +609,16 @@ public function testFetchColumn()
public function testConnectionIsClosedButNotUnset()
{
// mock Connection, and make connect() purposefully do nothing
- $connection = $this->getMockBuilder('Doctrine\DBAL\Connection')
+ $connection = $this->getMockBuilder(Connection::class)
->disableOriginalConstructor()
- ->setMethods(array('connect'))
+ ->setMethods(['connect'])
->getMock();
// artificially set the wrapped connection to non-null
- $reflection = new \ReflectionObject($connection);
+ $reflection = new ReflectionObject($connection);
$connProperty = $reflection->getProperty('_conn');
$connProperty->setAccessible(true);
- $connProperty->setValue($connection, new \stdClass);
+ $connProperty->setValue($connection, new stdClass());
// close the connection (should nullify the wrapped connection)
$connection->close();
@@ -635,7 +636,7 @@ public function testFetchAll()
$types = [ParameterType::INTEGER];
$result = [];
- $driverMock = $this->createMock('Doctrine\DBAL\Driver');
+ $driverMock = $this->createMock(Driver::class);
$driverMock->expects($this->any())
->method('connect')
@@ -643,16 +644,16 @@ public function testFetchAll()
$this->createMock(DriverConnection::class)
));
- $driverStatementMock = $this->createMock('Doctrine\Tests\Mocks\DriverStatementMock');
+ $driverStatementMock = $this->createMock(DriverStatementMock::class);
$driverStatementMock->expects($this->once())
->method('fetchAll')
->will($this->returnValue($result));
- /** @var \PHPUnit_Framework_MockObject_MockObject|\Doctrine\DBAL\Connection $conn */
- $conn = $this->getMockBuilder('Doctrine\DBAL\Connection')
- ->setMethods(array('executeQuery'))
- ->setConstructorArgs(array(array('platform' => new Mocks\MockPlatform()), $driverMock))
+ /** @var PHPUnit_Framework_MockObject_MockObject|Connection $conn */
+ $conn = $this->getMockBuilder(Connection::class)
+ ->setMethods(['executeQuery'])
+ ->setConstructorArgs([['platform' => new Mocks\MockPlatform()], $driverMock])
->getMock();
$conn->expects($this->once())
@@ -665,51 +666,51 @@ public function testFetchAll()
public function testConnectionDoesNotMaintainTwoReferencesToExternalPDO()
{
- $params['pdo'] = new \stdClass();
+ $params['pdo'] = new stdClass();
- $driverMock = $this->createMock('Doctrine\DBAL\Driver');
+ $driverMock = $this->createMock(Driver::class);
$conn = new Connection($params, $driverMock);
- self::assertArrayNotHasKey('pdo', $conn->getParams(), "Connection is maintaining additional reference to the PDO connection");
+ self::assertArrayNotHasKey('pdo', $conn->getParams(), 'Connection is maintaining additional reference to the PDO connection');
}
public function testPassingExternalPDOMeansConnectionIsConnected()
{
- $params['pdo'] = new \stdClass();
+ $params['pdo'] = new stdClass();
- $driverMock = $this->createMock('Doctrine\DBAL\Driver');
+ $driverMock = $this->createMock(Driver::class);
$conn = new Connection($params, $driverMock);
- self::assertTrue($conn->isConnected(), "Connection is not connected after passing external PDO");
+ self::assertTrue($conn->isConnected(), 'Connection is not connected after passing external PDO');
}
public function testCallingDeleteWithNoDeletionCriteriaResultsInInvalidArgumentException()
{
- /* @var $driver \Doctrine\DBAL\Driver */
- $driver = $this->createMock('Doctrine\DBAL\Driver');
- $pdoMock = $this->createMock('Doctrine\DBAL\Driver\Connection');
+ /** @var Driver $driver */
+ $driver = $this->createMock(Driver::class);
+ $pdoMock = $this->createMock(\Doctrine\DBAL\Driver\Connection::class);
// should never execute queries with invalid arguments
$pdoMock->expects($this->never())->method('exec');
$pdoMock->expects($this->never())->method('prepare');
- $conn = new Connection(array('pdo' => $pdoMock), $driver);
+ $conn = new Connection(['pdo' => $pdoMock], $driver);
$this->expectException(InvalidArgumentException::class);
- $conn->delete('kittens', array());
+ $conn->delete('kittens', []);
}
public function dataCallConnectOnce()
{
- return array(
- array('delete', array('tbl', array('id' => 12345))),
- array('insert', array('tbl', array('data' => 'foo'))),
- array('update', array('tbl', array('data' => 'bar'), array('id' => 12345))),
- array('prepare', array('select * from dual')),
- array('executeUpdate', array('insert into tbl (id) values (?)'), array(123)),
- );
+ return [
+ ['delete', ['tbl', ['id' => 12345]]],
+ ['insert', ['tbl', ['data' => 'foo']]],
+ ['update', ['tbl', ['data' => 'bar'], ['id' => 12345]]],
+ ['prepare', ['select * from dual']],
+ ['executeUpdate', ['insert into tbl (id) values (?)'], [123]],
+ ];
}
/**
@@ -717,23 +718,23 @@ public function dataCallConnectOnce()
*/
public function testCallConnectOnce($method, $params)
{
- $driverMock = $this->createMock('Doctrine\DBAL\Driver');
- $pdoMock = $this->createMock('Doctrine\DBAL\Driver\Connection');
+ $driverMock = $this->createMock(Driver::class);
+ $pdoMock = $this->createMock(\Doctrine\DBAL\Driver\Connection::class);
$platformMock = new Mocks\MockPlatform();
- $stmtMock = $this->createMock('Doctrine\DBAL\Driver\Statement');
+ $stmtMock = $this->createMock(Statement::class);
$pdoMock->expects($this->any())
->method('prepare')
->will($this->returnValue($stmtMock));
- $conn = $this->getMockBuilder('Doctrine\DBAL\Connection')
- ->setConstructorArgs(array(array('pdo' => $pdoMock, 'platform' => $platformMock), $driverMock))
- ->setMethods(array('connect'))
+ $conn = $this->getMockBuilder(Connection::class)
+ ->setConstructorArgs([['pdo' => $pdoMock, 'platform' => $platformMock], $driverMock])
+ ->setMethods(['connect'])
->getMock();
$conn->expects($this->once())->method('connect');
- call_user_func_array(array($conn, $method), $params);
+ call_user_func_array([$conn, $method], $params);
}
/**
@@ -741,16 +742,16 @@ public function testCallConnectOnce($method, $params)
*/
public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform()
{
- /** @var \Doctrine\Tests\Mocks\VersionAwarePlatformDriverMock|\PHPUnit_Framework_MockObject_MockObject $driverMock */
- $driverMock = $this->createMock('Doctrine\Tests\Mocks\VersionAwarePlatformDriverMock');
+ /** @var VersionAwarePlatformDriverMock|PHPUnit_Framework_MockObject_MockObject $driverMock */
+ $driverMock = $this->createMock(VersionAwarePlatformDriverMock::class);
- /** @var \Doctrine\Tests\Mocks\ServerInfoAwareConnectionMock|\PHPUnit_Framework_MockObject_MockObject $driverConnectionMock */
- $driverConnectionMock = $this->createMock('Doctrine\Tests\Mocks\ServerInfoAwareConnectionMock');
+ /** @var ServerInfoAwareConnectionMock|PHPUnit_Framework_MockObject_MockObject $driverConnectionMock */
+ $driverConnectionMock = $this->createMock(ServerInfoAwareConnectionMock::class);
- /** @var \Doctrine\DBAL\Platforms\AbstractPlatform|\PHPUnit_Framework_MockObject_MockObject $platformMock */
- $platformMock = $this->getMockForAbstractClass('Doctrine\DBAL\Platforms\AbstractPlatform');
+ /** @var AbstractPlatform|PHPUnit_Framework_MockObject_MockObject $platformMock */
+ $platformMock = $this->getMockForAbstractClass(AbstractPlatform::class);
- $connection = new Connection(array(), $driverMock);
+ $connection = new Connection([], $driverMock);
$driverMock->expects($this->once())
->method('connect')
@@ -786,7 +787,7 @@ public function testConnectionParamsArePassedToTheQueryCacheProfileInExecuteCach
$params = [666];
$types = [ParameterType::INTEGER];
- /* @var $queryCacheProfileMock QueryCacheProfile|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var QueryCacheProfile|PHPUnit_Framework_MockObject_MockObject $queryCacheProfileMock */
$queryCacheProfileMock = $this->createMock(QueryCacheProfile::class);
$queryCacheProfileMock
@@ -801,7 +802,7 @@ public function testConnectionParamsArePassedToTheQueryCacheProfileInExecuteCach
->with($query, $params, $types, $this->params)
->will($this->returnValue(['cacheKey', 'realKey']));
- /* @var $driver Driver */
+ /** @var Driver $driver */
$driver = $this->createMock(Driver::class);
self::assertInstanceOf(
@@ -813,7 +814,7 @@ public function testConnectionParamsArePassedToTheQueryCacheProfileInExecuteCach
/**
* @group #2821
*/
- public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecuteCacheQuery(): void
+ public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecuteCacheQuery() : void
{
$resultCacheDriverMock = $this->createMock(Cache::class);
@@ -823,7 +824,7 @@ public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecute
->with('cacheKey')
->will($this->returnValue(['realKey' => []]));
- /* @var $queryCacheProfileMock QueryCacheProfile|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var QueryCacheProfile|PHPUnit_Framework_MockObject_MockObject $queryCacheProfileMock */
$queryCacheProfileMock = $this->createMock(QueryCacheProfile::class);
$queryCacheProfileMock
@@ -831,7 +832,7 @@ public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecute
->method('getResultCacheDriver')
->will($this->returnValue($resultCacheDriverMock));
- $query = 'SELECT 1';
+ $query = 'SELECT 1';
$connectionParams = $this->params;
@@ -843,7 +844,7 @@ public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecute
$connectionParams['platform'] = $this->createMock(AbstractPlatform::class);
- /* @var $driver Driver */
+ /** @var Driver $driver */
$driver = $this->createMock(Driver::class);
(new Connection($connectionParams, $driver))->executeCacheQuery($query, [], [], $queryCacheProfileMock);
@@ -852,12 +853,12 @@ public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecute
/**
* @group #2821
*/
- public function testThrowsExceptionWhenInValidPlatformSpecified(): void
+ public function testThrowsExceptionWhenInValidPlatformSpecified() : void
{
- $connectionParams = $this->params;
- $connectionParams['platform'] = new \stdClass();
+ $connectionParams = $this->params;
+ $connectionParams['platform'] = new stdClass();
- /* @var $driver Driver */
+ /** @var Driver $driver */
$driver = $this->createMock(Driver::class);
$this->expectException(DBALException::class);
@@ -870,12 +871,12 @@ public function testThrowsExceptionWhenInValidPlatformSpecified(): void
*/
public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnectingToNonExistentDatabase()
{
- /** @var \Doctrine\Tests\Mocks\VersionAwarePlatformDriverMock|\PHPUnit_Framework_MockObject_MockObject $driverMock */
+ /** @var VersionAwarePlatformDriverMock|PHPUnit_Framework_MockObject_MockObject $driverMock */
$driverMock = $this->createMock(VersionAwarePlatformDriverMock::class);
- $connection = new Connection(array('dbname' => 'foo'), $driverMock);
- $originalException = new \Exception('Original exception');
- $fallbackException = new \Exception('Fallback exception');
+ $connection = new Connection(['dbname' => 'foo'], $driverMock);
+ $originalException = new Exception('Original exception');
+ $fallbackException = new Exception('Fallback exception');
$driverMock->expects($this->at(0))
->method('connect')
diff --git a/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php b/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php
index e83524f3c84..9c0cc18c0be 100644
--- a/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php
+++ b/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php
@@ -3,10 +3,12 @@
namespace Doctrine\Tests\DBAL;
use Doctrine\DBAL\DBALException;
-use Doctrine\DBAL\Exception\DriverException;
+use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\DriverException as InnerDriverException;
+use Doctrine\DBAL\Exception\DriverException;
use Doctrine\Tests\DbalTestCase;
-use Doctrine\DBAL\Driver;
+use Exception;
+use stdClass;
use function chr;
use function fopen;
use function sprintf;
@@ -15,25 +17,25 @@ class DBALExceptionTest extends DbalTestCase
{
public function testDriverExceptionDuringQueryAcceptsBinaryData()
{
- /* @var $driver Driver */
+ /** @var Driver $driver */
$driver = $this->createMock(Driver::class);
- $e = DBALException::driverExceptionDuringQuery($driver, new \Exception, '', array('ABC', chr(128)));
+ $e = DBALException::driverExceptionDuringQuery($driver, new Exception(), '', ['ABC', chr(128)]);
self::assertContains('with params ["ABC", "\x80"]', $e->getMessage());
}
-
+
public function testDriverExceptionDuringQueryAcceptsResource()
{
- /* @var $driver Driver */
+ /** @var Driver $driver */
$driver = $this->createMock(Driver::class);
- $e = \Doctrine\DBAL\DBALException::driverExceptionDuringQuery($driver, new \Exception, "INSERT INTO file (`content`) VALUES (?)", [1 => fopen(__FILE__, 'r')]);
+ $e = DBALException::driverExceptionDuringQuery($driver, new Exception(), 'INSERT INTO file (`content`) VALUES (?)', [1 => fopen(__FILE__, 'r')]);
self::assertContains('Resource', $e->getMessage());
}
public function testAvoidOverWrappingOnDriverException()
{
- /* @var $driver Driver */
+ /** @var Driver $driver */
$driver = $this->createMock(Driver::class);
- $inner = new class extends \Exception implements InnerDriverException
+ $inner = new class extends Exception implements InnerDriverException
{
/**
* {@inheritDoc}
@@ -49,14 +51,14 @@ public function getSQLState()
{
}
};
- $ex = new DriverException('', $inner);
- $e = DBALException::driverExceptionDuringQuery($driver, $ex, '');
+ $ex = new DriverException('', $inner);
+ $e = DBALException::driverExceptionDuringQuery($driver, $ex, '');
self::assertSame($ex, $e);
}
public function testDriverRequiredWithUrl()
{
- $url = 'mysql://localhost';
+ $url = 'mysql://localhost';
$exception = DBALException::driverRequired($url);
self::assertInstanceOf(DBALException::class, $exception);
@@ -73,9 +75,9 @@ public function testDriverRequiredWithUrl()
/**
* @group #2821
*/
- public function testInvalidPlatformTypeObject(): void
+ public function testInvalidPlatformTypeObject() : void
{
- $exception = DBALException::invalidPlatformType(new \stdClass());
+ $exception = DBALException::invalidPlatformType(new stdClass());
self::assertSame(
"Option 'platform' must be a subtype of 'Doctrine\DBAL\Platforms\AbstractPlatform', instance of 'stdClass' given",
@@ -86,7 +88,7 @@ public function testInvalidPlatformTypeObject(): void
/**
* @group #2821
*/
- public function testInvalidPlatformTypeScalar(): void
+ public function testInvalidPlatformTypeScalar() : void
{
$exception = DBALException::invalidPlatformType('some string');
diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractDB2DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractDB2DriverTest.php
index 3b6b9773c06..e6a54060c71 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/AbstractDB2DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractDB2DriverTest.php
@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver\AbstractDB2Driver;
use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Schema\DB2SchemaManager;
@@ -10,7 +11,7 @@ class AbstractDB2DriverTest extends AbstractDriverTest
{
protected function createDriver()
{
- return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractDB2Driver');
+ return $this->getMockForAbstractClass(AbstractDB2Driver::class);
}
protected function createPlatform()
diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php
index 7a49b3f9577..0475ea11b89 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php
@@ -3,37 +3,58 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
-use Doctrine\DBAL\Driver\DriverException;
+use Doctrine\DBAL\Driver;
+use Doctrine\DBAL\Driver\DriverException as DriverExceptionInterface;
use Doctrine\DBAL\Driver\ExceptionConverterDriver;
+use Doctrine\DBAL\Exception\ConnectionException;
+use Doctrine\DBAL\Exception\ConstraintViolationException;
+use Doctrine\DBAL\Exception\DatabaseObjectExistsException;
+use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException;
+use Doctrine\DBAL\Exception\DeadlockException;
+use Doctrine\DBAL\Exception\DriverException;
+use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
+use Doctrine\DBAL\Exception\InvalidFieldNameException;
+use Doctrine\DBAL\Exception\LockWaitTimeoutException;
+use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
+use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
+use Doctrine\DBAL\Exception\ReadOnlyException;
+use Doctrine\DBAL\Exception\ServerException;
+use Doctrine\DBAL\Exception\SyntaxErrorException;
+use Doctrine\DBAL\Exception\TableExistsException;
+use Doctrine\DBAL\Exception\TableNotFoundException;
+use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver;
use Doctrine\Tests\DbalTestCase;
+use Exception;
use function get_class;
use function sprintf;
abstract class AbstractDriverTest extends DbalTestCase
{
- const EXCEPTION_CONNECTION = 'Doctrine\DBAL\Exception\ConnectionException';
- const EXCEPTION_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\ConstraintViolationException';
- const EXCEPTION_DATABASE_OBJECT_EXISTS = 'Doctrine\DBAL\Exception\DatabaseObjectExistsException';
- const EXCEPTION_DATABASE_OBJECT_NOT_FOUND = 'Doctrine\DBAL\Exception\DatabaseObjectNotFoundException';
- const EXCEPTION_DRIVER = 'Doctrine\DBAL\Exception\DriverException';
- const EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException';
- const EXCEPTION_INVALID_FIELD_NAME = 'Doctrine\DBAL\Exception\InvalidFieldNameException';
- const EXCEPTION_NON_UNIQUE_FIELD_NAME = 'Doctrine\DBAL\Exception\NonUniqueFieldNameException';
- const EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\NotNullConstraintViolationException';
- const EXCEPTION_READ_ONLY = 'Doctrine\DBAL\Exception\ReadOnlyException';
- const EXCEPTION_SERVER = 'Doctrine\DBAL\Exception\ServerException';
- const EXCEPTION_SYNTAX_ERROR = 'Doctrine\DBAL\Exception\SyntaxErrorException';
- const EXCEPTION_TABLE_EXISTS = 'Doctrine\DBAL\Exception\TableExistsException';
- const EXCEPTION_TABLE_NOT_FOUND = 'Doctrine\DBAL\Exception\TableNotFoundException';
- const EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\UniqueConstraintViolationException';
- const EXCEPTION_DEADLOCK = 'Doctrine\DBAL\Exception\DeadlockException';
- const EXCEPTION_LOCK_WAIT_TIMEOUT = 'Doctrine\DBAL\Exception\LockWaitTimeoutException';
+ public const EXCEPTION_CONNECTION = ConnectionException::class;
+ public const EXCEPTION_CONSTRAINT_VIOLATION = ConstraintViolationException::class;
+ public const EXCEPTION_DATABASE_OBJECT_EXISTS = DatabaseObjectExistsException::class;
+ public const EXCEPTION_DATABASE_OBJECT_NOT_FOUND = DatabaseObjectNotFoundException::class;
+ public const EXCEPTION_DRIVER = DriverException::class;
+ public const EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION = ForeignKeyConstraintViolationException::class;
+ public const EXCEPTION_INVALID_FIELD_NAME = InvalidFieldNameException::class;
+ public const EXCEPTION_NON_UNIQUE_FIELD_NAME = NonUniqueFieldNameException::class;
+ public const EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION = NotNullConstraintViolationException::class;
+ public const EXCEPTION_READ_ONLY = ReadOnlyException::class;
+ public const EXCEPTION_SERVER = ServerException::class;
+ public const EXCEPTION_SYNTAX_ERROR = SyntaxErrorException::class;
+ public const EXCEPTION_TABLE_EXISTS = TableExistsException::class;
+ public const EXCEPTION_TABLE_NOT_FOUND = TableNotFoundException::class;
+ public const EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION = UniqueConstraintViolationException::class;
+ public const EXCEPTION_DEADLOCK = DeadlockException::class;
+ public const EXCEPTION_LOCK_WAIT_TIMEOUT = LockWaitTimeoutException::class;
/**
* The driver mock under test.
*
- * @var \Doctrine\DBAL\Driver
+ * @var Driver
*/
protected $driver;
@@ -46,7 +67,7 @@ protected function setUp()
public function testConvertsException()
{
- if ( ! $this->driver instanceof ExceptionConverterDriver) {
+ if (! $this->driver instanceof ExceptionConverterDriver) {
$this->markTestSkipped('This test is only intended for exception converter drivers.');
}
@@ -56,13 +77,13 @@ public function testConvertsException()
$this->fail(
sprintf(
'No test data found for test %s. You have to return test data from %s.',
- get_class($this) . '::' . __FUNCTION__,
- get_class($this) . '::getExceptionConversionData'
+ static::class . '::' . __FUNCTION__,
+ static::class . '::getExceptionConversionData'
)
);
}
- $driverException = new class extends \Exception implements DriverException
+ $driverException = new class extends Exception implements DriverExceptionInterface
{
public function __construct()
{
@@ -86,13 +107,13 @@ public function getSQLState()
}
};
- $data[] = array($driverException, self::EXCEPTION_DRIVER);
+ $data[] = [$driverException, self::EXCEPTION_DRIVER];
$message = 'DBAL exception message';
foreach ($data as $item) {
/** @var $driverException \Doctrine\DBAL\Driver\DriverException */
- list($driverException, $convertedExceptionClassName) = $item;
+ [$driverException, $convertedExceptionClassName] = $item;
$convertedException = $this->driver->convertException($message, $driverException);
@@ -106,7 +127,7 @@ public function getSQLState()
public function testCreatesDatabasePlatformForVersion()
{
- if ( ! $this->driver instanceof VersionAwarePlatformDriver) {
+ if (! $this->driver instanceof VersionAwarePlatformDriver) {
$this->markTestSkipped('This test is only intended for version aware platform drivers.');
}
@@ -116,8 +137,8 @@ public function testCreatesDatabasePlatformForVersion()
$data,
sprintf(
'No test data found for test %s. You have to return test data from %s.',
- get_class($this) . '::' . __FUNCTION__,
- get_class($this) . '::getDatabasePlatformsForVersions'
+ static::class . '::' . __FUNCTION__,
+ static::class . '::getDatabasePlatformsForVersions'
)
);
@@ -142,7 +163,7 @@ public function testCreatesDatabasePlatformForVersion()
*/
public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion()
{
- if ( ! $this->driver instanceof VersionAwarePlatformDriver) {
+ if (! $this->driver instanceof VersionAwarePlatformDriver) {
$this->markTestSkipped('This test is only intended for version aware platform drivers.');
}
@@ -151,11 +172,11 @@ public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion(
public function testReturnsDatabaseName()
{
- $params = array(
+ $params = [
'user' => 'foo',
'password' => 'bar',
'dbname' => 'baz',
- );
+ ];
$connection = $this->getConnectionMock();
@@ -183,7 +204,7 @@ public function testReturnsSchemaManager()
/**
* Factory method for creating the driver instance under test.
*
- * @return \Doctrine\DBAL\Driver
+ * @return Driver
*/
abstract protected function createDriver();
@@ -193,7 +214,7 @@ abstract protected function createDriver();
* The platform instance returned by this method must be the same as returned by
* the driver's getDatabasePlatform() method.
*
- * @return \Doctrine\DBAL\Platforms\AbstractPlatform
+ * @return AbstractPlatform
*/
abstract protected function createPlatform();
@@ -205,45 +226,41 @@ abstract protected function createPlatform();
*
* @param Connection $connection The underlying connection to use.
*
- * @return \Doctrine\DBAL\Schema\AbstractSchemaManager
+ * @return AbstractSchemaManager
*/
abstract protected function createSchemaManager(Connection $connection);
protected function getConnectionMock()
{
- return $this->getMockBuilder('Doctrine\DBAL\Connection')
+ return $this->getMockBuilder(Connection::class)
->disableOriginalConstructor()
->getMock();
}
protected function getDatabasePlatformsForVersions()
{
- return array();
+ return [];
}
protected function getExceptionConversionData()
{
- return array();
+ return [];
}
private function getExceptionConversions()
{
- $data = array();
+ $data = [];
foreach ($this->getExceptionConversionData() as $convertedExceptionClassName => $errors) {
foreach ($errors as $error) {
$driverException = new class ($error[0], $error[1], $error[2])
- extends \Exception
- implements DriverException
+ extends Exception
+ implements DriverExceptionInterface
{
- /**
- * @var mixed
- */
+ /** @var mixed */
private $errorCode;
- /**
- * @var mixed
- */
+ /** @var mixed */
private $sqlState;
public function __construct($errorCode, $sqlState, $message)
@@ -271,7 +288,7 @@ public function getSQLState()
}
};
- $data[] = array($driverException, $convertedExceptionClassName);
+ $data[] = [$driverException, $convertedExceptionClassName];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php
index 337a73c0e29..cde381653a9 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php
@@ -3,11 +3,13 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver\AbstractMySQLDriver;
use Doctrine\DBAL\Platforms\MariaDb1027Platform;
use Doctrine\DBAL\Platforms\MySQL57Platform;
use Doctrine\DBAL\Platforms\MySQL80Platform;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\MySqlSchemaManager;
+use Doctrine\Tests\Mocks\DriverResultStatementMock;
class AbstractMySQLDriverTest extends AbstractDriverTest
{
@@ -16,12 +18,12 @@ public function testReturnsDatabaseName()
parent::testReturnsDatabaseName();
$database = 'bloo';
- $params = array(
+ $params = [
'user' => 'foo',
'password' => 'bar',
- );
+ ];
- $statement = $this->createMock('Doctrine\Tests\Mocks\DriverResultStatementMock');
+ $statement = $this->createMock(DriverResultStatementMock::class);
$statement->expects($this->once())
->method('fetchColumn')
@@ -42,7 +44,7 @@ public function testReturnsDatabaseName()
protected function createDriver()
{
- return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractMySQLDriver');
+ return $this->getMockForAbstractClass(AbstractMySQLDriver::class);
}
protected function createPlatform()
@@ -55,6 +57,9 @@ protected function createSchemaManager(Connection $connection)
return new MySqlSchemaManager($connection);
}
+ /**
+ * @return mixed[][]
+ */
protected function getDatabasePlatformsForVersions() : array
{
return [
@@ -74,85 +79,85 @@ protected function getDatabasePlatformsForVersions() : array
['5.5.40-MariaDB-1~wheezy', MySqlPlatform::class],
['5.5.5-MariaDB-10.2.8+maria~xenial-log', MariaDb1027Platform::class],
['10.2.8-MariaDB-10.2.8+maria~xenial-log', MariaDb1027Platform::class],
- ['10.2.8-MariaDB-1~lenny-log', MariaDb1027Platform::class]
+ ['10.2.8-MariaDB-1~lenny-log', MariaDb1027Platform::class],
];
}
protected function getExceptionConversionData()
{
- return array(
- self::EXCEPTION_CONNECTION => array(
- array('1044', null, null),
- array('1045', null, null),
- array('1046', null, null),
- array('1049', null, null),
- array('1095', null, null),
- array('1142', null, null),
- array('1143', null, null),
- array('1227', null, null),
- array('1370', null, null),
- array('2002', null, null),
- array('2005', null, null),
- ),
- self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => array(
- array('1216', null, null),
- array('1217', null, null),
- array('1451', null, null),
- array('1452', null, null),
- ),
- self::EXCEPTION_INVALID_FIELD_NAME => array(
- array('1054', null, null),
- array('1166', null, null),
- array('1611', null, null),
- ),
- self::EXCEPTION_NON_UNIQUE_FIELD_NAME => array(
- array('1052', null, null),
- array('1060', null, null),
- array('1110', null, null),
- ),
- self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => array(
- array('1048', null, null),
- array('1121', null, null),
- array('1138', null, null),
- array('1171', null, null),
- array('1252', null, null),
- array('1263', null, null),
- array('1364', null, null),
- array('1566', null, null),
- ),
- self::EXCEPTION_SYNTAX_ERROR => array(
- array('1064', null, null),
- array('1149', null, null),
- array('1287', null, null),
- array('1341', null, null),
- array('1342', null, null),
- array('1343', null, null),
- array('1344', null, null),
- array('1382', null, null),
- array('1479', null, null),
- array('1541', null, null),
- array('1554', null, null),
- array('1626', null, null),
- ),
- self::EXCEPTION_TABLE_EXISTS => array(
- array('1050', null, null),
- ),
- self::EXCEPTION_TABLE_NOT_FOUND => array(
- array('1051', null, null),
- array('1146', null, null),
- ),
- self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => array(
- array('1062', null, null),
- array('1557', null, null),
- array('1569', null, null),
- array('1586', null, null),
- ),
- self::EXCEPTION_DEADLOCK => array(
- array('1213', null, null),
- ),
- self::EXCEPTION_LOCK_WAIT_TIMEOUT => array(
- array('1205', null, null),
- ),
- );
+ return [
+ self::EXCEPTION_CONNECTION => [
+ ['1044', null, null],
+ ['1045', null, null],
+ ['1046', null, null],
+ ['1049', null, null],
+ ['1095', null, null],
+ ['1142', null, null],
+ ['1143', null, null],
+ ['1227', null, null],
+ ['1370', null, null],
+ ['2002', null, null],
+ ['2005', null, null],
+ ],
+ self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => [
+ ['1216', null, null],
+ ['1217', null, null],
+ ['1451', null, null],
+ ['1452', null, null],
+ ],
+ self::EXCEPTION_INVALID_FIELD_NAME => [
+ ['1054', null, null],
+ ['1166', null, null],
+ ['1611', null, null],
+ ],
+ self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
+ ['1052', null, null],
+ ['1060', null, null],
+ ['1110', null, null],
+ ],
+ self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
+ ['1048', null, null],
+ ['1121', null, null],
+ ['1138', null, null],
+ ['1171', null, null],
+ ['1252', null, null],
+ ['1263', null, null],
+ ['1364', null, null],
+ ['1566', null, null],
+ ],
+ self::EXCEPTION_SYNTAX_ERROR => [
+ ['1064', null, null],
+ ['1149', null, null],
+ ['1287', null, null],
+ ['1341', null, null],
+ ['1342', null, null],
+ ['1343', null, null],
+ ['1344', null, null],
+ ['1382', null, null],
+ ['1479', null, null],
+ ['1541', null, null],
+ ['1554', null, null],
+ ['1626', null, null],
+ ],
+ self::EXCEPTION_TABLE_EXISTS => [
+ ['1050', null, null],
+ ],
+ self::EXCEPTION_TABLE_NOT_FOUND => [
+ ['1051', null, null],
+ ['1146', null, null],
+ ],
+ self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
+ ['1062', null, null],
+ ['1557', null, null],
+ ['1569', null, null],
+ ['1586', null, null],
+ ],
+ self::EXCEPTION_DEADLOCK => [
+ ['1213', null, null],
+ ],
+ self::EXCEPTION_LOCK_WAIT_TIMEOUT => [
+ ['1205', null, null],
+ ],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriver/EasyConnectStringTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriver/EasyConnectStringTest.php
index 812a46b5682..efb250d1ac7 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriver/EasyConnectStringTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriver/EasyConnectStringTest.php
@@ -9,6 +9,7 @@ class EasyConnectStringTest extends TestCase
{
/**
* @param mixed[] $params
+ *
* @dataProvider connectionParametersProvider
*/
public function testFromConnectionParameters(array $params, string $expected) : void
diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php
index 59d3c20ae0b..d88040e10a7 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php
@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver\AbstractOracleDriver;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Schema\OracleSchemaManager;
@@ -10,11 +11,11 @@ class AbstractOracleDriverTest extends AbstractDriverTest
{
public function testReturnsDatabaseName()
{
- $params = array(
+ $params = [
'user' => 'foo',
'password' => 'bar',
'dbname' => 'baz',
- );
+ ];
$connection = $this->getConnectionMock();
@@ -27,13 +28,13 @@ public function testReturnsDatabaseName()
public function testReturnsDatabaseNameWithConnectDescriptor()
{
- $params = array(
+ $params = [
'user' => 'foo',
'password' => 'bar',
'connectionstring' => '(DESCRIPTION=' .
'(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))' .
- '(CONNECT_DATA=(SERVICE_NAME=baz)))'
- );
+ '(CONNECT_DATA=(SERVICE_NAME=baz)))',
+ ];
$connection = $this->getConnectionMock();
@@ -46,7 +47,7 @@ public function testReturnsDatabaseNameWithConnectDescriptor()
protected function createDriver()
{
- return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractOracleDriver');
+ return $this->getMockForAbstractClass(AbstractOracleDriver::class);
}
protected function createPlatform()
@@ -61,38 +62,38 @@ protected function createSchemaManager(Connection $connection)
protected function getExceptionConversionData()
{
- return array(
- self::EXCEPTION_CONNECTION => array(
- array('1017', null, null),
- array('12545', null, null),
- ),
- self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => array(
- array('2292', null, null),
- ),
- self::EXCEPTION_INVALID_FIELD_NAME => array(
- array('904', null, null),
- ),
- self::EXCEPTION_NON_UNIQUE_FIELD_NAME => array(
- array('918', null, null),
- array('960', null, null),
- ),
- self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => array(
- array('1400', null, null),
- ),
- self::EXCEPTION_SYNTAX_ERROR => array(
- array('923', null, null),
- ),
- self::EXCEPTION_TABLE_EXISTS => array(
- array('955', null, null),
- ),
- self::EXCEPTION_TABLE_NOT_FOUND => array(
- array('942', null, null),
- ),
- self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => array(
- array('1', null, null),
- array('2299', null, null),
- array('38911', null, null),
- ),
- );
+ return [
+ self::EXCEPTION_CONNECTION => [
+ ['1017', null, null],
+ ['12545', null, null],
+ ],
+ self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => [
+ ['2292', null, null],
+ ],
+ self::EXCEPTION_INVALID_FIELD_NAME => [
+ ['904', null, null],
+ ],
+ self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
+ ['918', null, null],
+ ['960', null, null],
+ ],
+ self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
+ ['1400', null, null],
+ ],
+ self::EXCEPTION_SYNTAX_ERROR => [
+ ['923', null, null],
+ ],
+ self::EXCEPTION_TABLE_EXISTS => [
+ ['955', null, null],
+ ],
+ self::EXCEPTION_TABLE_NOT_FOUND => [
+ ['942', null, null],
+ ],
+ self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
+ ['1', null, null],
+ ['2299', null, null],
+ ['38911', null, null],
+ ],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php
index b71e10f80ce..d1159c80308 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php
@@ -3,9 +3,14 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
use Doctrine\DBAL\Platforms\PostgreSQL100Platform;
+use Doctrine\DBAL\Platforms\PostgreSQL91Platform;
+use Doctrine\DBAL\Platforms\PostgreSQL92Platform;
+use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\PostgreSqlSchemaManager;
+use Doctrine\Tests\Mocks\DriverResultStatementMock;
class AbstractPostgreSQLDriverTest extends AbstractDriverTest
{
@@ -14,12 +19,12 @@ public function testReturnsDatabaseName()
parent::testReturnsDatabaseName();
$database = 'bloo';
- $params = array(
+ $params = [
'user' => 'foo',
'password' => 'bar',
- );
+ ];
- $statement = $this->createMock('Doctrine\Tests\Mocks\DriverResultStatementMock');
+ $statement = $this->createMock(DriverResultStatementMock::class);
$statement->expects($this->once())
->method('fetchColumn')
@@ -40,7 +45,7 @@ public function testReturnsDatabaseName()
protected function createDriver()
{
- return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractPostgreSQLDriver');
+ return $this->getMockForAbstractClass(AbstractPostgreSQLDriver::class);
}
protected function createPlatform()
@@ -55,57 +60,57 @@ protected function createSchemaManager(Connection $connection)
protected function getDatabasePlatformsForVersions()
{
- return array(
- array('9.0.9', 'Doctrine\DBAL\Platforms\PostgreSqlPlatform'),
- array('9.1', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'),
- array('9.1.0', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'),
- array('9.1.1', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'),
- array('9.1.9', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'),
- array('9.2', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'),
- array('9.2.0', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'),
- array('9.2.1', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'),
- array('9.3.6', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'),
- array('9.4', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'),
- array('9.4.0', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'),
- array('9.4.1', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'),
- array('10', PostgreSQL100Platform::class),
- );
+ return [
+ ['9.0.9', PostgreSqlPlatform::class],
+ ['9.1', PostgreSQL91Platform::class],
+ ['9.1.0', PostgreSQL91Platform::class],
+ ['9.1.1', PostgreSQL91Platform::class],
+ ['9.1.9', PostgreSQL91Platform::class],
+ ['9.2', PostgreSQL92Platform::class],
+ ['9.2.0', PostgreSQL92Platform::class],
+ ['9.2.1', PostgreSQL92Platform::class],
+ ['9.3.6', PostgreSQL92Platform::class],
+ ['9.4', PostgreSQL94Platform::class],
+ ['9.4.0', PostgreSQL94Platform::class],
+ ['9.4.1', PostgreSQL94Platform::class],
+ ['10', PostgreSQL100Platform::class],
+ ];
}
protected function getExceptionConversionData()
{
- return array(
- self::EXCEPTION_CONNECTION => array(
- array(null, '7', 'SQLSTATE[08006]'),
- ),
- self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => array(
- array(null, '23503', null),
- ),
- self::EXCEPTION_INVALID_FIELD_NAME => array(
- array(null, '42703', null),
- ),
- self::EXCEPTION_NON_UNIQUE_FIELD_NAME => array(
- array(null, '42702', null),
- ),
- self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => array(
- array(null, '23502', null),
- ),
- self::EXCEPTION_SYNTAX_ERROR => array(
- array(null, '42601', null),
- ),
- self::EXCEPTION_TABLE_EXISTS => array(
- array(null, '42P07', null),
- ),
- self::EXCEPTION_TABLE_NOT_FOUND => array(
- array(null, '42P01', null),
- ),
- self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => array(
- array(null, '23505', null),
- ),
- self::EXCEPTION_DEADLOCK => array(
- array(null, '40001', null),
- array(null, '40P01', null),
- ),
- );
+ return [
+ self::EXCEPTION_CONNECTION => [
+ [null, '7', 'SQLSTATE[08006]'],
+ ],
+ self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => [
+ [null, '23503', null],
+ ],
+ self::EXCEPTION_INVALID_FIELD_NAME => [
+ [null, '42703', null],
+ ],
+ self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
+ [null, '42702', null],
+ ],
+ self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
+ [null, '23502', null],
+ ],
+ self::EXCEPTION_SYNTAX_ERROR => [
+ [null, '42601', null],
+ ],
+ self::EXCEPTION_TABLE_EXISTS => [
+ [null, '42P07', null],
+ ],
+ self::EXCEPTION_TABLE_NOT_FOUND => [
+ [null, '42P01', null],
+ ],
+ self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
+ [null, '23505', null],
+ ],
+ self::EXCEPTION_DEADLOCK => [
+ [null, '40001', null],
+ [null, '40P01', null],
+ ],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php
index f2b13c3c1c9..cbd23505bae 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php
@@ -3,14 +3,18 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver\AbstractSQLAnywhereDriver;
+use Doctrine\DBAL\Platforms\SQLAnywhere11Platform;
use Doctrine\DBAL\Platforms\SQLAnywhere12Platform;
+use Doctrine\DBAL\Platforms\SQLAnywhere16Platform;
+use Doctrine\DBAL\Platforms\SQLAnywherePlatform;
use Doctrine\DBAL\Schema\SQLAnywhereSchemaManager;
class AbstractSQLAnywhereDriverTest extends AbstractDriverTest
{
protected function createDriver()
{
- return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractSQLAnywhereDriver');
+ return $this->getMockForAbstractClass(AbstractSQLAnywhereDriver::class);
}
protected function createPlatform()
@@ -25,84 +29,84 @@ protected function createSchemaManager(Connection $connection)
protected function getDatabasePlatformsForVersions()
{
- return array(
- array('10', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'),
- array('10.0', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'),
- array('10.0.0', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'),
- array('10.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'),
- array('10.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'),
- array('10.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'),
- array('11', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'),
- array('11.0', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'),
- array('11.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'),
- array('11.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'),
- array('11.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'),
- array('11.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'),
- array('12', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('12.0', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('12.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('12.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('12.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('12.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('13', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('14', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('15', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('15.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'),
- array('16', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'),
- array('16.0', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'),
- array('16.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'),
- array('16.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'),
- array('16.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'),
- array('16.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'),
- array('17', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'),
- );
+ return [
+ ['10', SQLAnywherePlatform::class],
+ ['10.0', SQLAnywherePlatform::class],
+ ['10.0.0', SQLAnywherePlatform::class],
+ ['10.0.0.0', SQLAnywherePlatform::class],
+ ['10.1.2.3', SQLAnywherePlatform::class],
+ ['10.9.9.9', SQLAnywherePlatform::class],
+ ['11', SQLAnywhere11Platform::class],
+ ['11.0', SQLAnywhere11Platform::class],
+ ['11.0.0', SQLAnywhere11Platform::class],
+ ['11.0.0.0', SQLAnywhere11Platform::class],
+ ['11.1.2.3', SQLAnywhere11Platform::class],
+ ['11.9.9.9', SQLAnywhere11Platform::class],
+ ['12', SQLAnywhere12Platform::class],
+ ['12.0', SQLAnywhere12Platform::class],
+ ['12.0.0', SQLAnywhere12Platform::class],
+ ['12.0.0.0', SQLAnywhere12Platform::class],
+ ['12.1.2.3', SQLAnywhere12Platform::class],
+ ['12.9.9.9', SQLAnywhere12Platform::class],
+ ['13', SQLAnywhere12Platform::class],
+ ['14', SQLAnywhere12Platform::class],
+ ['15', SQLAnywhere12Platform::class],
+ ['15.9.9.9', SQLAnywhere12Platform::class],
+ ['16', SQLAnywhere16Platform::class],
+ ['16.0', SQLAnywhere16Platform::class],
+ ['16.0.0', SQLAnywhere16Platform::class],
+ ['16.0.0.0', SQLAnywhere16Platform::class],
+ ['16.1.2.3', SQLAnywhere16Platform::class],
+ ['16.9.9.9', SQLAnywhere16Platform::class],
+ ['17', SQLAnywhere16Platform::class],
+ ];
}
protected function getExceptionConversionData()
{
- return array(
- self::EXCEPTION_CONNECTION => array(
- array('-100', null, null),
- array('-103', null, null),
- array('-832', null, null),
- ),
- self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => array(
- array('-198', null, null),
- ),
- self::EXCEPTION_INVALID_FIELD_NAME => array(
- array('-143', null, null),
- ),
- self::EXCEPTION_NON_UNIQUE_FIELD_NAME => array(
- array('-144', null, null),
- ),
- self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => array(
- array('-184', null, null),
- array('-195', null, null),
- ),
- self::EXCEPTION_SYNTAX_ERROR => array(
- array('-131', null, null),
- ),
- self::EXCEPTION_TABLE_EXISTS => array(
- array('-110', null, null),
- ),
- self::EXCEPTION_TABLE_NOT_FOUND => array(
- array('-141', null, null),
- array('-1041', null, null),
- ),
- self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => array(
- array('-193', null, null),
- array('-196', null, null),
- ),
- self::EXCEPTION_DEADLOCK => array(
- array('-306', null, null),
- array('-307', null, null),
- array('-684', null, null),
- ),
- self::EXCEPTION_LOCK_WAIT_TIMEOUT => array(
- array('-210', null, null),
- array('-1175', null, null),
- array('-1281', null, null),
- ),
- );
+ return [
+ self::EXCEPTION_CONNECTION => [
+ ['-100', null, null],
+ ['-103', null, null],
+ ['-832', null, null],
+ ],
+ self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => [
+ ['-198', null, null],
+ ],
+ self::EXCEPTION_INVALID_FIELD_NAME => [
+ ['-143', null, null],
+ ],
+ self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
+ ['-144', null, null],
+ ],
+ self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
+ ['-184', null, null],
+ ['-195', null, null],
+ ],
+ self::EXCEPTION_SYNTAX_ERROR => [
+ ['-131', null, null],
+ ],
+ self::EXCEPTION_TABLE_EXISTS => [
+ ['-110', null, null],
+ ],
+ self::EXCEPTION_TABLE_NOT_FOUND => [
+ ['-141', null, null],
+ ['-1041', null, null],
+ ],
+ self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
+ ['-193', null, null],
+ ['-196', null, null],
+ ],
+ self::EXCEPTION_DEADLOCK => [
+ ['-306', null, null],
+ ['-307', null, null],
+ ['-684', null, null],
+ ],
+ self::EXCEPTION_LOCK_WAIT_TIMEOUT => [
+ ['-210', null, null],
+ ['-1175', null, null],
+ ['-1281', null, null],
+ ],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php
index 35d2d721a51..48fb3b29f3e 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php
@@ -3,14 +3,18 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver\AbstractSQLServerDriver;
+use Doctrine\DBAL\Platforms\SQLServer2005Platform;
use Doctrine\DBAL\Platforms\SQLServer2008Platform;
+use Doctrine\DBAL\Platforms\SQLServer2012Platform;
+use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\SQLServerSchemaManager;
class AbstractSQLServerDriverTest extends AbstractDriverTest
{
protected function createDriver()
{
- return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractSQLServerDriver');
+ return $this->getMockForAbstractClass(AbstractSQLServerDriver::class);
}
protected function createPlatform()
@@ -25,33 +29,33 @@ protected function createSchemaManager(Connection $connection)
protected function getDatabasePlatformsForVersions()
{
- return array(
- array('9', 'Doctrine\DBAL\Platforms\SQLServerPlatform'),
- array('9.00', 'Doctrine\DBAL\Platforms\SQLServerPlatform'),
- array('9.00.0', 'Doctrine\DBAL\Platforms\SQLServerPlatform'),
- array('9.00.1398', 'Doctrine\DBAL\Platforms\SQLServerPlatform'),
- array('9.00.1398.99', 'Doctrine\DBAL\Platforms\SQLServerPlatform'),
- array('9.00.1399', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('9.00.1399.0', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('9.00.1399.99', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('9.00.1400', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('9.10', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('9.10.9999', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('10.00.1599', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('10.00.1599.99', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'),
- array('10.00.1600', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('10.00.1600.0', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('10.00.1600.99', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('10.00.1601', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('10.10', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('10.10.9999', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('11.00.2099', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('11.00.2099.99', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'),
- array('11.00.2100', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'),
- array('11.00.2100.0', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'),
- array('11.00.2100.99', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'),
- array('11.00.2101', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'),
- array('12', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'),
- );
+ return [
+ ['9', SQLServerPlatform::class],
+ ['9.00', SQLServerPlatform::class],
+ ['9.00.0', SQLServerPlatform::class],
+ ['9.00.1398', SQLServerPlatform::class],
+ ['9.00.1398.99', SQLServerPlatform::class],
+ ['9.00.1399', SQLServer2005Platform::class],
+ ['9.00.1399.0', SQLServer2005Platform::class],
+ ['9.00.1399.99', SQLServer2005Platform::class],
+ ['9.00.1400', SQLServer2005Platform::class],
+ ['9.10', SQLServer2005Platform::class],
+ ['9.10.9999', SQLServer2005Platform::class],
+ ['10.00.1599', SQLServer2005Platform::class],
+ ['10.00.1599.99', SQLServer2005Platform::class],
+ ['10.00.1600', SQLServer2008Platform::class],
+ ['10.00.1600.0', SQLServer2008Platform::class],
+ ['10.00.1600.99', SQLServer2008Platform::class],
+ ['10.00.1601', SQLServer2008Platform::class],
+ ['10.10', SQLServer2008Platform::class],
+ ['10.10.9999', SQLServer2008Platform::class],
+ ['11.00.2099', SQLServer2008Platform::class],
+ ['11.00.2099.99', SQLServer2008Platform::class],
+ ['11.00.2100', SQLServer2012Platform::class],
+ ['11.00.2100.0', SQLServer2012Platform::class],
+ ['11.00.2100.99', SQLServer2012Platform::class],
+ ['11.00.2101', SQLServer2012Platform::class],
+ ['12', SQLServer2012Platform::class],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php
index e1ce3f10127..d92aa5d0d8d 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php
@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver\AbstractSQLiteDriver;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\SqliteSchemaManager;
@@ -10,12 +11,12 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest
{
public function testReturnsDatabaseName()
{
- $params = array(
+ $params = [
'user' => 'foo',
'password' => 'bar',
'dbname' => 'baz',
'path' => 'bloo',
- );
+ ];
$connection = $this->getConnectionMock();
@@ -28,7 +29,7 @@ public function testReturnsDatabaseName()
protected function createDriver()
{
- return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractSQLiteDriver');
+ return $this->getMockForAbstractClass(AbstractSQLiteDriver::class);
}
protected function createPlatform()
@@ -43,39 +44,39 @@ protected function createSchemaManager(Connection $connection)
protected function getExceptionConversionData()
{
- return array(
- self::EXCEPTION_CONNECTION => array(
- array(null, null, 'unable to open database file'),
- ),
- self::EXCEPTION_INVALID_FIELD_NAME => array(
- array(null, null, 'has no column named'),
- ),
- self::EXCEPTION_NON_UNIQUE_FIELD_NAME => array(
- array(null, null, 'ambiguous column name'),
- ),
- self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => array(
- array(null, null, 'may not be NULL'),
- ),
- self::EXCEPTION_READ_ONLY => array(
- array(null, null, 'attempt to write a readonly database'),
- ),
- self::EXCEPTION_SYNTAX_ERROR => array(
- array(null, null, 'syntax error'),
- ),
- self::EXCEPTION_TABLE_EXISTS => array(
- array(null, null, 'already exists'),
- ),
- self::EXCEPTION_TABLE_NOT_FOUND => array(
- array(null, null, 'no such table:'),
- ),
- self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => array(
- array(null, null, 'must be unique'),
- array(null, null, 'is not unique'),
- array(null, null, 'are not unique'),
- ),
- self::EXCEPTION_LOCK_WAIT_TIMEOUT => array(
- array(null, null, 'database is locked'),
- ),
- );
+ return [
+ self::EXCEPTION_CONNECTION => [
+ [null, null, 'unable to open database file'],
+ ],
+ self::EXCEPTION_INVALID_FIELD_NAME => [
+ [null, null, 'has no column named'],
+ ],
+ self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
+ [null, null, 'ambiguous column name'],
+ ],
+ self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
+ [null, null, 'may not be NULL'],
+ ],
+ self::EXCEPTION_READ_ONLY => [
+ [null, null, 'attempt to write a readonly database'],
+ ],
+ self::EXCEPTION_SYNTAX_ERROR => [
+ [null, null, 'syntax error'],
+ ],
+ self::EXCEPTION_TABLE_EXISTS => [
+ [null, null, 'already exists'],
+ ],
+ self::EXCEPTION_TABLE_NOT_FOUND => [
+ [null, null, 'no such table:'],
+ ],
+ self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
+ [null, null, 'must be unique'],
+ [null, null, 'is not unique'],
+ [null, null, 'are not unique'],
+ ],
+ self::EXCEPTION_LOCK_WAIT_TIMEOUT => [
+ [null, null, 'database is locked'],
+ ],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php
index 004043c2051..520a732a0c3 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php
@@ -35,12 +35,15 @@ protected function createSchemaManager(Connection $connection)
return new DrizzleSchemaManager($connection);
}
+ /**
+ * @return mixed[][]
+ */
protected function getDatabasePlatformsForVersions() : array
{
return [
- ['foo', 'Doctrine\DBAL\Platforms\DrizzlePlatform'],
- ['bar', 'Doctrine\DBAL\Platforms\DrizzlePlatform'],
- ['baz', 'Doctrine\DBAL\Platforms\DrizzlePlatform'],
+ ['foo', DrizzlePlatform::class],
+ ['bar', DrizzlePlatform::class],
+ ['baz', DrizzlePlatform::class],
];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php
index 114a5a108a1..a60772295a6 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php
@@ -2,7 +2,9 @@
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;
class DB2ConnectionTest extends DbalTestCase
@@ -10,19 +12,19 @@ class DB2ConnectionTest extends DbalTestCase
/**
* The ibm_db2 driver connection mock under test.
*
- * @var \Doctrine\DBAL\Driver\IBMDB2\DB2Connection|\PHPUnit_Framework_MockObject_MockObject
+ * @var DB2Connection|PHPUnit_Framework_MockObject_MockObject
*/
private $connectionMock;
protected function setUp()
{
- if ( ! extension_loaded('ibm_db2')) {
+ if (! extension_loaded('ibm_db2')) {
$this->markTestSkipped('ibm_db2 is not installed.');
}
parent::setUp();
- $this->connectionMock = $this->getMockBuilder('Doctrine\DBAL\Driver\IBMDB2\DB2Connection')
+ $this->connectionMock = $this->getMockBuilder(DB2Connection::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php
index 1dec0608eba..9bd3172dd1d 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php
@@ -6,6 +6,7 @@
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;
@@ -15,19 +16,19 @@ class MysqliConnectionTest extends DbalFunctionalTestCase
/**
* The mysqli driver connection mock under test.
*
- * @var \Doctrine\DBAL\Driver\Mysqli\MysqliConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var MysqliConnection|PHPUnit_Framework_MockObject_MockObject
*/
private $connectionMock;
protected function setUp()
{
- if ( ! extension_loaded('mysqli')) {
+ if (! extension_loaded('mysqli')) {
$this->markTestSkipped('mysqli is not installed.');
}
parent::setUp();
- if (! $this->_conn->getDatabasePlatform() instanceof MySqlPlatform) {
+ if (! $this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
$this->markTestSkipped('MySQL only test.');
}
@@ -43,7 +44,9 @@ public function testDoesNotRequireQueryForServerVersion()
public function testRestoresErrorHandlerOnException()
{
- $handler = function () { self::fail('Never expected this to be called'); };
+ $handler = static function () {
+ self::fail('Never expected this to be called');
+ };
$default_handler = set_error_handler($handler);
try {
diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php
index 864b1a643d5..0628738400e 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php
@@ -2,7 +2,9 @@
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;
class OCI8ConnectionTest extends DbalTestCase
@@ -10,19 +12,19 @@ class OCI8ConnectionTest extends DbalTestCase
/**
* The oci8 driver connection mock under test.
*
- * @var \Doctrine\DBAL\Driver\OCI8\OCI8Connection|\PHPUnit_Framework_MockObject_MockObject
+ * @var OCI8Connection|PHPUnit_Framework_MockObject_MockObject
*/
private $connectionMock;
protected function setUp()
{
- if ( ! extension_loaded('oci8')) {
+ if (! extension_loaded('oci8')) {
$this->markTestSkipped('oci8 is not installed.');
}
parent::setUp();
- $this->connectionMock = $this->getMockBuilder('Doctrine\DBAL\Driver\OCI8\OCI8Connection')
+ $this->connectionMock = $this->getMockBuilder(OCI8Connection::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php
index 65a3c95ce36..b51f3bf2f5b 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php
@@ -2,16 +2,18 @@
namespace Doctrine\Tests\DBAL\Driver\OCI8;
+use Doctrine\DBAL\Driver\OCI8\OCI8Connection;
use Doctrine\DBAL\Driver\OCI8\OCI8Exception;
use Doctrine\DBAL\Driver\OCI8\OCI8Statement;
use Doctrine\Tests\DbalTestCase;
+use ReflectionProperty;
use function extension_loaded;
class OCI8StatementTest extends DbalTestCase
{
protected function setUp()
{
- if (!extension_loaded('oci8')) {
+ if (! extension_loaded('oci8')) {
$this->markTestSkipped('oci8 is not installed.');
}
@@ -27,13 +29,15 @@ protected function setUp()
*
* The expected exception is due to oci_execute failing due to no valid connection.
*
+ * @param mixed[] $params
+ *
* @dataProvider executeDataProvider
* @expectedException \Doctrine\DBAL\Driver\OCI8\OCI8Exception
*/
public function testExecute(array $params)
{
- $statement = $this->getMockBuilder('\Doctrine\DBAL\Driver\OCI8\OCI8Statement')
- ->setMethods(array('bindValue', 'errorInfo'))
+ $statement = $this->getMockBuilder(OCI8Statement::class)
+ ->setMethods(['bindValue', 'errorInfo'])
->disableOriginalConstructor()
->getMock();
@@ -54,18 +58,18 @@ public function testExecute(array $params)
->with(
$this->equalTo(3),
$this->equalTo($params[2])
- );
+ );
// can't pass to constructor since we don't have a real database handle,
// but execute must check the connection for the executeMode
- $conn = $this->getMockBuilder('\Doctrine\DBAL\Driver\OCI8\OCI8Connection')
- ->setMethods(array('getExecuteMode'))
+ $conn = $this->getMockBuilder(OCI8Connection::class)
+ ->setMethods(['getExecuteMode'])
->disableOriginalConstructor()
->getMock();
$conn->expects($this->once())
->method('getExecuteMode');
- $reflProperty = new \ReflectionProperty($statement, '_conn');
+ $reflProperty = new ReflectionProperty($statement, '_conn');
$reflProperty->setAccessible(true);
$reflProperty->setValue($statement, $conn);
@@ -74,16 +78,16 @@ public function testExecute(array $params)
public static function executeDataProvider()
{
- return array(
+ return [
// $hasZeroIndex = isset($params[0]); == true
- array(
- array(0 => 'test', 1 => null, 2 => 'value')
- ),
+ [
+ [0 => 'test', 1 => null, 2 => 'value'],
+ ],
// $hasZeroIndex = isset($params[0]); == false
- array(
- array(0 => null, 1 => 'test', 2 => 'value')
- )
- );
+ [
+ [0 => null, 1 => 'test', 2 => 'value'],
+ ],
+ ];
}
/**
@@ -98,19 +102,19 @@ public function testConvertNonTerminatedLiteral($sql, $message)
public static function nonTerminatedLiteralProvider()
{
- return array(
- 'no-matching-quote' => array(
+ return [
+ 'no-matching-quote' => [
"SELECT 'literal FROM DUAL",
'/offset 7/',
- ),
- 'no-matching-double-quote' => array(
+ ],
+ 'no-matching-double-quote' => [
'SELECT 1 "COL1 FROM DUAL',
'/offset 9/',
- ),
- 'incorrect-escaping-syntax' => array(
+ ],
+ 'incorrect-escaping-syntax' => [
"SELECT 'quoted \\'string' FROM DUAL",
'/offset 23/',
- ),
- );
+ ],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php
index 96691bacd9c..593f04d203c 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php
@@ -4,33 +4,34 @@
use Doctrine\DBAL\Driver\PDOException;
use Doctrine\Tests\DbalTestCase;
+use PHPUnit_Framework_MockObject_MockObject;
use function extension_loaded;
class PDOExceptionTest extends DbalTestCase
{
- const ERROR_CODE = 666;
+ public const ERROR_CODE = 666;
- const MESSAGE = 'PDO Exception';
+ public const MESSAGE = 'PDO Exception';
- const SQLSTATE = 28000;
+ public const SQLSTATE = 28000;
/**
* The PDO exception wrapper under test.
*
- * @var \Doctrine\DBAL\Driver\PDOException
+ * @var PDOException
*/
private $exception;
/**
* The wrapped PDO exception mock.
*
- * @var \PDOException|\PHPUnit_Framework_MockObject_MockObject
+ * @var \PDOException|PHPUnit_Framework_MockObject_MockObject
*/
private $wrappedException;
protected function setUp()
{
- if ( ! extension_loaded('PDO')) {
+ if (! extension_loaded('PDO')) {
$this->markTestSkipped('PDO is not installed.');
}
@@ -38,7 +39,7 @@ protected function setUp()
$this->wrappedException = new \PDOException(self::MESSAGE, self::SQLSTATE);
- $this->wrappedException->errorInfo = array(self::SQLSTATE, self::ERROR_CODE);
+ $this->wrappedException->errorInfo = [self::SQLSTATE, self::ERROR_CODE];
$this->exception = new PDOException($this->wrappedException);
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php
index 6fd187e3d28..a6ac2456b64 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php
@@ -2,10 +2,12 @@
namespace Doctrine\Tests\DBAL\Driver\PDOPgSql;
+use Doctrine\DBAL\Driver\PDOConnection;
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
@@ -23,15 +25,15 @@ public function testConnectionDisablesPreparesOnPhp56()
$this->skipWhenNotUsingPhp56AndPdoPgsql();
$connection = $this->createDriver()->connect(
- array(
+ [
'host' => $GLOBALS['db_host'],
- 'port' => $GLOBALS['db_port']
- ),
+ 'port' => $GLOBALS['db_port'],
+ ],
$GLOBALS['db_username'],
$GLOBALS['db_password']
);
- self::assertInstanceOf('Doctrine\DBAL\Driver\PDOConnection', $connection);
+ self::assertInstanceOf(PDOConnection::class, $connection);
try {
self::assertTrue($connection->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES));
@@ -49,16 +51,16 @@ public function testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined(
$this->skipWhenNotUsingPhp56AndPdoPgsql();
$connection = $this->createDriver()->connect(
- array(
+ [
'host' => $GLOBALS['db_host'],
- 'port' => $GLOBALS['db_port']
- ),
+ 'port' => $GLOBALS['db_port'],
+ ],
$GLOBALS['db_username'],
$GLOBALS['db_password'],
- array(PDO::PGSQL_ATTR_DISABLE_PREPARES => false)
+ [PDO::PGSQL_ATTR_DISABLE_PREPARES => false]
);
- self::assertInstanceOf('Doctrine\DBAL\Driver\PDOConnection', $connection);
+ self::assertInstanceOf(PDOConnection::class, $connection);
try {
self::assertNotSame(true, $connection->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES));
@@ -76,16 +78,16 @@ public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplici
$this->skipWhenNotUsingPhp56AndPdoPgsql();
$connection = $this->createDriver()->connect(
- array(
+ [
'host' => $GLOBALS['db_host'],
- 'port' => $GLOBALS['db_port']
- ),
+ 'port' => $GLOBALS['db_port'],
+ ],
$GLOBALS['db_username'],
$GLOBALS['db_password'],
- array(PDO::PGSQL_ATTR_DISABLE_PREPARES => true)
+ [PDO::PGSQL_ATTR_DISABLE_PREPARES => true]
);
- self::assertInstanceOf('Doctrine\DBAL\Driver\PDOConnection', $connection);
+ self::assertInstanceOf(PDOConnection::class, $connection);
try {
self::assertTrue($connection->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES));
@@ -104,7 +106,7 @@ protected function createDriver()
}
/**
- * @throws \PHPUnit_Framework_SkippedTestError
+ * @throws PHPUnit_Framework_SkippedTestError
*/
private function skipWhenNotUsingPhp56AndPdoPgsql()
{
@@ -112,8 +114,10 @@ private function skipWhenNotUsingPhp56AndPdoPgsql()
$this->markTestSkipped('Test requires PHP 5.6+');
}
- if (! (isset($GLOBALS['db_type']) && $GLOBALS['db_type'] === 'pdo_pgsql')) {
- $this->markTestSkipped('Test enabled only when using pdo_pgsql specific phpunit.xml');
+ if (isset($GLOBALS['db_type']) && $GLOBALS['db_type'] === 'pdo_pgsql') {
+ return;
}
+
+ $this->markTestSkipped('Test enabled only when using pdo_pgsql specific phpunit.xml');
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php
index 273c2de1b85..d70d36396ba 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php
@@ -2,7 +2,9 @@
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;
class SQLAnywhereConnectionTest extends DbalTestCase
@@ -10,19 +12,19 @@ class SQLAnywhereConnectionTest extends DbalTestCase
/**
* The sqlanywhere driver connection mock under test.
*
- * @var \Doctrine\DBAL\Driver\SQLAnywhere\SQLAnywhereConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var SQLAnywhereConnection|PHPUnit_Framework_MockObject_MockObject
*/
private $connectionMock;
protected function setUp()
{
- if ( ! extension_loaded('sqlanywhere')) {
+ if (! extension_loaded('sqlanywhere')) {
$this->markTestSkipped('sqlanywhere is not installed.');
}
parent::setUp();
- $this->connectionMock = $this->getMockBuilder('Doctrine\DBAL\Driver\SQLAnywhere\SQLAnywhereConnection')
+ $this->connectionMock = $this->getMockBuilder(SQLAnywhereConnection::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php
index 089d2b11085..b0e32708428 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php
@@ -2,7 +2,9 @@
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
@@ -10,19 +12,19 @@ class SQLSrvConnectionTest extends DbalTestCase
/**
* The sqlsrv driver connection mock under test.
*
- * @var \Doctrine\DBAL\Driver\SQLSrv\SQLSrvConnection|\PHPUnit_Framework_MockObject_MockObject
+ * @var SQLSrvConnection|PHPUnit_Framework_MockObject_MockObject
*/
private $connectionMock;
protected function setUp()
{
- if ( ! extension_loaded('sqlsrv')) {
+ if (! extension_loaded('sqlsrv')) {
$this->markTestSkipped('sqlsrv is not installed.');
}
parent::setUp();
- $this->connectionMock = $this->getMockBuilder('Doctrine\DBAL\Driver\SQLSrv\SQLSrvConnection')
+ $this->connectionMock = $this->getMockBuilder(SQLSrvConnection::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
}
diff --git a/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php b/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php
index 95f107cf921..90244cd2ac8 100644
--- a/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php
+++ b/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php
@@ -10,12 +10,13 @@
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Driver\StatementIterator;
use Doctrine\DBAL\Portability\Statement as PortabilityStatement;
+use Doctrine\Tests\DbalTestCase;
use IteratorAggregate;
use PHPUnit\Framework\MockObject\MockObject;
use Traversable;
use function extension_loaded;
-class StatementIteratorTest extends \Doctrine\Tests\DbalTestCase
+class StatementIteratorTest extends DbalTestCase
{
/**
* @dataProvider statementProvider()
@@ -58,11 +59,11 @@ public function testStatementIterationCallsFetchOncePerStep(string $class) : voi
private function configureStatement(MockObject $stmt, int &$calls) : void
{
$values = ['foo', '', 'bar', '0', 'baz', 0, 'qux', null, 'quz', false, 'impossible'];
- $calls = 0;
+ $calls = 0;
$stmt->expects($this->exactly(10))
->method('fetch')
- ->willReturnCallback(function() use ($values, &$calls) {
+ ->willReturnCallback(static function () use ($values, &$calls) {
$value = $values[$calls];
$calls++;
diff --git a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php
index 7e7c5b0153a..e5520afcf1e 100644
--- a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php
@@ -15,6 +15,7 @@
use Doctrine\Tests\DbalTestCase;
use Doctrine\Tests\Mocks\ConnectionMock;
use Doctrine\Tests\Mocks\DriverMock;
+use PDO;
use stdClass;
use function extension_loaded;
use function in_array;
@@ -37,7 +38,7 @@ public function testInvalidPdoInstance()
public function testValidPdoInstance()
{
$conn = DriverManager::getConnection([
- 'pdo' => new \PDO('sqlite::memory:'),
+ 'pdo' => new PDO('sqlite::memory:'),
]);
self::assertEquals('sqlite', $conn->getDatabasePlatform()->getName());
@@ -49,12 +50,12 @@ public function testValidPdoInstance()
*/
public function testPdoInstanceSetErrorMode()
{
- $pdo = new \PDO('sqlite::memory:');
- $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);
+ $pdo = new PDO('sqlite::memory:');
+ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$options = ['pdo' => $pdo];
DriverManager::getConnection($options);
- self::assertEquals(\PDO::ERRMODE_EXCEPTION, $pdo->getAttribute(\PDO::ATTR_ERRMODE));
+ self::assertEquals(PDO::ERRMODE_EXCEPTION, $pdo->getAttribute(PDO::ATTR_ERRMODE));
}
/**
@@ -80,7 +81,7 @@ public function testCustomPlatform()
{
$mockPlatform = new MockPlatform();
$options = [
- 'pdo' => new \PDO('sqlite::memory:'),
+ 'pdo' => new PDO('sqlite::memory:'),
'platform' => $mockPlatform,
];
@@ -96,7 +97,7 @@ public function testCustomWrapper()
$wrapperClass = ConnectionMock::class;
$options = [
- 'pdo' => new \PDO('sqlite::memory:'),
+ 'pdo' => new PDO('sqlite::memory:'),
'wrapperClass' => $wrapperClass,
];
@@ -112,7 +113,7 @@ public function testInvalidWrapperClass()
$this->expectException(DBALException::class);
$options = [
- 'pdo' => new \PDO('sqlite::memory:'),
+ 'pdo' => new PDO('sqlite::memory:'),
'wrapperClass' => stdClass::class,
];
@@ -216,7 +217,7 @@ public function testDatabaseUrl($url, $expected)
$this->markTestSkipped('PDO is not installed');
}
- $options['pdo'] = $this->createMock(\PDO::class);
+ $options['pdo'] = $this->createMock(PDO::class);
}
$options = is_array($url) ? $url : ['url' => $url];
diff --git a/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php
index 2a19d2c5fee..0f9be11edda 100644
--- a/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php
+++ b/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php
@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Events;
+use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Event\Listeners\MysqlSessionInit;
use Doctrine\DBAL\Events;
@@ -11,14 +12,13 @@ class MysqlSessionInitTest extends DbalTestCase
{
public function testPostConnect()
{
- $connectionMock = $this->createMock('Doctrine\DBAL\Connection');
+ $connectionMock = $this->createMock(Connection::class);
$connectionMock->expects($this->once())
->method('executeUpdate')
- ->with($this->equalTo("SET NAMES foo COLLATE bar"));
+ ->with($this->equalTo('SET NAMES foo COLLATE bar'));
$eventArgs = new ConnectionEventArgs($connectionMock);
-
$listener = new MysqlSessionInit('foo', 'bar');
$listener->postConnect($eventArgs);
}
@@ -26,6 +26,6 @@ public function testPostConnect()
public function testGetSubscribedEvents()
{
$listener = new MysqlSessionInit();
- self::assertEquals(array(Events::postConnect), $listener->getSubscribedEvents());
+ self::assertEquals([Events::postConnect], $listener->getSubscribedEvents());
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php
index 4ec3545c002..2ea510a0543 100644
--- a/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php
+++ b/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php
@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Events;
+use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Event\Listeners\OracleSessionInit;
use Doctrine\DBAL\Events;
@@ -12,26 +13,24 @@ class OracleSessionInitTest extends DbalTestCase
{
public function testPostConnect()
{
- $connectionMock = $this->createMock('Doctrine\DBAL\Connection');
+ $connectionMock = $this->createMock(Connection::class);
$connectionMock->expects($this->once())
->method('executeUpdate')
->with($this->isType('string'));
$eventArgs = new ConnectionEventArgs($connectionMock);
-
$listener = new OracleSessionInit();
$listener->postConnect($eventArgs);
}
/**
* @group DBAL-1824
- *
* @dataProvider getPostConnectWithSessionParameterValuesData
*/
public function testPostConnectQuotesSessionParameterValues($name, $value)
{
- $connectionMock = $this->getMockBuilder('Doctrine\DBAL\Connection')
+ $connectionMock = $this->getMockBuilder(Connection::class)
->disableOriginalConstructor()
->getMock();
$connectionMock->expects($this->once())
@@ -40,21 +39,20 @@ public function testPostConnectQuotesSessionParameterValues($name, $value)
$eventArgs = new ConnectionEventArgs($connectionMock);
-
- $listener = new OracleSessionInit(array($name => $value));
+ $listener = new OracleSessionInit([$name => $value]);
$listener->postConnect($eventArgs);
}
public function getPostConnectWithSessionParameterValuesData()
{
- return array(
- array('CURRENT_SCHEMA', 'foo'),
- );
+ return [
+ ['CURRENT_SCHEMA', 'foo'],
+ ];
}
public function testGetSubscribedEvents()
{
$listener = new OracleSessionInit();
- self::assertEquals(array(Events::postConnect), $listener->getSubscribedEvents());
+ self::assertEquals([Events::postConnect], $listener->getSubscribedEvents());
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php
index 2b25301da98..f42458de74d 100644
--- a/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php
+++ b/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php
@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Events;
+use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Event\Listeners\SQLSessionInit;
use Doctrine\DBAL\Events;
@@ -14,7 +15,7 @@ class SQLSessionInitTest extends DbalTestCase
{
public function testPostConnect()
{
- $connectionMock = $this->createMock('Doctrine\DBAL\Connection');
+ $connectionMock = $this->createMock(Connection::class);
$connectionMock->expects($this->once())
->method('exec')
->with($this->equalTo("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'"));
@@ -28,6 +29,6 @@ public function testPostConnect()
public function testGetSubscribedEvents()
{
$listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'");
- self::assertEquals(array(Events::postConnect), $listener->getSubscribedEvents());
+ self::assertEquals([Events::postConnect], $listener->getSubscribedEvents());
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php b/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php
index 9984e3d0223..54cfea89596 100644
--- a/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php
@@ -1,40 +1,22 @@
.
- */
namespace Doctrine\Tests\DBAL\Exception;
use Doctrine\DBAL\Exception\InvalidArgumentException;
+use PHPUnit\Framework\TestCase;
/**
* Tests for {@see \Doctrine\DBAL\Exception\InvalidArgumentException}
*
* @covers \Doctrine\DBAL\Exception\InvalidArgumentException
- *
- * @author Marco Pivetta
*/
-class InvalidArgumentExceptionTest extends \PHPUnit\Framework\TestCase
+class InvalidArgumentExceptionTest extends TestCase
{
public function testFromEmptyCriteria()
{
$exception = InvalidArgumentException::fromEmptyCriteria();
- self::assertInstanceOf('Doctrine\DBAL\Exception\InvalidArgumentException', $exception);
+ self::assertInstanceOf(InvalidArgumentException::class, $exception);
self::assertSame('Empty criteria was used, expected non-empty criteria', $exception->getMessage());
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php b/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php
index e409f5f5f5e..779f33254b5 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php
@@ -5,8 +5,10 @@
use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSrvDriver;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType;
+use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
+use Doctrine\Tests\DbalFunctionalTestCase;
use function fopen;
use function in_array;
use function str_repeat;
@@ -15,30 +17,30 @@
/**
* @group DBAL-6
*/
-class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase
+class BlobTest extends DbalFunctionalTestCase
{
protected function setUp()
{
parent::setUp();
- if ($this->_conn->getDriver() instanceof PDOSQLSrvDriver) {
+ if ($this->connection->getDriver() instanceof PDOSQLSrvDriver) {
$this->markTestSkipped('This test does not work on pdo_sqlsrv driver due to a bug. See: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/5a755bdd-41e9-45cb-9166-c9da4475bb94/how-to-set-null-for-varbinarymax-using-bindvalue-using-pdosqlsrv?forum=sqldriverforphp');
}
- /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
+ /** @var AbstractSchemaManager $sm */
$table = new Table('blob_table');
$table->addColumn('id', 'integer');
$table->addColumn('clobfield', 'text');
$table->addColumn('blobfield', 'blob');
$table->setPrimaryKey(['id']);
- $sm = $this->_conn->getSchemaManager();
+ $sm = $this->connection->getSchemaManager();
$sm->dropAndCreateTable($table);
}
public function testInsert()
{
- $ret = $this->_conn->insert('blob_table', [
+ $ret = $this->connection->insert('blob_table', [
'id' => 1,
'clobfield' => 'test',
'blobfield' => 'test',
@@ -53,14 +55,14 @@ public function testInsert()
public function testInsertProcessesStream()
{
- if (in_array($this->_conn->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
+ if (in_array($this->connection->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
// https://github.com/doctrine/dbal/issues/3288 for DB2
// https://github.com/doctrine/dbal/issues/3290 for Oracle
$this->markTestIncomplete('Platform does not support stream resources as parameters');
}
$longBlob = str_repeat('x', 4 * 8192); // send 4 chunks
- $this->_conn->insert('blob_table', [
+ $this->connection->insert('blob_table', [
'id' => 1,
'clobfield' => 'ignored',
'blobfield' => fopen('data://text/plain,' . $longBlob, 'r'),
@@ -75,7 +77,7 @@ public function testInsertProcessesStream()
public function testSelect()
{
- $this->_conn->insert('blob_table', [
+ $this->connection->insert('blob_table', [
'id' => 1,
'clobfield' => 'test',
'blobfield' => 'test',
@@ -90,7 +92,7 @@ public function testSelect()
public function testUpdate()
{
- $this->_conn->insert('blob_table', [
+ $this->connection->insert('blob_table', [
'id' => 1,
'clobfield' => 'test',
'blobfield' => 'test',
@@ -100,9 +102,7 @@ public function testUpdate()
ParameterType::LARGE_OBJECT,
]);
- $this->_conn->update('blob_table', [
- 'blobfield' => 'test2',
- ], ['id' => 1], [
+ $this->connection->update('blob_table', ['blobfield' => 'test2'], ['id' => 1], [
ParameterType::LARGE_OBJECT,
ParameterType::INTEGER,
]);
@@ -112,13 +112,13 @@ public function testUpdate()
public function testUpdateProcessesStream()
{
- if (in_array($this->_conn->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
+ if (in_array($this->connection->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
// https://github.com/doctrine/dbal/issues/3288 for DB2
// https://github.com/doctrine/dbal/issues/3290 for Oracle
$this->markTestIncomplete('Platform does not support stream resources as parameters');
}
- $this->_conn->insert('blob_table', [
+ $this->connection->insert('blob_table', [
'id' => 1,
'clobfield' => 'ignored',
'blobfield' => 'test',
@@ -128,7 +128,7 @@ public function testUpdateProcessesStream()
ParameterType::LARGE_OBJECT,
]);
- $this->_conn->update('blob_table', [
+ $this->connection->update('blob_table', [
'id' => 1,
'blobfield' => fopen('data://text/plain,test2', 'r'),
], ['id' => 1], [
@@ -141,13 +141,13 @@ public function testUpdateProcessesStream()
public function testBindParamProcessesStream()
{
- if (in_array($this->_conn->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
+ if (in_array($this->connection->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
// https://github.com/doctrine/dbal/issues/3288 for DB2
// https://github.com/doctrine/dbal/issues/3290 for Oracle
$this->markTestIncomplete('Platform does not support stream resources as parameters');
}
- $stmt = $this->_conn->prepare("INSERT INTO blob_table(id, clobfield, blobfield) VALUES (1, 'ignored', ?)");
+ $stmt = $this->connection->prepare("INSERT INTO blob_table(id, clobfield, blobfield) VALUES (1, 'ignored', ?)");
$stream = null;
$stmt->bindParam(1, $stream, ParameterType::LARGE_OBJECT);
@@ -162,11 +162,11 @@ public function testBindParamProcessesStream()
private function assertBlobContains($text)
{
- $rows = $this->_conn->query('SELECT blobfield FROM blob_table')->fetchAll(FetchMode::COLUMN);
+ $rows = $this->connection->query('SELECT blobfield FROM blob_table')->fetchAll(FetchMode::COLUMN);
self::assertCount(1, $rows);
- $blobValue = Type::getType('blob')->convertToPHPValue($rows[0], $this->_conn->getDatabasePlatform());
+ $blobValue = Type::getType('blob')->convertToPHPValue($rows[0], $this->connection->getDatabasePlatform());
self::assertInternalType('resource', $blobValue);
self::assertEquals($text, stream_get_contents($blobValue));
diff --git a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
index 0c9d57895aa..b9d03d5e66c 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
@@ -2,14 +2,21 @@
namespace Doctrine\Tests\DBAL\Functional;
+use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ConnectionException;
+use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
+use Doctrine\Tests\DbalFunctionalTestCase;
+use Error;
+use Exception;
+use RuntimeException;
+use Throwable;
use function in_array;
-class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
+class ConnectionTest extends DbalFunctionalTestCase
{
protected function setUp()
{
@@ -25,205 +32,205 @@ protected function tearDown()
public function testGetWrappedConnection()
{
- self::assertInstanceOf('Doctrine\DBAL\Driver\Connection', $this->_conn->getWrappedConnection());
+ self::assertInstanceOf(DriverConnection::class, $this->connection->getWrappedConnection());
}
public function testCommitWithRollbackOnlyThrowsException()
{
- $this->_conn->beginTransaction();
- $this->_conn->setRollbackOnly();
+ $this->connection->beginTransaction();
+ $this->connection->setRollbackOnly();
$this->expectException(ConnectionException::class);
- $this->_conn->commit();
+ $this->connection->commit();
}
public function testTransactionNestingBehavior()
{
try {
- $this->_conn->beginTransaction();
- self::assertEquals(1, $this->_conn->getTransactionNestingLevel());
+ $this->connection->beginTransaction();
+ self::assertEquals(1, $this->connection->getTransactionNestingLevel());
try {
- $this->_conn->beginTransaction();
- self::assertEquals(2, $this->_conn->getTransactionNestingLevel());
- throw new \Exception;
- $this->_conn->commit(); // never reached
- } catch (\Exception $e) {
- $this->_conn->rollBack();
- self::assertEquals(1, $this->_conn->getTransactionNestingLevel());
+ $this->connection->beginTransaction();
+ self::assertEquals(2, $this->connection->getTransactionNestingLevel());
+ throw new Exception();
+ $this->connection->commit(); // never reached
+ } catch (Throwable $e) {
+ $this->connection->rollBack();
+ self::assertEquals(1, $this->connection->getTransactionNestingLevel());
//no rethrow
}
- self::assertTrue($this->_conn->isRollbackOnly());
+ self::assertTrue($this->connection->isRollbackOnly());
- $this->_conn->commit(); // should throw exception
+ $this->connection->commit(); // should throw exception
$this->fail('Transaction commit after failed nested transaction should fail.');
} catch (ConnectionException $e) {
- self::assertEquals(1, $this->_conn->getTransactionNestingLevel());
- $this->_conn->rollBack();
- self::assertEquals(0, $this->_conn->getTransactionNestingLevel());
+ self::assertEquals(1, $this->connection->getTransactionNestingLevel());
+ $this->connection->rollBack();
+ self::assertEquals(0, $this->connection->getTransactionNestingLevel());
}
}
public function testTransactionNestingBehaviorWithSavepoints()
{
- if (!$this->_conn->getDatabasePlatform()->supportsSavepoints()) {
+ if (! $this->connection->getDatabasePlatform()->supportsSavepoints()) {
$this->markTestSkipped('This test requires the platform to support savepoints.');
}
- $this->_conn->setNestTransactionsWithSavepoints(true);
+ $this->connection->setNestTransactionsWithSavepoints(true);
try {
- $this->_conn->beginTransaction();
- self::assertEquals(1, $this->_conn->getTransactionNestingLevel());
+ $this->connection->beginTransaction();
+ self::assertEquals(1, $this->connection->getTransactionNestingLevel());
try {
- $this->_conn->beginTransaction();
- self::assertEquals(2, $this->_conn->getTransactionNestingLevel());
- $this->_conn->beginTransaction();
- self::assertEquals(3, $this->_conn->getTransactionNestingLevel());
- $this->_conn->commit();
- self::assertEquals(2, $this->_conn->getTransactionNestingLevel());
- throw new \Exception;
- $this->_conn->commit(); // never reached
- } catch (\Exception $e) {
- $this->_conn->rollBack();
- self::assertEquals(1, $this->_conn->getTransactionNestingLevel());
+ $this->connection->beginTransaction();
+ self::assertEquals(2, $this->connection->getTransactionNestingLevel());
+ $this->connection->beginTransaction();
+ self::assertEquals(3, $this->connection->getTransactionNestingLevel());
+ $this->connection->commit();
+ self::assertEquals(2, $this->connection->getTransactionNestingLevel());
+ throw new Exception();
+ $this->connection->commit(); // never reached
+ } catch (Throwable $e) {
+ $this->connection->rollBack();
+ self::assertEquals(1, $this->connection->getTransactionNestingLevel());
//no rethrow
}
- self::assertFalse($this->_conn->isRollbackOnly());
+ self::assertFalse($this->connection->isRollbackOnly());
try {
- $this->_conn->setNestTransactionsWithSavepoints(false);
+ $this->connection->setNestTransactionsWithSavepoints(false);
$this->fail('Should not be able to disable savepoints in usage for nested transactions inside an open transaction.');
} catch (ConnectionException $e) {
- self::assertTrue($this->_conn->getNestTransactionsWithSavepoints());
+ self::assertTrue($this->connection->getNestTransactionsWithSavepoints());
}
- $this->_conn->commit(); // should not throw exception
+ $this->connection->commit(); // should not throw exception
} catch (ConnectionException $e) {
$this->fail('Transaction commit after failed nested transaction should not fail when using savepoints.');
- $this->_conn->rollBack();
+ $this->connection->rollBack();
}
}
public function testTransactionNestingBehaviorCantBeChangedInActiveTransaction()
{
- if (!$this->_conn->getDatabasePlatform()->supportsSavepoints()) {
+ if (! $this->connection->getDatabasePlatform()->supportsSavepoints()) {
$this->markTestSkipped('This test requires the platform to support savepoints.');
}
- $this->_conn->beginTransaction();
+ $this->connection->beginTransaction();
$this->expectException(ConnectionException::class);
- $this->_conn->setNestTransactionsWithSavepoints(true);
+ $this->connection->setNestTransactionsWithSavepoints(true);
}
public function testSetNestedTransactionsThroughSavepointsNotSupportedThrowsException()
{
- if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) {
+ if ($this->connection->getDatabasePlatform()->supportsSavepoints()) {
$this->markTestSkipped('This test requires the platform not to support savepoints.');
}
$this->expectException(ConnectionException::class);
- $this->expectExceptionMessage("Savepoints are not supported by this driver.");
+ $this->expectExceptionMessage('Savepoints are not supported by this driver.');
- $this->_conn->setNestTransactionsWithSavepoints(true);
+ $this->connection->setNestTransactionsWithSavepoints(true);
}
public function testCreateSavepointsNotSupportedThrowsException()
{
- if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) {
+ if ($this->connection->getDatabasePlatform()->supportsSavepoints()) {
$this->markTestSkipped('This test requires the platform not to support savepoints.');
}
$this->expectException(ConnectionException::class);
- $this->expectExceptionMessage("Savepoints are not supported by this driver.");
+ $this->expectExceptionMessage('Savepoints are not supported by this driver.');
- $this->_conn->createSavepoint('foo');
+ $this->connection->createSavepoint('foo');
}
public function testReleaseSavepointsNotSupportedThrowsException()
{
- if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) {
+ if ($this->connection->getDatabasePlatform()->supportsSavepoints()) {
$this->markTestSkipped('This test requires the platform not to support savepoints.');
}
$this->expectException(ConnectionException::class);
- $this->expectExceptionMessage("Savepoints are not supported by this driver.");
+ $this->expectExceptionMessage('Savepoints are not supported by this driver.');
- $this->_conn->releaseSavepoint('foo');
+ $this->connection->releaseSavepoint('foo');
}
public function testRollbackSavepointsNotSupportedThrowsException()
{
- if ($this->_conn->getDatabasePlatform()->supportsSavepoints()) {
+ if ($this->connection->getDatabasePlatform()->supportsSavepoints()) {
$this->markTestSkipped('This test requires the platform not to support savepoints.');
}
$this->expectException(ConnectionException::class);
- $this->expectExceptionMessage("Savepoints are not supported by this driver.");
+ $this->expectExceptionMessage('Savepoints are not supported by this driver.');
- $this->_conn->rollbackSavepoint('foo');
+ $this->connection->rollbackSavepoint('foo');
}
public function testTransactionBehaviorWithRollback()
{
try {
- $this->_conn->beginTransaction();
- self::assertEquals(1, $this->_conn->getTransactionNestingLevel());
+ $this->connection->beginTransaction();
+ self::assertEquals(1, $this->connection->getTransactionNestingLevel());
- throw new \Exception;
+ throw new Exception();
- $this->_conn->commit(); // never reached
- } catch (\Exception $e) {
- self::assertEquals(1, $this->_conn->getTransactionNestingLevel());
- $this->_conn->rollBack();
- self::assertEquals(0, $this->_conn->getTransactionNestingLevel());
+ $this->connection->commit(); // never reached
+ } catch (Throwable $e) {
+ self::assertEquals(1, $this->connection->getTransactionNestingLevel());
+ $this->connection->rollBack();
+ self::assertEquals(0, $this->connection->getTransactionNestingLevel());
}
}
public function testTransactionBehaviour()
{
try {
- $this->_conn->beginTransaction();
- self::assertEquals(1, $this->_conn->getTransactionNestingLevel());
- $this->_conn->commit();
- } catch (\Exception $e) {
- $this->_conn->rollBack();
- self::assertEquals(0, $this->_conn->getTransactionNestingLevel());
+ $this->connection->beginTransaction();
+ self::assertEquals(1, $this->connection->getTransactionNestingLevel());
+ $this->connection->commit();
+ } catch (Throwable $e) {
+ $this->connection->rollBack();
+ self::assertEquals(0, $this->connection->getTransactionNestingLevel());
}
- self::assertEquals(0, $this->_conn->getTransactionNestingLevel());
+ self::assertEquals(0, $this->connection->getTransactionNestingLevel());
}
public function testTransactionalWithException()
{
try {
- $this->_conn->transactional(function($conn) {
- /* @var $conn \Doctrine\DBAL\Connection */
+ $this->connection->transactional(static function ($conn) {
+ /** @var Connection $conn */
$conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL());
- throw new \RuntimeException("Ooops!");
+ throw new RuntimeException('Ooops!');
});
$this->fail('Expected exception');
- } catch (\RuntimeException $expected) {
- self::assertEquals(0, $this->_conn->getTransactionNestingLevel());
+ } catch (RuntimeException $expected) {
+ self::assertEquals(0, $this->connection->getTransactionNestingLevel());
}
}
public function testTransactionalWithThrowable()
{
try {
- $this->_conn->transactional(function($conn) {
- /* @var $conn \Doctrine\DBAL\Connection */
+ $this->connection->transactional(static function ($conn) {
+ /** @var Connection $conn */
$conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL());
- throw new \Error("Ooops!");
+ throw new Error('Ooops!');
});
$this->fail('Expected exception');
- } catch (\Error $expected) {
- self::assertEquals(0, $this->_conn->getTransactionNestingLevel());
+ } catch (Error $expected) {
+ self::assertEquals(0, $this->connection->getTransactionNestingLevel());
}
}
public function testTransactional()
{
- $res = $this->_conn->transactional(function($conn) {
- /* @var $conn \Doctrine\DBAL\Connection */
+ $res = $this->connection->transactional(static function ($conn) {
+ /** @var Connection $conn */
$conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL());
});
@@ -232,7 +239,7 @@ public function testTransactional()
public function testTransactionalReturnValue()
{
- $res = $this->_conn->transactional(function() {
+ $res = $this->connection->transactional(static function () {
return 42;
});
@@ -245,15 +252,15 @@ public function testTransactionalReturnValue()
public function testQuote()
{
self::assertEquals(
- $this->_conn->quote('foo', Type::STRING),
- $this->_conn->quote('foo', ParameterType::STRING)
+ $this->connection->quote('foo', Type::STRING),
+ $this->connection->quote('foo', ParameterType::STRING)
);
}
public function testPingDoesTriggersConnect()
{
- self::assertTrue($this->_conn->ping());
- self::assertTrue($this->_conn->isConnected());
+ self::assertTrue($this->connection->ping());
+ self::assertTrue($this->connection->isConnected());
}
/**
@@ -261,17 +268,17 @@ public function testPingDoesTriggersConnect()
*/
public function testConnectWithoutExplicitDatabaseName()
{
- if (in_array($this->_conn->getDatabasePlatform()->getName(), array('oracle', 'db2'), true)) {
+ if (in_array($this->connection->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
$this->markTestSkipped('Platform does not support connecting without database name.');
}
- $params = $this->_conn->getParams();
+ $params = $this->connection->getParams();
unset($params['dbname']);
$connection = DriverManager::getConnection(
$params,
- $this->_conn->getConfiguration(),
- $this->_conn->getEventManager()
+ $this->connection->getConfiguration(),
+ $this->connection->getEventManager()
);
self::assertTrue($connection->connect());
@@ -284,17 +291,18 @@ public function testConnectWithoutExplicitDatabaseName()
*/
public function testDeterminesDatabasePlatformWhenConnectingToNonExistentDatabase()
{
- if (in_array($this->_conn->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
+ if (in_array($this->connection->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
$this->markTestSkipped('Platform does not support connecting without database name.');
}
- $params = $this->_conn->getParams();
+ $params = $this->connection->getParams();
+
$params['dbname'] = 'foo_bar';
$connection = DriverManager::getConnection(
$params,
- $this->_conn->getConfiguration(),
- $this->_conn->getEventManager()
+ $this->connection->getConfiguration(),
+ $this->connection->getEventManager()
);
self::assertInstanceOf(AbstractPlatform::class, $connection->getDatabasePlatform());
diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
index f63e397c65b..9f6fcbfd75b 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
@@ -2,13 +2,19 @@
namespace Doctrine\Tests\DBAL\Functional;
+use DateTime;
use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver\Mysqli\Driver as MySQLiDriver;
+use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Platforms\TrimMode;
+use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Table;
+use Doctrine\DBAL\Statement;
use Doctrine\DBAL\Types\Type;
+use Doctrine\Tests\DbalFunctionalTestCase;
use const CASE_LOWER;
use const PHP_EOL;
use function array_change_key_case;
@@ -20,48 +26,49 @@
use function is_numeric;
use function json_encode;
use function property_exists;
+use function sprintf;
use function strtotime;
-class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
+class DataAccessTest extends DbalFunctionalTestCase
{
- /**
- * @var bool
- */
+ /** @var bool */
static private $generated = false;
protected function setUp()
{
parent::setUp();
- if (self::$generated === false) {
- /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
- $table = new \Doctrine\DBAL\Schema\Table("fetch_table");
- $table->addColumn('test_int', 'integer');
- $table->addColumn('test_string', 'string');
- $table->addColumn('test_datetime', 'datetime', array('notnull' => false));
- $table->setPrimaryKey(array('test_int'));
+ if (self::$generated !== false) {
+ return;
+ }
- $sm = $this->_conn->getSchemaManager();
- $sm->createTable($table);
+ /** @var AbstractSchemaManager $sm */
+ $table = new Table('fetch_table');
+ $table->addColumn('test_int', 'integer');
+ $table->addColumn('test_string', 'string');
+ $table->addColumn('test_datetime', 'datetime', ['notnull' => false]);
+ $table->setPrimaryKey(['test_int']);
- $this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo', 'test_datetime' => '2010-01-01 10:10:10'));
- self::$generated = true;
- }
+ $sm = $this->connection->getSchemaManager();
+ $sm->createTable($table);
+
+ $this->connection->insert('fetch_table', ['test_int' => 1, 'test_string' => 'foo', 'test_datetime' => '2010-01-01 10:10:10']);
+ self::$generated = true;
}
public function testPrepareWithBindValue()
{
- $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
- $stmt = $this->_conn->prepare($sql);
- self::assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
+ $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
+ $stmt = $this->connection->prepare($sql);
+ self::assertInstanceOf(Statement::class, $stmt);
$stmt->bindValue(1, 1);
$stmt->bindValue(2, 'foo');
$stmt->execute();
$row = $stmt->fetch(FetchMode::ASSOCIATIVE);
- $row = array_change_key_case($row, \CASE_LOWER);
- self::assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row);
+ $row = array_change_key_case($row, CASE_LOWER);
+ self::assertEquals(['test_int' => 1, 'test_string' => 'foo'], $row);
}
public function testPrepareWithBindParam()
@@ -69,17 +76,17 @@ public function testPrepareWithBindParam()
$paramInt = 1;
$paramStr = 'foo';
- $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
- $stmt = $this->_conn->prepare($sql);
- self::assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
+ $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
+ $stmt = $this->connection->prepare($sql);
+ self::assertInstanceOf(Statement::class, $stmt);
$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
$stmt->execute();
$row = $stmt->fetch(FetchMode::ASSOCIATIVE);
- $row = array_change_key_case($row, \CASE_LOWER);
- self::assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row);
+ $row = array_change_key_case($row, CASE_LOWER);
+ self::assertEquals(['test_int' => 1, 'test_string' => 'foo'], $row);
}
public function testPrepareWithFetchAll()
@@ -87,17 +94,17 @@ public function testPrepareWithFetchAll()
$paramInt = 1;
$paramStr = 'foo';
- $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
- $stmt = $this->_conn->prepare($sql);
- self::assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
+ $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
+ $stmt = $this->connection->prepare($sql);
+ self::assertInstanceOf(Statement::class, $stmt);
$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
$stmt->execute();
$rows = $stmt->fetchAll(FetchMode::ASSOCIATIVE);
- $rows[0] = array_change_key_case($rows[0], \CASE_LOWER);
- self::assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $rows[0]);
+ $rows[0] = array_change_key_case($rows[0], CASE_LOWER);
+ self::assertEquals(['test_int' => 1, 'test_string' => 'foo'], $rows[0]);
}
/**
@@ -108,17 +115,17 @@ public function testPrepareWithFetchAllBoth()
$paramInt = 1;
$paramStr = 'foo';
- $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
- $stmt = $this->_conn->prepare($sql);
- self::assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
+ $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
+ $stmt = $this->connection->prepare($sql);
+ self::assertInstanceOf(Statement::class, $stmt);
$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
$stmt->execute();
$rows = $stmt->fetchAll(FetchMode::MIXED);
- $rows[0] = array_change_key_case($rows[0], \CASE_LOWER);
- self::assertEquals(array('test_int' => 1, 'test_string' => 'foo', 0 => 1, 1 => 'foo'), $rows[0]);
+ $rows[0] = array_change_key_case($rows[0], CASE_LOWER);
+ self::assertEquals(['test_int' => 1, 'test_string' => 'foo', 0 => 1, 1 => 'foo'], $rows[0]);
}
public function testPrepareWithFetchColumn()
@@ -126,9 +133,9 @@ public function testPrepareWithFetchColumn()
$paramInt = 1;
$paramStr = 'foo';
- $sql = "SELECT test_int FROM fetch_table WHERE test_int = ? AND test_string = ?";
- $stmt = $this->_conn->prepare($sql);
- self::assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
+ $sql = 'SELECT test_int FROM fetch_table WHERE test_int = ? AND test_string = ?';
+ $stmt = $this->connection->prepare($sql);
+ self::assertInstanceOf(Statement::class, $stmt);
$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
@@ -143,33 +150,36 @@ public function testPrepareWithIterator()
$paramInt = 1;
$paramStr = 'foo';
- $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
- $stmt = $this->_conn->prepare($sql);
- self::assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
+ $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
+ $stmt = $this->connection->prepare($sql);
+ self::assertInstanceOf(Statement::class, $stmt);
$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
$stmt->execute();
- $rows = array();
+ $rows = [];
$stmt->setFetchMode(FetchMode::ASSOCIATIVE);
foreach ($stmt as $row) {
- $rows[] = array_change_key_case($row, \CASE_LOWER);
+ $rows[] = array_change_key_case($row, CASE_LOWER);
}
- self::assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $rows[0]);
+ self::assertEquals(['test_int' => 1, 'test_string' => 'foo'], $rows[0]);
}
public function testPrepareWithQuoted()
{
- $table = 'fetch_table';
+ $table = 'fetch_table';
$paramInt = 1;
$paramStr = 'foo';
- $sql = "SELECT test_int, test_string FROM " . $this->_conn->quoteIdentifier($table) . " ".
- "WHERE test_int = " . $this->_conn->quote($paramInt) . " AND test_string = " . $this->_conn->quote($paramStr);
- $stmt = $this->_conn->prepare($sql);
- self::assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
+ $stmt = $this->connection->prepare(sprintf(
+ 'SELECT test_int, test_string FROM %s WHERE test_int = %s AND test_string = %s',
+ $this->connection->quoteIdentifier($table),
+ $this->connection->quote($paramInt),
+ $this->connection->quote($paramStr)
+ ));
+ self::assertInstanceOf(Statement::class, $stmt);
}
public function testPrepareWithExecuteParams()
@@ -177,28 +187,28 @@ public function testPrepareWithExecuteParams()
$paramInt = 1;
$paramStr = 'foo';
- $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
- $stmt = $this->_conn->prepare($sql);
- self::assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
- $stmt->execute(array($paramInt, $paramStr));
+ $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
+ $stmt = $this->connection->prepare($sql);
+ self::assertInstanceOf(Statement::class, $stmt);
+ $stmt->execute([$paramInt, $paramStr]);
$row = $stmt->fetch(FetchMode::ASSOCIATIVE);
self::assertNotFalse($row);
- $row = array_change_key_case($row, \CASE_LOWER);
- self::assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $row);
+ $row = array_change_key_case($row, CASE_LOWER);
+ self::assertEquals(['test_int' => 1, 'test_string' => 'foo'], $row);
}
public function testFetchAll()
{
- $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
- $data = $this->_conn->fetchAll($sql, array(1, 'foo'));
+ $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
+ $data = $this->connection->fetchAll($sql, [1, 'foo']);
self::assertCount(1, $data);
$row = $data[0];
self::assertCount(2, $row);
- $row = array_change_key_case($row, \CASE_LOWER);
+ $row = array_change_key_case($row, CASE_LOWER);
self::assertEquals(1, $row['test_int']);
self::assertEquals('foo', $row['test_string']);
}
@@ -209,17 +219,17 @@ public function testFetchAll()
public function testFetchAllWithTypes()
{
$datetimeString = '2010-01-01 10:10:10';
- $datetime = new \DateTime($datetimeString);
+ $datetime = new DateTime($datetimeString);
$sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
- $data = $this->_conn->fetchAll($sql, [1, $datetime], [ParameterType::STRING, Type::DATETIME]);
+ $data = $this->connection->fetchAll($sql, [1, $datetime], [ParameterType::STRING, Type::DATETIME]);
self::assertCount(1, $data);
$row = $data[0];
self::assertCount(2, $row);
- $row = array_change_key_case($row, \CASE_LOWER);
+ $row = array_change_key_case($row, CASE_LOWER);
self::assertEquals(1, $row['test_int']);
self::assertStringStartsWith($datetimeString, $row['test_datetime']);
}
@@ -230,25 +240,25 @@ public function testFetchAllWithTypes()
*/
public function testFetchAllWithMissingTypes()
{
- if ($this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\Mysqli\Driver ||
- $this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\SQLSrv\Driver) {
+ if ($this->connection->getDriver() instanceof MySQLiDriver ||
+ $this->connection->getDriver() instanceof SQLSrvDriver) {
$this->markTestSkipped('mysqli and sqlsrv actually supports this');
}
$datetimeString = '2010-01-01 10:10:10';
- $datetime = new \DateTime($datetimeString);
- $sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
- $data = $this->_conn->fetchAll($sql, array(1, $datetime));
+ $datetime = new DateTime($datetimeString);
+ $sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
+ $this->connection->fetchAll($sql, [1, $datetime]);
}
public function testFetchBoth()
{
$sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
- $row = $this->_conn->executeQuery($sql, [1, 'foo'])->fetch(FetchMode::MIXED);
+ $row = $this->connection->executeQuery($sql, [1, 'foo'])->fetch(FetchMode::MIXED);
self::assertNotFalse($row);
- $row = array_change_key_case($row, \CASE_LOWER);
+ $row = array_change_key_case($row, CASE_LOWER);
self::assertEquals(1, $row['test_int']);
self::assertEquals('foo', $row['test_string']);
@@ -259,18 +269,18 @@ public function testFetchBoth()
public function testFetchNoResult()
{
self::assertFalse(
- $this->_conn->executeQuery('SELECT test_int FROM fetch_table WHERE test_int = ?', [-1])->fetch()
+ $this->connection->executeQuery('SELECT test_int FROM fetch_table WHERE test_int = ?', [-1])->fetch()
);
}
public function testFetchAssoc()
{
- $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
- $row = $this->_conn->fetchAssoc($sql, array(1, 'foo'));
+ $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
+ $row = $this->connection->fetchAssoc($sql, [1, 'foo']);
self::assertNotFalse($row);
- $row = array_change_key_case($row, \CASE_LOWER);
+ $row = array_change_key_case($row, CASE_LOWER);
self::assertEquals(1, $row['test_int']);
self::assertEquals('foo', $row['test_string']);
@@ -279,14 +289,14 @@ public function testFetchAssoc()
public function testFetchAssocWithTypes()
{
$datetimeString = '2010-01-01 10:10:10';
- $datetime = new \DateTime($datetimeString);
+ $datetime = new DateTime($datetimeString);
$sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
- $row = $this->_conn->fetchAssoc($sql, [1, $datetime], [ParameterType::STRING, Type::DATETIME]);
+ $row = $this->connection->fetchAssoc($sql, [1, $datetime], [ParameterType::STRING, Type::DATETIME]);
self::assertNotFalse($row);
- $row = array_change_key_case($row, \CASE_LOWER);
+ $row = array_change_key_case($row, CASE_LOWER);
self::assertEquals(1, $row['test_int']);
self::assertStringStartsWith($datetimeString, $row['test_datetime']);
@@ -297,21 +307,21 @@ public function testFetchAssocWithTypes()
*/
public function testFetchAssocWithMissingTypes()
{
- if ($this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\Mysqli\Driver ||
- $this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\SQLSrv\Driver) {
+ if ($this->connection->getDriver() instanceof MySQLiDriver ||
+ $this->connection->getDriver() instanceof SQLSrvDriver) {
$this->markTestSkipped('mysqli and sqlsrv actually supports this');
}
$datetimeString = '2010-01-01 10:10:10';
- $datetime = new \DateTime($datetimeString);
- $sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
- $row = $this->_conn->fetchAssoc($sql, array(1, $datetime));
+ $datetime = new DateTime($datetimeString);
+ $sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
+ $this->connection->fetchAssoc($sql, [1, $datetime]);
}
public function testFetchArray()
{
- $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
- $row = $this->_conn->fetchArray($sql, array(1, 'foo'));
+ $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
+ $row = $this->connection->fetchArray($sql, [1, 'foo']);
self::assertEquals(1, $row[0]);
self::assertEquals('foo', $row[1]);
@@ -320,14 +330,14 @@ public function testFetchArray()
public function testFetchArrayWithTypes()
{
$datetimeString = '2010-01-01 10:10:10';
- $datetime = new \DateTime($datetimeString);
+ $datetime = new DateTime($datetimeString);
$sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
- $row = $this->_conn->fetchArray($sql, [1, $datetime], [ParameterType::STRING, Type::DATETIME]);
+ $row = $this->connection->fetchArray($sql, [1, $datetime], [ParameterType::STRING, Type::DATETIME]);
self::assertNotFalse($row);
- $row = array_change_key_case($row, \CASE_LOWER);
+ $row = array_change_key_case($row, CASE_LOWER);
self::assertEquals(1, $row[0]);
self::assertStringStartsWith($datetimeString, $row[1]);
@@ -338,26 +348,26 @@ public function testFetchArrayWithTypes()
*/
public function testFetchArrayWithMissingTypes()
{
- if ($this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\Mysqli\Driver ||
- $this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\SQLSrv\Driver) {
+ if ($this->connection->getDriver() instanceof MySQLiDriver ||
+ $this->connection->getDriver() instanceof SQLSrvDriver) {
$this->markTestSkipped('mysqli and sqlsrv actually supports this');
}
$datetimeString = '2010-01-01 10:10:10';
- $datetime = new \DateTime($datetimeString);
- $sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
- $row = $this->_conn->fetchArray($sql, array(1, $datetime));
+ $datetime = new DateTime($datetimeString);
+ $sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
+ $row = $this->connection->fetchArray($sql, [1, $datetime]);
}
public function testFetchColumn()
{
- $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
- $testInt = $this->_conn->fetchColumn($sql, array(1, 'foo'), 0);
+ $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
+ $testInt = $this->connection->fetchColumn($sql, [1, 'foo'], 0);
self::assertEquals(1, $testInt);
- $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
- $testString = $this->_conn->fetchColumn($sql, array(1, 'foo'), 1);
+ $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
+ $testString = $this->connection->fetchColumn($sql, [1, 'foo'], 1);
self::assertEquals('foo', $testString);
}
@@ -365,10 +375,10 @@ public function testFetchColumn()
public function testFetchColumnWithTypes()
{
$datetimeString = '2010-01-01 10:10:10';
- $datetime = new \DateTime($datetimeString);
+ $datetime = new DateTime($datetimeString);
$sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
- $column = $this->_conn->fetchColumn($sql, [1, $datetime], 1, [ParameterType::STRING, Type::DATETIME]);
+ $column = $this->connection->fetchColumn($sql, [1, $datetime], 1, [ParameterType::STRING, Type::DATETIME]);
self::assertNotFalse($column);
@@ -380,15 +390,15 @@ public function testFetchColumnWithTypes()
*/
public function testFetchColumnWithMissingTypes()
{
- if ($this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\Mysqli\Driver ||
- $this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\SQLSrv\Driver) {
+ if ($this->connection->getDriver() instanceof MySQLiDriver ||
+ $this->connection->getDriver() instanceof SQLSrvDriver) {
$this->markTestSkipped('mysqli and sqlsrv actually supports this');
}
$datetimeString = '2010-01-01 10:10:10';
- $datetime = new \DateTime($datetimeString);
- $sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
- $column = $this->_conn->fetchColumn($sql, array(1, $datetime), 1);
+ $datetime = new DateTime($datetimeString);
+ $sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
+ $column = $this->connection->fetchColumn($sql, [1, $datetime], 1);
}
/**
@@ -396,10 +406,11 @@ public function testFetchColumnWithMissingTypes()
*/
public function testExecuteQueryBindDateTimeType()
{
- $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?';
- $stmt = $this->_conn->executeQuery($sql,
- array(1 => new \DateTime('2010-01-01 10:10:10')),
- array(1 => Type::DATETIME)
+ $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?';
+ $stmt = $this->connection->executeQuery(
+ $sql,
+ [1 => new DateTime('2010-01-01 10:10:10')],
+ [1 => Type::DATETIME]
);
self::assertEquals(1, $stmt->fetchColumn());
@@ -410,10 +421,10 @@ public function testExecuteQueryBindDateTimeType()
*/
public function testExecuteUpdateBindDateTimeType()
{
- $datetime = new \DateTime('2010-02-02 20:20:20');
+ $datetime = new DateTime('2010-02-02 20:20:20');
- $sql = 'INSERT INTO fetch_table (test_int, test_string, test_datetime) VALUES (?, ?, ?)';
- $affectedRows = $this->_conn->executeUpdate($sql, [
+ $sql = 'INSERT INTO fetch_table (test_int, test_string, test_datetime) VALUES (?, ?, ?)';
+ $affectedRows = $this->connection->executeUpdate($sql, [
1 => 50,
2 => 'foo',
3 => $datetime,
@@ -424,10 +435,10 @@ public function testExecuteUpdateBindDateTimeType()
]);
self::assertEquals(1, $affectedRows);
- self::assertEquals(1, $this->_conn->executeQuery(
+ self::assertEquals(1, $this->connection->executeQuery(
'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?',
- array(1 => $datetime),
- array(1 => Type::DATETIME)
+ [1 => $datetime],
+ [1 => Type::DATETIME]
)->fetchColumn());
}
@@ -436,9 +447,9 @@ public function testExecuteUpdateBindDateTimeType()
*/
public function testPrepareQueryBindValueDateTimeType()
{
- $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?';
- $stmt = $this->_conn->prepare($sql);
- $stmt->bindValue(1, new \DateTime('2010-01-01 10:10:10'), Type::DATETIME);
+ $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?';
+ $stmt = $this->connection->prepare($sql);
+ $stmt->bindValue(1, new DateTime('2010-01-01 10:10:10'), Type::DATETIME);
$stmt->execute();
self::assertEquals(1, $stmt->fetchColumn());
@@ -450,22 +461,28 @@ public function testPrepareQueryBindValueDateTimeType()
public function testNativeArrayListSupport()
{
for ($i = 100; $i < 110; $i++) {
- $this->_conn->insert('fetch_table', array('test_int' => $i, 'test_string' => 'foo' . $i, 'test_datetime' => '2010-01-01 10:10:10'));
+ $this->connection->insert('fetch_table', ['test_int' => $i, 'test_string' => 'foo' . $i, 'test_datetime' => '2010-01-01 10:10:10']);
}
- $stmt = $this->_conn->executeQuery('SELECT test_int FROM fetch_table WHERE test_int IN (?)',
- array(array(100, 101, 102, 103, 104)), array(Connection::PARAM_INT_ARRAY));
+ $stmt = $this->connection->executeQuery(
+ 'SELECT test_int FROM fetch_table WHERE test_int IN (?)',
+ [[100, 101, 102, 103, 104]],
+ [Connection::PARAM_INT_ARRAY]
+ );
$data = $stmt->fetchAll(FetchMode::NUMERIC);
self::assertCount(5, $data);
- self::assertEquals(array(array(100), array(101), array(102), array(103), array(104)), $data);
+ self::assertEquals([[100], [101], [102], [103], [104]], $data);
- $stmt = $this->_conn->executeQuery('SELECT test_int FROM fetch_table WHERE test_string IN (?)',
- array(array('foo100', 'foo101', 'foo102', 'foo103', 'foo104')), array(Connection::PARAM_STR_ARRAY));
+ $stmt = $this->connection->executeQuery(
+ 'SELECT test_int FROM fetch_table WHERE test_string IN (?)',
+ [['foo100', 'foo101', 'foo102', 'foo103', 'foo104']],
+ [Connection::PARAM_STR_ARRAY]
+ );
$data = $stmt->fetchAll(FetchMode::NUMERIC);
self::assertCount(5, $data);
- self::assertEquals(array(array(100), array(101), array(102), array(103), array(104)), $data);
+ self::assertEquals([[100], [101], [102], [103], [104]], $data);
}
/**
@@ -474,10 +491,10 @@ public function testNativeArrayListSupport()
public function testTrimExpression($value, $position, $char, $expectedResult)
{
$sql = 'SELECT ' .
- $this->_conn->getDatabasePlatform()->getTrimExpression($value, $position, $char) . ' AS trimmed ' .
+ $this->connection->getDatabasePlatform()->getTrimExpression($value, $position, $char) . ' AS trimmed ' .
'FROM fetch_table';
- $row = $this->_conn->fetchAssoc($sql);
+ $row = $this->connection->fetchAssoc($sql);
$row = array_change_key_case($row, CASE_LOWER);
self::assertEquals($expectedResult, $row['trimmed']);
@@ -485,7 +502,7 @@ public function testTrimExpression($value, $position, $char, $expectedResult)
public function getTrimExpressionData()
{
- return array(
+ return [
['test_string', TrimMode::UNSPECIFIED, false, 'foo'],
['test_string', TrimMode::LEADING, false, 'foo'],
['test_string', TrimMode::TRAILING, false, 'foo'],
@@ -522,7 +539,7 @@ public function getTrimExpressionData()
["' foo '", TrimMode::BOTH, "'o'", ' foo '],
["' foo '", TrimMode::BOTH, "'.'", ' foo '],
["' foo '", TrimMode::BOTH, "' '", 'foo'],
- );
+ ];
}
/**
@@ -530,50 +547,50 @@ public function getTrimExpressionData()
*/
public function testDateArithmetics()
{
- $p = $this->_conn->getDatabasePlatform();
- $sql = 'SELECT ';
- $sql .= $p->getDateAddSecondsExpression('test_datetime', 1) .' AS add_seconds, ';
- $sql .= $p->getDateSubSecondsExpression('test_datetime', 1) .' AS sub_seconds, ';
- $sql .= $p->getDateAddMinutesExpression('test_datetime', 5) .' AS add_minutes, ';
- $sql .= $p->getDateSubMinutesExpression('test_datetime', 5) .' AS sub_minutes, ';
- $sql .= $p->getDateAddHourExpression('test_datetime', 3) .' AS add_hour, ';
- $sql .= $p->getDateSubHourExpression('test_datetime', 3) .' AS sub_hour, ';
- $sql .= $p->getDateAddDaysExpression('test_datetime', 10) .' AS add_days, ';
- $sql .= $p->getDateSubDaysExpression('test_datetime', 10) .' AS sub_days, ';
- $sql .= $p->getDateAddWeeksExpression('test_datetime', 1) .' AS add_weeks, ';
- $sql .= $p->getDateSubWeeksExpression('test_datetime', 1) .' AS sub_weeks, ';
- $sql .= $p->getDateAddMonthExpression('test_datetime', 2) .' AS add_month, ';
- $sql .= $p->getDateSubMonthExpression('test_datetime', 2) .' AS sub_month, ';
- $sql .= $p->getDateAddQuartersExpression('test_datetime', 3) .' AS add_quarters, ';
- $sql .= $p->getDateSubQuartersExpression('test_datetime', 3) .' AS sub_quarters, ';
- $sql .= $p->getDateAddYearsExpression('test_datetime', 6) .' AS add_years, ';
- $sql .= $p->getDateSubYearsExpression('test_datetime', 6) .' AS sub_years ';
+ $p = $this->connection->getDatabasePlatform();
+ $sql = 'SELECT ';
+ $sql .= $p->getDateAddSecondsExpression('test_datetime', 1) . ' AS add_seconds, ';
+ $sql .= $p->getDateSubSecondsExpression('test_datetime', 1) . ' AS sub_seconds, ';
+ $sql .= $p->getDateAddMinutesExpression('test_datetime', 5) . ' AS add_minutes, ';
+ $sql .= $p->getDateSubMinutesExpression('test_datetime', 5) . ' AS sub_minutes, ';
+ $sql .= $p->getDateAddHourExpression('test_datetime', 3) . ' AS add_hour, ';
+ $sql .= $p->getDateSubHourExpression('test_datetime', 3) . ' AS sub_hour, ';
+ $sql .= $p->getDateAddDaysExpression('test_datetime', 10) . ' AS add_days, ';
+ $sql .= $p->getDateSubDaysExpression('test_datetime', 10) . ' AS sub_days, ';
+ $sql .= $p->getDateAddWeeksExpression('test_datetime', 1) . ' AS add_weeks, ';
+ $sql .= $p->getDateSubWeeksExpression('test_datetime', 1) . ' AS sub_weeks, ';
+ $sql .= $p->getDateAddMonthExpression('test_datetime', 2) . ' AS add_month, ';
+ $sql .= $p->getDateSubMonthExpression('test_datetime', 2) . ' AS sub_month, ';
+ $sql .= $p->getDateAddQuartersExpression('test_datetime', 3) . ' AS add_quarters, ';
+ $sql .= $p->getDateSubQuartersExpression('test_datetime', 3) . ' AS sub_quarters, ';
+ $sql .= $p->getDateAddYearsExpression('test_datetime', 6) . ' AS add_years, ';
+ $sql .= $p->getDateSubYearsExpression('test_datetime', 6) . ' AS sub_years ';
$sql .= 'FROM fetch_table';
- $row = $this->_conn->fetchAssoc($sql);
+ $row = $this->connection->fetchAssoc($sql);
$row = array_change_key_case($row, CASE_LOWER);
- self::assertEquals('2010-01-01 10:10:11', date('Y-m-d H:i:s', strtotime($row['add_seconds'])), "Adding second should end up on 2010-01-01 10:10:11");
- self::assertEquals('2010-01-01 10:10:09', date('Y-m-d H:i:s', strtotime($row['sub_seconds'])), "Subtracting second should end up on 2010-01-01 10:10:09");
- self::assertEquals('2010-01-01 10:15:10', date('Y-m-d H:i:s', strtotime($row['add_minutes'])), "Adding minutes should end up on 2010-01-01 10:15:10");
- self::assertEquals('2010-01-01 10:05:10', date('Y-m-d H:i:s', strtotime($row['sub_minutes'])), "Subtracting minutes should end up on 2010-01-01 10:05:10");
- self::assertEquals('2010-01-01 13:10', date('Y-m-d H:i', strtotime($row['add_hour'])), "Adding date should end up on 2010-01-01 13:10");
- self::assertEquals('2010-01-01 07:10', date('Y-m-d H:i', strtotime($row['sub_hour'])), "Subtracting date should end up on 2010-01-01 07:10");
- self::assertEquals('2010-01-11', date('Y-m-d', strtotime($row['add_days'])), "Adding date should end up on 2010-01-11");
- self::assertEquals('2009-12-22', date('Y-m-d', strtotime($row['sub_days'])), "Subtracting date should end up on 2009-12-22");
- self::assertEquals('2010-01-08', date('Y-m-d', strtotime($row['add_weeks'])), "Adding week should end up on 2010-01-08");
- self::assertEquals('2009-12-25', date('Y-m-d', strtotime($row['sub_weeks'])), "Subtracting week should end up on 2009-12-25");
- self::assertEquals('2010-03-01', date('Y-m-d', strtotime($row['add_month'])), "Adding month should end up on 2010-03-01");
- self::assertEquals('2009-11-01', date('Y-m-d', strtotime($row['sub_month'])), "Subtracting month should end up on 2009-11-01");
- self::assertEquals('2010-10-01', date('Y-m-d', strtotime($row['add_quarters'])), "Adding quarters should end up on 2010-04-01");
- self::assertEquals('2009-04-01', date('Y-m-d', strtotime($row['sub_quarters'])), "Subtracting quarters should end up on 2009-10-01");
- self::assertEquals('2016-01-01', date('Y-m-d', strtotime($row['add_years'])), "Adding years should end up on 2016-01-01");
- self::assertEquals('2004-01-01', date('Y-m-d', strtotime($row['sub_years'])), "Subtracting years should end up on 2004-01-01");
+ self::assertEquals('2010-01-01 10:10:11', date('Y-m-d H:i:s', strtotime($row['add_seconds'])), 'Adding second should end up on 2010-01-01 10:10:11');
+ self::assertEquals('2010-01-01 10:10:09', date('Y-m-d H:i:s', strtotime($row['sub_seconds'])), 'Subtracting second should end up on 2010-01-01 10:10:09');
+ self::assertEquals('2010-01-01 10:15:10', date('Y-m-d H:i:s', strtotime($row['add_minutes'])), 'Adding minutes should end up on 2010-01-01 10:15:10');
+ self::assertEquals('2010-01-01 10:05:10', date('Y-m-d H:i:s', strtotime($row['sub_minutes'])), 'Subtracting minutes should end up on 2010-01-01 10:05:10');
+ self::assertEquals('2010-01-01 13:10', date('Y-m-d H:i', strtotime($row['add_hour'])), 'Adding date should end up on 2010-01-01 13:10');
+ self::assertEquals('2010-01-01 07:10', date('Y-m-d H:i', strtotime($row['sub_hour'])), 'Subtracting date should end up on 2010-01-01 07:10');
+ self::assertEquals('2010-01-11', date('Y-m-d', strtotime($row['add_days'])), 'Adding date should end up on 2010-01-11');
+ self::assertEquals('2009-12-22', date('Y-m-d', strtotime($row['sub_days'])), 'Subtracting date should end up on 2009-12-22');
+ self::assertEquals('2010-01-08', date('Y-m-d', strtotime($row['add_weeks'])), 'Adding week should end up on 2010-01-08');
+ self::assertEquals('2009-12-25', date('Y-m-d', strtotime($row['sub_weeks'])), 'Subtracting week should end up on 2009-12-25');
+ self::assertEquals('2010-03-01', date('Y-m-d', strtotime($row['add_month'])), 'Adding month should end up on 2010-03-01');
+ self::assertEquals('2009-11-01', date('Y-m-d', strtotime($row['sub_month'])), 'Subtracting month should end up on 2009-11-01');
+ self::assertEquals('2010-10-01', date('Y-m-d', strtotime($row['add_quarters'])), 'Adding quarters should end up on 2010-04-01');
+ self::assertEquals('2009-04-01', date('Y-m-d', strtotime($row['sub_quarters'])), 'Subtracting quarters should end up on 2009-10-01');
+ self::assertEquals('2016-01-01', date('Y-m-d', strtotime($row['add_years'])), 'Adding years should end up on 2016-01-01');
+ self::assertEquals('2004-01-01', date('Y-m-d', strtotime($row['sub_years'])), 'Subtracting years should end up on 2004-01-01');
}
public function testSqliteDateArithmeticWithDynamicInterval()
{
- $platform = $this->_conn->getDatabasePlatform();
+ $platform = $this->connection->getDatabasePlatform();
if (! $platform instanceof SqlitePlatform) {
$this->markTestSkipped('test is for sqlite only');
@@ -584,38 +601,38 @@ public function testSqliteDateArithmeticWithDynamicInterval()
$table->addColumn('test_days', 'integer');
$table->setPrimaryKey(['test_date']);
- /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
- $sm = $this->_conn->getSchemaManager();
+ /** @var AbstractSchemaManager $sm */
+ $sm = $this->connection->getSchemaManager();
$sm->createTable($table);
- $this->_conn->insert('fetch_table_date_math', ['test_date' => '2010-01-01', 'test_days' => 10]);
- $this->_conn->insert('fetch_table_date_math', ['test_date' => '2010-06-01', 'test_days' => 20]);
+ $this->connection->insert('fetch_table_date_math', ['test_date' => '2010-01-01', 'test_days' => 10]);
+ $this->connection->insert('fetch_table_date_math', ['test_date' => '2010-06-01', 'test_days' => 20]);
$sql = 'SELECT COUNT(*) FROM fetch_table_date_math WHERE ';
$sql .= $platform->getDateSubDaysExpression('test_date', 'test_days') . " < '2010-05-12'";
- $rowCount = $this->_conn->fetchColumn($sql, [], 0);
+ $rowCount = $this->connection->fetchColumn($sql, [], 0);
$this->assertEquals(1, $rowCount);
}
public function testLocateExpression()
{
- $platform = $this->_conn->getDatabasePlatform();
-
- $sql = 'SELECT ';
- $sql .= $platform->getLocateExpression('test_string', "'oo'") .' AS locate1, ';
- $sql .= $platform->getLocateExpression('test_string', "'foo'") .' AS locate2, ';
- $sql .= $platform->getLocateExpression('test_string', "'bar'") .' AS locate3, ';
- $sql .= $platform->getLocateExpression('test_string', 'test_string') .' AS locate4, ';
- $sql .= $platform->getLocateExpression("'foo'", 'test_string') .' AS locate5, ';
- $sql .= $platform->getLocateExpression("'barfoobaz'", 'test_string') .' AS locate6, ';
- $sql .= $platform->getLocateExpression("'bar'", 'test_string') .' AS locate7, ';
- $sql .= $platform->getLocateExpression('test_string', "'oo'", 2) .' AS locate8, ';
- $sql .= $platform->getLocateExpression('test_string', "'oo'", 3) .' AS locate9 ';
+ $platform = $this->connection->getDatabasePlatform();
+
+ $sql = 'SELECT ';
+ $sql .= $platform->getLocateExpression('test_string', "'oo'") . ' AS locate1, ';
+ $sql .= $platform->getLocateExpression('test_string', "'foo'") . ' AS locate2, ';
+ $sql .= $platform->getLocateExpression('test_string', "'bar'") . ' AS locate3, ';
+ $sql .= $platform->getLocateExpression('test_string', 'test_string') . ' AS locate4, ';
+ $sql .= $platform->getLocateExpression("'foo'", 'test_string') . ' AS locate5, ';
+ $sql .= $platform->getLocateExpression("'barfoobaz'", 'test_string') . ' AS locate6, ';
+ $sql .= $platform->getLocateExpression("'bar'", 'test_string') . ' AS locate7, ';
+ $sql .= $platform->getLocateExpression('test_string', "'oo'", 2) . ' AS locate8, ';
+ $sql .= $platform->getLocateExpression('test_string', "'oo'", 3) . ' AS locate9 ';
$sql .= 'FROM fetch_table';
- $row = $this->_conn->fetchAssoc($sql);
+ $row = $this->connection->fetchAssoc($sql);
$row = array_change_key_case($row, CASE_LOWER);
self::assertEquals(2, $row['locate1']);
@@ -631,10 +648,10 @@ public function testLocateExpression()
public function testQuoteSQLInjection()
{
- $sql = "SELECT * FROM fetch_table WHERE test_string = " . $this->_conn->quote("bar' OR '1'='1");
- $rows = $this->_conn->fetchAll($sql);
+ $sql = 'SELECT * FROM fetch_table WHERE test_string = ' . $this->connection->quote("bar' OR '1'='1");
+ $rows = $this->connection->fetchAll($sql);
- self::assertCount(0, $rows, "no result should be returned, otherwise SQL injection is possible");
+ self::assertCount(0, $rows, 'no result should be returned, otherwise SQL injection is possible');
}
/**
@@ -642,33 +659,32 @@ public function testQuoteSQLInjection()
*/
public function testBitComparisonExpressionSupport()
{
- $this->_conn->exec('DELETE FROM fetch_table');
- $platform = $this->_conn->getDatabasePlatform();
- $bitmap = array();
+ $this->connection->exec('DELETE FROM fetch_table');
+ $platform = $this->connection->getDatabasePlatform();
+ $bitmap = [];
- for ($i = 2; $i < 9; $i = $i + 2) {
- $bitmap[$i] = array(
+ for ($i = 2; $i < 9; $i += 2) {
+ $bitmap[$i] = [
'bit_or' => ($i | 2),
- 'bit_and' => ($i & 2)
- );
- $this->_conn->insert('fetch_table', array(
+ 'bit_and' => ($i & 2),
+ ];
+ $this->connection->insert('fetch_table', [
'test_int' => $i,
'test_string' => json_encode($bitmap[$i]),
- 'test_datetime' => '2010-01-01 10:10:10'
- ));
+ 'test_datetime' => '2010-01-01 10:10:10',
+ ]);
}
- $sql[] = 'SELECT ';
- $sql[] = 'test_int, ';
- $sql[] = 'test_string, ';
- $sql[] = $platform->getBitOrComparisonExpression('test_int', 2) . ' AS bit_or, ';
- $sql[] = $platform->getBitAndComparisonExpression('test_int', 2) . ' AS bit_and ';
- $sql[] = 'FROM fetch_table';
+ $sql[] = 'SELECT ';
+ $sql[] = 'test_int, ';
+ $sql[] = 'test_string, ';
+ $sql[] = $platform->getBitOrComparisonExpression('test_int', 2) . ' AS bit_or, ';
+ $sql[] = $platform->getBitAndComparisonExpression('test_int', 2) . ' AS bit_and ';
+ $sql[] = 'FROM fetch_table';
- $stmt = $this->_conn->executeQuery(implode(PHP_EOL, $sql));
+ $stmt = $this->connection->executeQuery(implode(PHP_EOL, $sql));
$data = $stmt->fetchAll(FetchMode::ASSOCIATIVE);
-
self::assertCount(4, $data);
self::assertEquals(count($bitmap), count($data));
foreach ($data as $row) {
@@ -691,11 +707,13 @@ public function testBitComparisonExpressionSupport()
public function testSetDefaultFetchMode()
{
- $stmt = $this->_conn->query("SELECT * FROM fetch_table");
+ $stmt = $this->connection->query('SELECT * FROM fetch_table');
$stmt->setFetchMode(FetchMode::NUMERIC);
$row = array_keys($stmt->fetch());
- self::assertCount(0, array_filter($row, function($v) { return ! is_numeric($v); }), "should be no non-numerical elements in the result.");
+ self::assertCount(0, array_filter($row, static function ($v) {
+ return ! is_numeric($v);
+ }), 'should be no non-numerical elements in the result.');
}
/**
@@ -705,8 +723,8 @@ public function testFetchAllStyleObject()
{
$this->setupFixture();
- $sql = 'SELECT test_int, test_string, test_datetime FROM fetch_table';
- $stmt = $this->_conn->prepare($sql);
+ $sql = 'SELECT test_int, test_string, test_datetime FROM fetch_table';
+ $stmt = $this->connection->prepare($sql);
$stmt->execute();
@@ -737,17 +755,17 @@ public function testFetchAllSupportFetchClass()
$this->skipOci8AndMysqli();
$this->setupFixture();
- $sql = "SELECT test_int, test_string, test_datetime FROM fetch_table";
- $stmt = $this->_conn->prepare($sql);
+ $sql = 'SELECT test_int, test_string, test_datetime FROM fetch_table';
+ $stmt = $this->connection->prepare($sql);
$stmt->execute();
$results = $stmt->fetchAll(
FetchMode::CUSTOM_OBJECT,
- __NAMESPACE__.'\\MyFetchClass'
+ MyFetchClass::class
);
self::assertCount(1, $results);
- self::assertInstanceOf(__NAMESPACE__.'\\MyFetchClass', $results[0]);
+ self::assertInstanceOf(MyFetchClass::class, $results[0]);
self::assertEquals(1, $results[0]->test_int);
self::assertEquals('foo', $results[0]->test_string);
@@ -759,16 +777,16 @@ public function testFetchAllSupportFetchClass()
*/
public function testFetchAllStyleColumn()
{
- $sql = "DELETE FROM fetch_table";
- $this->_conn->executeUpdate($sql);
+ $sql = 'DELETE FROM fetch_table';
+ $this->connection->executeUpdate($sql);
- $this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo'));
- $this->_conn->insert('fetch_table', array('test_int' => 10, 'test_string' => 'foo'));
+ $this->connection->insert('fetch_table', ['test_int' => 1, 'test_string' => 'foo']);
+ $this->connection->insert('fetch_table', ['test_int' => 10, 'test_string' => 'foo']);
- $sql = "SELECT test_int FROM fetch_table";
- $rows = $this->_conn->query($sql)->fetchAll(FetchMode::COLUMN);
+ $sql = 'SELECT test_int FROM fetch_table';
+ $rows = $this->connection->query($sql)->fetchAll(FetchMode::COLUMN);
- self::assertEquals(array(1, 10), $rows);
+ self::assertEquals([1, 10], $rows);
}
/**
@@ -779,14 +797,14 @@ public function testSetFetchModeClassFetchAll()
$this->skipOci8AndMysqli();
$this->setupFixture();
- $sql = "SELECT * FROM fetch_table";
- $stmt = $this->_conn->query($sql);
- $stmt->setFetchMode(FetchMode::CUSTOM_OBJECT, __NAMESPACE__ . '\\MyFetchClass');
+ $sql = 'SELECT * FROM fetch_table';
+ $stmt = $this->connection->query($sql);
+ $stmt->setFetchMode(FetchMode::CUSTOM_OBJECT, MyFetchClass::class);
$results = $stmt->fetchAll();
self::assertCount(1, $results);
- self::assertInstanceOf(__NAMESPACE__.'\\MyFetchClass', $results[0]);
+ self::assertInstanceOf(MyFetchClass::class, $results[0]);
self::assertEquals(1, $results[0]->test_int);
self::assertEquals('foo', $results[0]->test_string);
@@ -801,17 +819,17 @@ public function testSetFetchModeClassFetch()
$this->skipOci8AndMysqli();
$this->setupFixture();
- $sql = "SELECT * FROM fetch_table";
- $stmt = $this->_conn->query($sql);
- $stmt->setFetchMode(FetchMode::CUSTOM_OBJECT, __NAMESPACE__ . '\\MyFetchClass');
+ $sql = 'SELECT * FROM fetch_table';
+ $stmt = $this->connection->query($sql);
+ $stmt->setFetchMode(FetchMode::CUSTOM_OBJECT, MyFetchClass::class);
- $results = array();
+ $results = [];
while ($row = $stmt->fetch()) {
$results[] = $row;
}
self::assertCount(1, $results);
- self::assertInstanceOf(__NAMESPACE__.'\\MyFetchClass', $results[0]);
+ self::assertInstanceOf(MyFetchClass::class, $results[0]);
self::assertEquals(1, $results[0]->test_int);
self::assertEquals('foo', $results[0]->test_string);
@@ -823,11 +841,11 @@ public function testSetFetchModeClassFetch()
*/
public function testEmptyFetchColumnReturnsFalse()
{
- $this->_conn->beginTransaction();
- $this->_conn->exec('DELETE FROM fetch_table');
- self::assertFalse($this->_conn->fetchColumn('SELECT test_int FROM fetch_table'));
- self::assertFalse($this->_conn->query('SELECT test_int FROM fetch_table')->fetchColumn());
- $this->_conn->rollBack();
+ $this->connection->beginTransaction();
+ $this->connection->exec('DELETE FROM fetch_table');
+ self::assertFalse($this->connection->fetchColumn('SELECT test_int FROM fetch_table'));
+ self::assertFalse($this->connection->query('SELECT test_int FROM fetch_table')->fetchColumn());
+ $this->connection->rollBack();
}
/**
@@ -835,8 +853,8 @@ public function testEmptyFetchColumnReturnsFalse()
*/
public function testSetFetchModeOnDbalStatement()
{
- $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
- $stmt = $this->_conn->executeQuery($sql, array(1, "foo"));
+ $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
+ $stmt = $this->connection->executeQuery($sql, [1, 'foo']);
$stmt->setFetchMode(FetchMode::NUMERIC);
$row = $stmt->fetch();
@@ -851,11 +869,11 @@ public function testSetFetchModeOnDbalStatement()
*/
public function testEmptyParameters()
{
- $sql = "SELECT * FROM fetch_table WHERE test_int IN (?)";
- $stmt = $this->_conn->executeQuery($sql, array(array()), array(\Doctrine\DBAL\Connection::PARAM_INT_ARRAY));
+ $sql = 'SELECT * FROM fetch_table WHERE test_int IN (?)';
+ $stmt = $this->connection->executeQuery($sql, [[]], [Connection::PARAM_INT_ARRAY]);
$rows = $stmt->fetchAll();
- self::assertEquals(array(), $rows);
+ self::assertEquals([], $rows);
}
/**
@@ -863,13 +881,13 @@ public function testEmptyParameters()
*/
public function testFetchColumnNullValue()
{
- $this->_conn->executeUpdate(
+ $this->connection->executeUpdate(
'INSERT INTO fetch_table (test_int, test_string) VALUES (?, ?)',
- array(2, 'foo')
+ [2, 'foo']
);
self::assertNull(
- $this->_conn->fetchColumn('SELECT test_datetime FROM fetch_table WHERE test_int = ?', array(2))
+ $this->connection->fetchColumn('SELECT test_datetime FROM fetch_table WHERE test_int = ?', [2])
);
}
@@ -878,14 +896,14 @@ public function testFetchColumnNullValue()
*/
public function testFetchColumnNonExistingIndex()
{
- if ($this->_conn->getDriver()->getName() === 'pdo_sqlsrv') {
+ if ($this->connection->getDriver()->getName() === 'pdo_sqlsrv') {
$this->markTestSkipped(
'Test does not work for pdo_sqlsrv driver as it throws a fatal error for a non-existing column index.'
);
}
self::assertNull(
- $this->_conn->fetchColumn('SELECT test_int FROM fetch_table WHERE test_int = ?', array(1), 1)
+ $this->connection->fetchColumn('SELECT test_int FROM fetch_table WHERE test_int = ?', [1], 1)
);
}
@@ -895,32 +913,41 @@ public function testFetchColumnNonExistingIndex()
public function testFetchColumnNoResult()
{
self::assertFalse(
- $this->_conn->fetchColumn('SELECT test_int FROM fetch_table WHERE test_int = ?', array(-1))
+ $this->connection->fetchColumn('SELECT test_int FROM fetch_table WHERE test_int = ?', [-1])
);
}
private function setupFixture()
{
- $this->_conn->exec('DELETE FROM fetch_table');
- $this->_conn->insert('fetch_table', array(
+ $this->connection->exec('DELETE FROM fetch_table');
+ $this->connection->insert('fetch_table', [
'test_int' => 1,
'test_string' => 'foo',
- 'test_datetime' => '2010-01-01 10:10:10'
- ));
+ 'test_datetime' => '2010-01-01 10:10:10',
+ ]);
}
private function skipOci8AndMysqli()
{
- if (isset($GLOBALS['db_type']) && $GLOBALS['db_type'] == "oci8") {
- $this->markTestSkipped("Not supported by OCI8");
+ if (isset($GLOBALS['db_type']) && $GLOBALS['db_type'] === 'oci8') {
+ $this->markTestSkipped('Not supported by OCI8');
}
- if ('mysqli' == $this->_conn->getDriver()->getName()) {
- $this->markTestSkipped('Mysqli driver dont support this feature.');
+ if ($this->connection->getDriver()->getName() !== 'mysqli') {
+ return;
}
+
+ $this->markTestSkipped('Mysqli driver dont support this feature.');
}
}
class MyFetchClass
{
- public $test_int, $test_string, $test_datetime;
+ /** @var int */
+ public $test_int;
+
+ /** @var string */
+ public $test_string;
+
+ /** @var string */
+ public $test_datetime;
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php
index 4857e81a5e1..738c259d5c0 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php
@@ -3,6 +3,8 @@
namespace Doctrine\Tests\DBAL\Functional\Driver;
use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver;
+use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\Tests\DbalFunctionalTestCase;
abstract class AbstractDriverTest extends DbalFunctionalTestCase
@@ -10,7 +12,7 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase
/**
* The driver instance under test.
*
- * @var \Doctrine\DBAL\Driver
+ * @var Driver
*/
protected $driver;
@@ -26,15 +28,15 @@ protected function setUp()
*/
public function testConnectsWithoutDatabaseNameParameter()
{
- $params = $this->_conn->getParams();
+ $params = $this->connection->getParams();
unset($params['dbname']);
- $user = $params['user'] ?? null;
+ $user = $params['user'] ?? null;
$password = $params['password'] ?? null;
$connection = $this->driver->connect($params, $user, $password);
- self::assertInstanceOf('Doctrine\DBAL\Driver\Connection', $connection);
+ self::assertInstanceOf(DriverConnection::class, $connection);
}
/**
@@ -42,14 +44,14 @@ public function testConnectsWithoutDatabaseNameParameter()
*/
public function testReturnsDatabaseNameWithoutDatabaseNameParameter()
{
- $params = $this->_conn->getParams();
+ $params = $this->connection->getParams();
unset($params['dbname']);
$connection = new Connection(
$params,
- $this->_conn->getDriver(),
- $this->_conn->getConfiguration(),
- $this->_conn->getEventManager()
+ $this->connection->getDriver(),
+ $this->connection->getConfiguration(),
+ $this->connection->getEventManager()
);
self::assertSame(
@@ -59,7 +61,7 @@ public function testReturnsDatabaseNameWithoutDatabaseNameParameter()
}
/**
- * @return \Doctrine\DBAL\Driver
+ * @return Driver
*/
abstract protected function createDriver();
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php
index 4bcc5b6cf76..82da6090b7e 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php
@@ -16,9 +16,11 @@ protected function setUp()
parent::setUp();
- if (! $this->_conn->getDriver() instanceof DB2Driver) {
- $this->markTestSkipped('ibm_db2 only test.');
+ if ($this->connection->getDriver() instanceof DB2Driver) {
+ return;
}
+
+ $this->markTestSkipped('ibm_db2 only test.');
}
/**
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php
index 59b42a75635..6c2ec6a9ca6 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php
@@ -13,20 +13,22 @@ class DB2StatementTest extends DbalFunctionalTestCase
{
protected function setUp()
{
- if ( ! extension_loaded('ibm_db2')) {
+ if (! extension_loaded('ibm_db2')) {
$this->markTestSkipped('ibm_db2 is not installed.');
}
parent::setUp();
- if ( ! $this->_conn->getDriver() instanceof DB2Driver) {
- $this->markTestSkipped('ibm_db2 only test.');
+ if ($this->connection->getDriver() instanceof DB2Driver) {
+ return;
}
+
+ $this->markTestSkipped('ibm_db2 only test.');
}
public function testExecutionErrorsAreNotSuppressed()
{
- $stmt = $this->_conn->prepare('SELECT * FROM SYSIBM.SYSDUMMY1 WHERE \'foo\' = ?');
+ $stmt = $this->connection->prepare('SELECT * FROM SYSIBM.SYSDUMMY1 WHERE \'foo\' = ?');
// unwrap the statement to prevent the wrapper from handling the PHPUnit-originated exception
$wrappedStmt = $stmt->getWrappedStatement();
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php
index c20533a4700..8c274e1cbb2 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php
@@ -1,20 +1,28 @@
markTestSkipped('mysqli is not installed.');
}
parent::setUp();
- if ( !($this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\Mysqli\Driver)) {
- $this->markTestSkipped('MySQLi only test.');
+ if ($this->connection->getDriver() instanceof Driver) {
+ return;
}
+
+ $this->markTestSkipped('MySQLi only test.');
}
protected function tearDown()
@@ -24,12 +32,10 @@ protected function tearDown()
public function testDriverOptions()
{
- $driverOptions = array(
- \MYSQLI_OPT_CONNECT_TIMEOUT => 1,
- );
+ $driverOptions = [MYSQLI_OPT_CONNECT_TIMEOUT => 1];
$connection = $this->getConnection($driverOptions);
- self::assertInstanceOf("\Doctrine\DBAL\Driver\Mysqli\MysqliConnection", $connection);
+ self::assertInstanceOf(MysqliConnection::class, $connection);
}
/**
@@ -37,22 +43,25 @@ public function testDriverOptions()
*/
public function testUnsupportedDriverOption()
{
- $this->getConnection(array('hello' => 'world')); // use local infile
+ $this->getConnection(['hello' => 'world']); // use local infile
}
public function testPing()
{
- $conn = $this->getConnection(array());
+ $conn = $this->getConnection([]);
self::assertTrue($conn->ping());
}
+ /**
+ * @param mixed[] $driverOptions
+ */
private function getConnection(array $driverOptions)
{
- return new \Doctrine\DBAL\Driver\Mysqli\MysqliConnection(
- array(
- 'host' => $GLOBALS['db_host'],
- 'dbname' => $GLOBALS['db_name'],
- ),
+ return new MysqliConnection(
+ [
+ 'host' => $GLOBALS['db_host'],
+ 'dbname' => $GLOBALS['db_name'],
+ ],
$GLOBALS['db_username'],
$GLOBALS['db_password'],
$driverOptions
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php
index d88265d4aa3..d7f02a40306 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php
@@ -16,9 +16,11 @@ protected function setUp()
parent::setUp();
- if (! $this->_conn->getDriver() instanceof Driver) {
- $this->markTestSkipped('MySQLi only test.');
+ if ($this->connection->getDriver() instanceof Driver) {
+ return;
}
+
+ $this->markTestSkipped('MySQLi only test.');
}
/**
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php
index 8a08d24f051..a781b31007d 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php
@@ -16,9 +16,11 @@ protected function setUp()
parent::setUp();
- if (! $this->_conn->getDriver() instanceof Driver) {
- $this->markTestSkipped('oci8 only test.');
+ if ($this->connection->getDriver() instanceof Driver) {
+ return;
}
+
+ $this->markTestSkipped('oci8 only test.');
}
/**
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php
index 90430e92a02..1c3226852d6 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php
@@ -3,15 +3,14 @@
namespace Doctrine\Tests\DBAL\Functional\Driver\OCI8;
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;
class OCI8ConnectionTest extends DbalFunctionalTestCase
{
- /**
- * @var \Doctrine\DBAL\Driver\OCI8\OCI8Connection
- */
+ /** @var OCI8Connection */
protected $driverConnection;
protected function setUp()
@@ -22,11 +21,11 @@ protected function setUp()
parent::setUp();
- if (! $this->_conn->getDriver() instanceof Driver) {
+ if (! $this->connection->getDriver() instanceof Driver) {
$this->markTestSkipped('oci8 only test.');
}
- $this->driverConnection = $this->_conn->getWrappedConnection();
+ $this->driverConnection = $this->connection->getWrappedConnection();
}
/**
@@ -34,18 +33,18 @@ protected function setUp()
*/
public function testLastInsertIdAcceptsFqn()
{
- $platform = $this->_conn->getDatabasePlatform();
- $schemaManager = $this->_conn->getSchemaManager();
+ $platform = $this->connection->getDatabasePlatform();
+ $schemaManager = $this->connection->getSchemaManager();
$table = new Table('DBAL2595');
- $table->addColumn('id', 'integer', array('autoincrement' => true));
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('foo', 'integer');
$schemaManager->dropAndCreateTable($table);
- $this->_conn->executeUpdate('INSERT INTO DBAL2595 (foo) VALUES (1)');
+ $this->connection->executeUpdate('INSERT INTO DBAL2595 (foo) VALUES (1)');
- $schema = $this->_conn->getDatabase();
+ $schema = $this->connection->getDatabase();
$sequence = $platform->getIdentitySequenceName($schema . '.DBAL2595', 'id');
self::assertSame(1, $this->driverConnection->lastInsertId($sequence));
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php
index 5cbaa9c137c..db6a4d552ca 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php
@@ -16,71 +16,70 @@ protected function setUp()
parent::setUp();
- if (! $this->_conn->getDriver() instanceof Driver) {
- $this->markTestSkipped('oci8 only test.');
+ if ($this->connection->getDriver() instanceof Driver) {
+ return;
}
+
+ $this->markTestSkipped('oci8 only test.');
}
/**
+ * @param mixed[] $params
+ * @param mixed[] $expected
+ *
* @dataProvider queryConversionProvider
*/
public function testQueryConversion($query, array $params, array $expected)
{
self::assertEquals(
$expected,
- $this->_conn->executeQuery($query, $params)->fetch()
+ $this->connection->executeQuery($query, $params)->fetch()
);
}
public static function queryConversionProvider()
{
- return array(
- 'simple' => array(
+ return [
+ 'simple' => [
'SELECT ? COL1 FROM DUAL',
- array(1),
- array(
- 'COL1' => 1,
- ),
- ),
- 'literal-with-placeholder' => array(
+ [1],
+ ['COL1' => 1],
+ ],
+ 'literal-with-placeholder' => [
"SELECT '?' COL1, ? COL2 FROM DUAL",
- array(2),
- array(
+ [2],
+ [
'COL1' => '?',
'COL2' => 2,
- ),
- ),
- 'literal-with-quotes' => array(
+ ],
+ ],
+ 'literal-with-quotes' => [
"SELECT ? COL1, '?\"?''?' \"COL?\" FROM DUAL",
- array(3),
- array(
+ [3],
+ [
'COL1' => 3,
'COL?' => '?"?\'?',
- ),
- ),
- 'placeholder-at-the-end' => array(
+ ],
+ ],
+ 'placeholder-at-the-end' => [
'SELECT ? COL1 FROM DUAL WHERE 1 = ?',
- array(4, 1),
- array(
- 'COL1' => 4,
- ),
- ),
- 'multi-line-literal' => array(
+ [4, 1],
+ ['COL1' => 4],
+ ],
+ 'multi-line-literal' => [
"SELECT 'Hello,
World?!' COL1 FROM DUAL WHERE 1 = ?",
- array(1),
- array(
+ [1],
+ [
'COL1' => 'Hello,
World?!',
- ),
- ),
- 'empty-literal' => array(
+ ],
+ ],
+ 'empty-literal' => [
"SELECT '' COL1 FROM DUAL",
- array(),
- array(
- 'COL1' => '',
- ),
- ),
- );
+ [],
+ ['COL1' => ''],
+ ],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php
index 29f18f8c78f..214f90700c1 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php
@@ -4,6 +4,7 @@
use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\Tests\DbalFunctionalTestCase;
+use PDO;
use function extension_loaded;
use function sprintf;
@@ -12,23 +13,25 @@ class PDOConnectionTest extends DbalFunctionalTestCase
/**
* The PDO driver connection under test.
*
- * @var \Doctrine\DBAL\Driver\PDOConnection
+ * @var PDOConnection
*/
protected $driverConnection;
protected function setUp()
{
- if ( ! extension_loaded('PDO')) {
+ if (! extension_loaded('PDO')) {
$this->markTestSkipped('PDO is not installed.');
}
parent::setUp();
- $this->driverConnection = $this->_conn->getWrappedConnection();
+ $this->driverConnection = $this->connection->getWrappedConnection();
- if ( ! $this->driverConnection instanceof PDOConnection) {
- $this->markTestSkipped('PDO connection only test.');
+ if ($this->driverConnection instanceof PDOConnection) {
+ return;
}
+
+ $this->markTestSkipped('PDO connection only test.');
}
protected function tearDown()
@@ -53,7 +56,6 @@ public function testThrowsWrappedExceptionOnConstruct()
/**
* @group DBAL-1022
- *
* @expectedException \Doctrine\DBAL\Driver\PDOException
*/
public function testThrowsWrappedExceptionOnExec()
@@ -66,13 +68,13 @@ public function testThrowsWrappedExceptionOnExec()
*/
public function testThrowsWrappedExceptionOnPrepare()
{
- if ($this->_conn->getDriver()->getName() === 'pdo_sqlsrv') {
+ if ($this->connection->getDriver()->getName() === 'pdo_sqlsrv') {
$this->markTestSkipped('pdo_sqlsrv does not allow setting PDO::ATTR_EMULATE_PREPARES at connection level.');
}
// 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);
+ $this->driverConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$this->driverConnection->prepare('foo');
@@ -84,7 +86,7 @@ public function testThrowsWrappedExceptionOnPrepare()
sprintf(
'The PDO adapter %s does not check the query to be prepared server-side, ' .
'so no assertions can be made.',
- $this->_conn->getDriver()->getName()
+ $this->connection->getDriver()->getName()
)
);
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php
index 299fd4798e4..cb0f9633201 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php
@@ -16,9 +16,11 @@ protected function setUp()
parent::setUp();
- if (! $this->_conn->getDriver() instanceof Driver) {
- $this->markTestSkipped('pdo_mysql only test.');
+ if ($this->connection->getDriver() instanceof Driver) {
+ return;
}
+
+ $this->markTestSkipped('pdo_mysql only test.');
}
/**
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php
index afbdc08c7e8..604fbc8b123 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php
@@ -16,9 +16,11 @@ protected function setUp()
parent::setUp();
- if (! $this->_conn->getDriver() instanceof Driver) {
- $this->markTestSkipped('PDO_OCI only test.');
+ if ($this->connection->getDriver() instanceof Driver) {
+ return;
}
+
+ $this->markTestSkipped('PDO_OCI only test.');
}
/**
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php
index 04be88079ec..289621c5eba 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php
@@ -21,9 +21,11 @@ protected function setUp()
parent::setUp();
- if (! $this->_conn->getDriver() instanceof Driver) {
- $this->markTestSkipped('pdo_pgsql only test.');
+ if ($this->connection->getDriver() instanceof Driver) {
+ return;
}
+
+ $this->markTestSkipped('pdo_pgsql only test.');
}
/**
@@ -31,15 +33,15 @@ protected function setUp()
*/
public function testDatabaseParameters($databaseName, $defaultDatabaseName, $expectedDatabaseName)
{
- $params = $this->_conn->getParams();
- $params['dbname'] = $databaseName;
+ $params = $this->connection->getParams();
+ $params['dbname'] = $databaseName;
$params['default_dbname'] = $defaultDatabaseName;
$connection = new Connection(
$params,
- $this->_conn->getDriver(),
- $this->_conn->getConfiguration(),
- $this->_conn->getEventManager()
+ $this->connection->getDriver(),
+ $this->connection->getConfiguration(),
+ $this->connection->getEventManager()
);
self::assertSame(
@@ -50,17 +52,17 @@ public function testDatabaseParameters($databaseName, $defaultDatabaseName, $exp
public function getDatabaseParameter()
{
- $params = TestUtil::getConnection()->getParams();
- $realDatabaseName = $params['dbname'] ?? '';
+ $params = TestUtil::getConnection()->getParams();
+ $realDatabaseName = $params['dbname'] ?? '';
$dummyDatabaseName = $realDatabaseName . 'a';
- return array(
+ return [
// dbname, default_dbname, expected
- array($realDatabaseName, null, $realDatabaseName),
- array($realDatabaseName, $dummyDatabaseName, $realDatabaseName),
- array(null, $realDatabaseName, $realDatabaseName),
- array(null, null, $this->getDatabaseNameForConnectionWithoutDatabaseNameParameter()),
- );
+ [$realDatabaseName, null, $realDatabaseName],
+ [$realDatabaseName, $dummyDatabaseName, $realDatabaseName],
+ [null, $realDatabaseName, $realDatabaseName],
+ [null, null, $this->getDatabaseNameForConnectionWithoutDatabaseNameParameter()],
+ ];
}
/**
@@ -68,18 +70,18 @@ public function getDatabaseParameter()
*/
public function testConnectsWithApplicationNameParameter()
{
- $parameters = $this->_conn->getParams();
+ $parameters = $this->connection->getParams();
$parameters['application_name'] = 'doctrine';
- $user = $parameters['user'] ?? null;
+ $user = $parameters['user'] ?? null;
$password = $parameters['password'] ?? null;
$connection = $this->driver->connect($parameters, $user, $password);
- $hash = microtime(true); // required to identify the record in the results uniquely
- $sql = sprintf('SELECT * FROM pg_stat_activity WHERE %d = %d', $hash, $hash);
+ $hash = microtime(true); // required to identify the record in the results uniquely
+ $sql = sprintf('SELECT * FROM pg_stat_activity WHERE %d = %d', $hash, $hash);
$statement = $connection->query($sql);
- $records = $statement->fetchAll();
+ $records = $statement->fetchAll();
foreach ($records as $record) {
// The query column is named "current_query" on PostgreSQL < 9.2
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php
index 52c7cda4efa..0893bed2e70 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php
@@ -12,34 +12,35 @@ class PDOPgsqlConnectionTest extends DbalFunctionalTestCase
{
protected function setUp()
{
- if ( ! extension_loaded('pdo_pgsql')) {
+ if (! extension_loaded('pdo_pgsql')) {
$this->markTestSkipped('pdo_pgsql is not loaded.');
}
parent::setUp();
- if ( ! $this->_conn->getDatabasePlatform() instanceof PostgreSqlPlatform) {
- $this->markTestSkipped('PDOPgsql only test.');
+ if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
+ return;
}
+
+ $this->markTestSkipped('PDOPgsql only test.');
}
/**
+ * @param string $charset
+ *
* @group DBAL-1183
* @group DBAL-1189
- *
* @dataProvider getValidCharsets
- *
- * @param string $charset
*/
public function testConnectsWithValidCharsetOption($charset)
{
- $params = $this->_conn->getParams();
+ $params = $this->connection->getParams();
$params['charset'] = $charset;
$connection = DriverManager::getConnection(
$params,
- $this->_conn->getConfiguration(),
- $this->_conn->getEventManager()
+ $this->connection->getConfiguration(),
+ $this->connection->getEventManager()
);
self::assertEquals(
@@ -50,13 +51,13 @@ public function testConnectsWithValidCharsetOption($charset)
}
/**
- * @return array
+ * @return mixed[][]
*/
public function getValidCharsets()
{
- return array(
- array("UTF8"),
- array("LATIN1")
- );
+ return [
+ ['UTF8'],
+ ['LATIN1'],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php
index d292db1583c..36978d4b4fd 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php
@@ -16,9 +16,11 @@ protected function setUp()
parent::setUp();
- if (! $this->_conn->getDriver() instanceof Driver) {
- $this->markTestSkipped('pdo_sqlite only test.');
+ if ($this->connection->getDriver() instanceof Driver) {
+ return;
}
+
+ $this->markTestSkipped('pdo_sqlite only test.');
}
/**
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php
index 88c87d7e08b..f125eab3515 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php
@@ -2,7 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional\Driver\PDOSqlsrv;
-use Doctrine\DBAL\Driver\Connection as Connection;
+use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\PDOSqlsrv\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use PDO;
@@ -18,7 +18,7 @@ protected function setUp()
parent::setUp();
- if ($this->_conn->getDriver() instanceof Driver) {
+ if ($this->connection->getDriver() instanceof Driver) {
return;
}
@@ -46,7 +46,7 @@ protected function getDatabaseNameForConnectionWithoutDatabaseNameParameter()
*/
protected function getConnection(array $driverOptions) : Connection
{
- return $this->_conn->getDriver()->connect(
+ return $this->connection->getDriver()->connect(
[
'host' => $GLOBALS['db_host'],
'port' => $GLOBALS['db_port'],
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php
index 9f62612ca3b..63253a84408 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php
@@ -4,9 +4,10 @@
use Doctrine\DBAL\Driver\SQLAnywhere\Driver;
use Doctrine\DBAL\DriverManager;
+use Doctrine\Tests\DbalFunctionalTestCase;
use function extension_loaded;
-class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
+class ConnectionTest extends DbalFunctionalTestCase
{
protected function setUp()
{
@@ -16,14 +17,16 @@ protected function setUp()
parent::setUp();
- if (! $this->_conn->getDriver() instanceof Driver) {
- $this->markTestSkipped('sqlanywhere only test.');
+ if ($this->connection->getDriver() instanceof Driver) {
+ return;
}
+
+ $this->markTestSkipped('sqlanywhere only test.');
}
public function testNonPersistentConnection()
{
- $params = $this->_conn->getParams();
+ $params = $this->connection->getParams();
$params['persistent'] = false;
$conn = DriverManager::getConnection($params);
@@ -35,7 +38,7 @@ public function testNonPersistentConnection()
public function testPersistentConnection()
{
- $params = $this->_conn->getParams();
+ $params = $this->connection->getParams();
$params['persistent'] = true;
$conn = DriverManager::getConnection($params);
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php
index 172b6479e94..07d0189a88d 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php
@@ -17,21 +17,23 @@ protected function setUp()
parent::setUp();
- if (! $this->_conn->getDriver() instanceof Driver) {
- $this->markTestSkipped('sqlanywhere only test.');
+ if ($this->connection->getDriver() instanceof Driver) {
+ return;
}
+
+ $this->markTestSkipped('sqlanywhere only test.');
}
public function testReturnsDatabaseNameWithoutDatabaseNameParameter()
{
- $params = $this->_conn->getParams();
+ $params = $this->connection->getParams();
unset($params['dbname']);
$connection = new Connection(
$params,
- $this->_conn->getDriver(),
- $this->_conn->getConfiguration(),
- $this->_conn->getEventManager()
+ $this->connection->getDriver(),
+ $this->connection->getConfiguration(),
+ $this->connection->getEventManager()
);
// SQL Anywhere has no "default" database. The name of the default database
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php
index 4fbc16acf27..3cf5c282ea0 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php
@@ -4,9 +4,10 @@
use Doctrine\DBAL\Driver\SQLAnywhere\Driver;
use Doctrine\DBAL\DriverManager;
+use Doctrine\Tests\DbalFunctionalTestCase;
use function extension_loaded;
-class StatementTest extends \Doctrine\Tests\DbalFunctionalTestCase
+class StatementTest extends DbalFunctionalTestCase
{
protected function setUp()
{
@@ -16,39 +17,40 @@ protected function setUp()
parent::setUp();
- if (! $this->_conn->getDriver() instanceof Driver) {
- $this->markTestSkipped('sqlanywhere only test.');
+ if ($this->connection->getDriver() instanceof Driver) {
+ return;
}
+
+ $this->markTestSkipped('sqlanywhere only test.');
}
public function testNonPersistentStatement()
{
- $params = $this->_conn->getParams();
+ $params = $this->connection->getParams();
$params['persistent'] = false;
$conn = DriverManager::getConnection($params);
$conn->connect();
- self::assertTrue($conn->isConnected(),'No SQLAnywhere-Connection established');
+ self::assertTrue($conn->isConnected(), 'No SQLAnywhere-Connection established');
$prepStmt = $conn->prepare('SELECT 1');
- self::assertTrue($prepStmt->execute(),' Statement non-persistent failed');
+ self::assertTrue($prepStmt->execute(), ' Statement non-persistent failed');
}
public function testPersistentStatement()
{
- $params = $this->_conn->getParams();
+ $params = $this->connection->getParams();
$params['persistent'] = true;
$conn = DriverManager::getConnection($params);
$conn->connect();
- self::assertTrue($conn->isConnected(),'No SQLAnywhere-Connection established');
+ self::assertTrue($conn->isConnected(), 'No SQLAnywhere-Connection established');
$prepStmt = $conn->prepare('SELECT 1');
- self::assertTrue($prepStmt->execute(),' Statement persistent failed');
+ self::assertTrue($prepStmt->execute(), ' Statement persistent failed');
}
-
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php
index aa7ed63a3e1..b09d7339fc9 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php
@@ -16,9 +16,11 @@ protected function setUp()
parent::setUp();
- if (! $this->_conn->getDriver() instanceof Driver) {
- $this->markTestSkipped('sqlsrv only test.');
+ if ($this->connection->getDriver() instanceof Driver) {
+ return;
}
+
+ $this->markTestSkipped('sqlsrv only test.');
}
/**
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php
index 6c9ea327a62..38df9cb5181 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php
@@ -11,21 +11,23 @@ class StatementTest extends DbalFunctionalTestCase
{
protected function setUp()
{
- if (!extension_loaded('sqlsrv')) {
+ if (! extension_loaded('sqlsrv')) {
self::markTestSkipped('sqlsrv is not installed.');
}
parent::setUp();
- if (!$this->_conn->getDriver() instanceof Driver) {
- self::markTestSkipped('sqlsrv only test');
+ if ($this->connection->getDriver() instanceof Driver) {
+ return;
}
+
+ self::markTestSkipped('sqlsrv only test');
}
public function testFailureToPrepareResultsInException()
{
// use the driver connection directly to avoid having exception wrapped
- $stmt = $this->_conn->getWrappedConnection()->prepare(null);
+ $stmt = $this->connection->getWrappedConnection()->prepare(null);
// it's impossible to prepare the statement without bound variables for SQL Server,
// so the preparation happens before the first execution when variables are already in place
diff --git a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
index a8c73ce33c5..e420000ba58 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
@@ -1,9 +1,14 @@
_conn->getDriver() instanceof ExceptionConverterDriver)) {
- $this->markTestSkipped('Driver does not support special exception handling.');
+ if ($this->connection->getDriver() instanceof ExceptionConverterDriver) {
+ return;
}
+
+ $this->markTestSkipped('Driver does not support special exception handling.');
}
public function testPrimaryConstraintViolationException()
{
- $table = new \Doctrine\DBAL\Schema\Table("duplicatekey_table");
- $table->addColumn('id', 'integer', array());
- $table->setPrimaryKey(array('id'));
+ $table = new Table('duplicatekey_table');
+ $table->addColumn('id', 'integer', []);
+ $table->setPrimaryKey(['id']);
- $this->_conn->getSchemaManager()->createTable($table);
+ $this->connection->getSchemaManager()->createTable($table);
- $this->_conn->insert("duplicatekey_table", array('id' => 1));
+ $this->connection->insert('duplicatekey_table', ['id' => 1]);
$this->expectException(Exception\UniqueConstraintViolationException::class);
- $this->_conn->insert("duplicatekey_table", array('id' => 1));
+ $this->connection->insert('duplicatekey_table', ['id' => 1]);
}
public function testTableNotFoundException()
{
- $sql = "SELECT * FROM unknown_table";
+ $sql = 'SELECT * FROM unknown_table';
$this->expectException(Exception\TableNotFoundException::class);
- $this->_conn->executeQuery($sql);
+ $this->connection->executeQuery($sql);
}
public function testTableExistsException()
{
- $schemaManager = $this->_conn->getSchemaManager();
- $table = new \Doctrine\DBAL\Schema\Table("alreadyexist_table");
- $table->addColumn('id', 'integer', array());
- $table->setPrimaryKey(array('id'));
+ $schemaManager = $this->connection->getSchemaManager();
+ $table = new Table('alreadyexist_table');
+ $table->addColumn('id', 'integer', []);
+ $table->setPrimaryKey(['id']);
$this->expectException(Exception\TableExistsException::class);
$schemaManager->createTable($table);
@@ -60,16 +67,16 @@ public function testTableExistsException()
public function testForeignKeyConstraintViolationExceptionOnInsert()
{
- if ( ! $this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) {
- $this->markTestSkipped("Only fails on platforms with foreign key constraints.");
+ if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) {
+ $this->markTestSkipped('Only fails on platforms with foreign key constraints.');
}
$this->setUpForeignKeyConstraintViolationExceptionTest();
try {
- $this->_conn->insert("constraint_error_table", array('id' => 1));
- $this->_conn->insert("owning_table", array('id' => 1, 'constraint_id' => 1));
- } catch (\Exception $exception) {
+ $this->connection->insert('constraint_error_table', ['id' => 1]);
+ $this->connection->insert('owning_table', ['id' => 1, 'constraint_id' => 1]);
+ } catch (Throwable $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();
throw $exception;
@@ -78,12 +85,12 @@ public function testForeignKeyConstraintViolationExceptionOnInsert()
$this->expectException(Exception\ForeignKeyConstraintViolationException::class);
try {
- $this->_conn->insert('owning_table', array('id' => 2, 'constraint_id' => 2));
+ $this->connection->insert('owning_table', ['id' => 2, 'constraint_id' => 2]);
} catch (Exception\ForeignKeyConstraintViolationException $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();
throw $exception;
- } catch (\Exception $exception) {
+ } catch (Throwable $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();
throw $exception;
@@ -94,16 +101,16 @@ public function testForeignKeyConstraintViolationExceptionOnInsert()
public function testForeignKeyConstraintViolationExceptionOnUpdate()
{
- if ( ! $this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) {
- $this->markTestSkipped("Only fails on platforms with foreign key constraints.");
+ if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) {
+ $this->markTestSkipped('Only fails on platforms with foreign key constraints.');
}
$this->setUpForeignKeyConstraintViolationExceptionTest();
try {
- $this->_conn->insert("constraint_error_table", array('id' => 1));
- $this->_conn->insert("owning_table", array('id' => 1, 'constraint_id' => 1));
- } catch (\Exception $exception) {
+ $this->connection->insert('constraint_error_table', ['id' => 1]);
+ $this->connection->insert('owning_table', ['id' => 1, 'constraint_id' => 1]);
+ } catch (Throwable $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();
throw $exception;
@@ -112,12 +119,12 @@ public function testForeignKeyConstraintViolationExceptionOnUpdate()
$this->expectException(Exception\ForeignKeyConstraintViolationException::class);
try {
- $this->_conn->update('constraint_error_table', array('id' => 2), array('id' => 1));
+ $this->connection->update('constraint_error_table', ['id' => 2], ['id' => 1]);
} catch (Exception\ForeignKeyConstraintViolationException $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();
throw $exception;
- } catch (\Exception $exception) {
+ } catch (Throwable $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();
throw $exception;
@@ -128,16 +135,16 @@ public function testForeignKeyConstraintViolationExceptionOnUpdate()
public function testForeignKeyConstraintViolationExceptionOnDelete()
{
- if ( ! $this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) {
- $this->markTestSkipped("Only fails on platforms with foreign key constraints.");
+ if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) {
+ $this->markTestSkipped('Only fails on platforms with foreign key constraints.');
}
$this->setUpForeignKeyConstraintViolationExceptionTest();
try {
- $this->_conn->insert("constraint_error_table", array('id' => 1));
- $this->_conn->insert("owning_table", array('id' => 1, 'constraint_id' => 1));
- } catch (\Exception $exception) {
+ $this->connection->insert('constraint_error_table', ['id' => 1]);
+ $this->connection->insert('owning_table', ['id' => 1, 'constraint_id' => 1]);
+ } catch (Throwable $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();
throw $exception;
@@ -146,12 +153,12 @@ public function testForeignKeyConstraintViolationExceptionOnDelete()
$this->expectException(Exception\ForeignKeyConstraintViolationException::class);
try {
- $this->_conn->delete('constraint_error_table', array('id' => 1));
+ $this->connection->delete('constraint_error_table', ['id' => 1]);
} catch (Exception\ForeignKeyConstraintViolationException $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();
throw $exception;
- } catch (\Exception $exception) {
+ } catch (Throwable $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();
throw $exception;
@@ -162,18 +169,18 @@ public function testForeignKeyConstraintViolationExceptionOnDelete()
public function testForeignKeyConstraintViolationExceptionOnTruncate()
{
- $platform = $this->_conn->getDatabasePlatform();
+ $platform = $this->connection->getDatabasePlatform();
- if (!$platform->supportsForeignKeyConstraints()) {
- $this->markTestSkipped("Only fails on platforms with foreign key constraints.");
+ if (! $platform->supportsForeignKeyConstraints()) {
+ $this->markTestSkipped('Only fails on platforms with foreign key constraints.');
}
$this->setUpForeignKeyConstraintViolationExceptionTest();
try {
- $this->_conn->insert("constraint_error_table", array('id' => 1));
- $this->_conn->insert("owning_table", array('id' => 1, 'constraint_id' => 1));
- } catch (\Exception $exception) {
+ $this->connection->insert('constraint_error_table', ['id' => 1]);
+ $this->connection->insert('owning_table', ['id' => 1, 'constraint_id' => 1]);
+ } catch (Throwable $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();
throw $exception;
@@ -182,12 +189,12 @@ public function testForeignKeyConstraintViolationExceptionOnTruncate()
$this->expectException(Exception\ForeignKeyConstraintViolationException::class);
try {
- $this->_conn->executeUpdate($platform->getTruncateTableSQL('constraint_error_table'));
+ $this->connection->executeUpdate($platform->getTruncateTableSQL('constraint_error_table'));
} catch (Exception\ForeignKeyConstraintViolationException $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();
throw $exception;
- } catch (\Exception $exception) {
+ } catch (Throwable $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();
throw $exception;
@@ -198,83 +205,83 @@ public function testForeignKeyConstraintViolationExceptionOnTruncate()
public function testNotNullConstraintViolationException()
{
- $schema = new \Doctrine\DBAL\Schema\Schema();
+ $schema = new Schema();
- $table = $schema->createTable("notnull_table");
- $table->addColumn('id', 'integer', array());
- $table->addColumn('value', 'integer', array('notnull' => true));
- $table->setPrimaryKey(array('id'));
+ $table = $schema->createTable('notnull_table');
+ $table->addColumn('id', 'integer', []);
+ $table->addColumn('value', 'integer', ['notnull' => true]);
+ $table->setPrimaryKey(['id']);
- foreach ($schema->toSql($this->_conn->getDatabasePlatform()) as $sql) {
- $this->_conn->exec($sql);
+ foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
+ $this->connection->exec($sql);
}
$this->expectException(Exception\NotNullConstraintViolationException::class);
- $this->_conn->insert("notnull_table", array('id' => 1, 'value' => null));
+ $this->connection->insert('notnull_table', ['id' => 1, 'value' => null]);
}
public function testInvalidFieldNameException()
{
- $schema = new \Doctrine\DBAL\Schema\Schema();
+ $schema = new Schema();
- $table = $schema->createTable("bad_fieldname_table");
- $table->addColumn('id', 'integer', array());
+ $table = $schema->createTable('bad_fieldname_table');
+ $table->addColumn('id', 'integer', []);
- foreach ($schema->toSql($this->_conn->getDatabasePlatform()) as $sql) {
- $this->_conn->exec($sql);
+ foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
+ $this->connection->exec($sql);
}
$this->expectException(Exception\InvalidFieldNameException::class);
- $this->_conn->insert("bad_fieldname_table", array('name' => 5));
+ $this->connection->insert('bad_fieldname_table', ['name' => 5]);
}
public function testNonUniqueFieldNameException()
{
- $schema = new \Doctrine\DBAL\Schema\Schema();
+ $schema = new Schema();
- $table = $schema->createTable("ambiguous_list_table");
+ $table = $schema->createTable('ambiguous_list_table');
$table->addColumn('id', 'integer');
- $table2 = $schema->createTable("ambiguous_list_table_2");
+ $table2 = $schema->createTable('ambiguous_list_table_2');
$table2->addColumn('id', 'integer');
- foreach ($schema->toSql($this->_conn->getDatabasePlatform()) as $sql) {
- $this->_conn->exec($sql);
+ foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
+ $this->connection->exec($sql);
}
$sql = 'SELECT id FROM ambiguous_list_table, ambiguous_list_table_2';
$this->expectException(Exception\NonUniqueFieldNameException::class);
- $this->_conn->executeQuery($sql);
+ $this->connection->executeQuery($sql);
}
public function testUniqueConstraintViolationException()
{
- $schema = new \Doctrine\DBAL\Schema\Schema();
+ $schema = new Schema();
- $table = $schema->createTable("unique_field_table");
+ $table = $schema->createTable('unique_field_table');
$table->addColumn('id', 'integer');
- $table->addUniqueIndex(array('id'));
+ $table->addUniqueIndex(['id']);
- foreach ($schema->toSql($this->_conn->getDatabasePlatform()) as $sql) {
- $this->_conn->exec($sql);
+ foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
+ $this->connection->exec($sql);
}
- $this->_conn->insert("unique_field_table", array('id' => 5));
+ $this->connection->insert('unique_field_table', ['id' => 5]);
$this->expectException(Exception\UniqueConstraintViolationException::class);
- $this->_conn->insert("unique_field_table", array('id' => 5));
+ $this->connection->insert('unique_field_table', ['id' => 5]);
}
public function testSyntaxErrorException()
{
- $table = new \Doctrine\DBAL\Schema\Table("syntax_error_table");
- $table->addColumn('id', 'integer', array());
- $table->setPrimaryKey(array('id'));
+ $table = new Table('syntax_error_table');
+ $table->addColumn('id', 'integer', []);
+ $table->setPrimaryKey(['id']);
- $this->_conn->getSchemaManager()->createTable($table);
+ $this->connection->getSchemaManager()->createTable($table);
$sql = 'SELECT id FRO syntax_error_table';
$this->expectException(Exception\SyntaxErrorException::class);
- $this->_conn->executeQuery($sql);
+ $this->connection->executeQuery($sql);
}
/**
@@ -282,11 +289,11 @@ public function testSyntaxErrorException()
*/
public function testConnectionExceptionSqLite($mode, $exceptionClass)
{
- if ($this->_conn->getDatabasePlatform()->getName() != 'sqlite') {
- $this->markTestSkipped("Only fails this way on sqlite");
+ if ($this->connection->getDatabasePlatform()->getName() !== 'sqlite') {
+ $this->markTestSkipped('Only fails this way on sqlite');
}
- $filename = sprintf('%s/%s', sys_get_temp_dir(), 'doctrine_failed_connection_'.$mode.'.db');
+ $filename = sprintf('%s/%s', sys_get_temp_dir(), 'doctrine_failed_connection_' . $mode . '.db');
if (file_exists($filename)) {
chmod($filename, 0200); // make the file writable again, so it can be removed on Windows
@@ -296,14 +303,14 @@ public function testConnectionExceptionSqLite($mode, $exceptionClass)
touch($filename);
chmod($filename, $mode);
- $params = array(
+ $params = [
'driver' => 'pdo_sqlite',
'path' => $filename,
- );
- $conn = \Doctrine\DBAL\DriverManager::getConnection($params);
+ ];
+ $conn = DriverManager::getConnection($params);
- $schema = new \Doctrine\DBAL\Schema\Schema();
- $table = $schema->createTable("no_connection");
+ $schema = new Schema();
+ $table = $schema->createTable('no_connection');
$table->addColumn('id', 'integer');
$this->expectException($exceptionClass);
@@ -314,11 +321,11 @@ public function testConnectionExceptionSqLite($mode, $exceptionClass)
public function getSqLiteOpenConnection()
{
- return array(
+ return [
// mode 0 is considered read-only on Windows
- array(0000, defined('PHP_WINDOWS_VERSION_BUILD') ? Exception\ReadOnlyException::class : Exception\ConnectionException::class),
- array(0444, Exception\ReadOnlyException::class),
- );
+ [0000, defined('PHP_WINDOWS_VERSION_BUILD') ? Exception\ReadOnlyException::class : Exception\ConnectionException::class],
+ [0444, Exception\ReadOnlyException::class],
+ ];
}
/**
@@ -326,25 +333,25 @@ public function getSqLiteOpenConnection()
*/
public function testConnectionException($params)
{
- if ($this->_conn->getDatabasePlatform()->getName() == 'sqlite') {
- $this->markTestSkipped("Only skipped if platform is not sqlite");
+ if ($this->connection->getDatabasePlatform()->getName() === 'sqlite') {
+ $this->markTestSkipped('Only skipped if platform is not sqlite');
}
- if ($this->_conn->getDatabasePlatform()->getName() == 'drizzle') {
- $this->markTestSkipped("Drizzle does not always support authentication");
+ if ($this->connection->getDatabasePlatform()->getName() === 'drizzle') {
+ $this->markTestSkipped('Drizzle does not always support authentication');
}
- if ($this->_conn->getDatabasePlatform()->getName() == 'postgresql' && isset($params['password'])) {
- $this->markTestSkipped("Does not work on Travis");
+ if ($this->connection->getDatabasePlatform()->getName() === 'postgresql' && isset($params['password'])) {
+ $this->markTestSkipped('Does not work on Travis');
}
- $defaultParams = $this->_conn->getParams();
- $params = array_merge($defaultParams, $params);
+ $defaultParams = $this->connection->getParams();
+ $params = array_merge($defaultParams, $params);
- $conn = \Doctrine\DBAL\DriverManager::getConnection($params);
+ $conn = DriverManager::getConnection($params);
- $schema = new \Doctrine\DBAL\Schema\Schema();
- $table = $schema->createTable("no_connection");
+ $schema = new Schema();
+ $table = $schema->createTable('no_connection');
$table->addColumn('id', 'integer');
$this->expectException(Exception\ConnectionException::class);
@@ -356,26 +363,26 @@ public function testConnectionException($params)
public function getConnectionParams()
{
- return array(
- array(array('user' => 'not_existing')),
- array(array('password' => 'really_not')),
- array(array('host' => 'localnope')),
- );
+ return [
+ [['user' => 'not_existing']],
+ [['password' => 'really_not']],
+ [['host' => 'localnope']],
+ ];
}
private function setUpForeignKeyConstraintViolationExceptionTest()
{
- $schemaManager = $this->_conn->getSchemaManager();
+ $schemaManager = $this->connection->getSchemaManager();
- $table = new Table("constraint_error_table");
- $table->addColumn('id', 'integer', array());
- $table->setPrimaryKey(array('id'));
+ $table = new Table('constraint_error_table');
+ $table->addColumn('id', 'integer', []);
+ $table->setPrimaryKey(['id']);
- $owningTable = new Table("owning_table");
- $owningTable->addColumn('id', 'integer', array());
- $owningTable->addColumn('constraint_id', 'integer', array());
- $owningTable->setPrimaryKey(array('id'));
- $owningTable->addForeignKeyConstraint($table, array('constraint_id'), array('id'));
+ $owningTable = new Table('owning_table');
+ $owningTable->addColumn('id', 'integer', []);
+ $owningTable->addColumn('constraint_id', 'integer', []);
+ $owningTable->setPrimaryKey(['id']);
+ $owningTable->addForeignKeyConstraint($table, ['constraint_id'], ['id']);
$schemaManager->createTable($table);
$schemaManager->createTable($owningTable);
@@ -383,7 +390,7 @@ private function setUpForeignKeyConstraintViolationExceptionTest()
private function tearDownForeignKeyConstraintViolationExceptionTest()
{
- $schemaManager = $this->_conn->getSchemaManager();
+ $schemaManager = $this->connection->getSchemaManager();
$schemaManager->dropTable('owning_table');
$schemaManager->dropTable('constraint_error_table');
diff --git a/tests/Doctrine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php b/tests/Doctrine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php
index 9f2a098d7f5..e172816f2af 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php
@@ -4,7 +4,6 @@
use Doctrine\Tests\DbalFunctionalTestCase;
use function sprintf;
-use function str_replace;
final class LikeWildcardsEscapingTest extends DbalFunctionalTestCase
{
@@ -12,8 +11,8 @@ public function testFetchLikeExpressionResult() : void
{
$string = '_25% off_ your next purchase \o/ [$̲̅(̲̅5̲̅)̲̅$̲̅] (^̮^)';
$escapeChar = '!';
- $databasePlatform = $this->_conn->getDatabasePlatform();
- $stmt = $this->_conn->prepare(
+ $databasePlatform = $this->connection->getDatabasePlatform();
+ $stmt = $this->connection->prepare(
$databasePlatform->getDummySelectSQL(
sprintf(
"(CASE WHEN '%s' LIKE '%s' ESCAPE '%s' THEN 1 ELSE 0 END)",
diff --git a/tests/Doctrine/Tests/DBAL/Functional/LoggingTest.php b/tests/Doctrine/Tests/DBAL/Functional/LoggingTest.php
index f32520485ef..99ca533e742 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/LoggingTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/LoggingTest.php
@@ -2,51 +2,54 @@
namespace Doctrine\Tests\DBAL\Functional;
-class LoggingTest extends \Doctrine\Tests\DbalFunctionalTestCase
+use Doctrine\DBAL\Logging\SQLLogger;
+use Doctrine\Tests\DbalFunctionalTestCase;
+
+class LoggingTest extends DbalFunctionalTestCase
{
public function testLogExecuteQuery()
{
- $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL();
+ $sql = $this->connection->getDatabasePlatform()->getDummySelectSQL();
- $logMock = $this->createMock('Doctrine\DBAL\Logging\SQLLogger');
+ $logMock = $this->createMock(SQLLogger::class);
$logMock->expects($this->at(0))
->method('startQuery')
- ->with($this->equalTo($sql), $this->equalTo(array()), $this->equalTo(array()));
+ ->with($this->equalTo($sql), $this->equalTo([]), $this->equalTo([]));
$logMock->expects($this->at(1))
->method('stopQuery');
- $this->_conn->getConfiguration()->setSQLLogger($logMock);
- $this->_conn->executeQuery($sql, array());
+ $this->connection->getConfiguration()->setSQLLogger($logMock);
+ $this->connection->executeQuery($sql, []);
}
public function testLogExecuteUpdate()
{
$this->markTestSkipped('Test breaks MySQL but works on all other platforms (Unbuffered Queries stuff).');
- $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL();
+ $sql = $this->connection->getDatabasePlatform()->getDummySelectSQL();
- $logMock = $this->createMock('Doctrine\DBAL\Logging\SQLLogger');
+ $logMock = $this->createMock(SQLLogger::class);
$logMock->expects($this->at(0))
->method('startQuery')
- ->with($this->equalTo($sql), $this->equalTo(array()), $this->equalTo(array()));
+ ->with($this->equalTo($sql), $this->equalTo([]), $this->equalTo([]));
$logMock->expects($this->at(1))
->method('stopQuery');
- $this->_conn->getConfiguration()->setSQLLogger($logMock);
- $this->_conn->executeUpdate($sql, array());
+ $this->connection->getConfiguration()->setSQLLogger($logMock);
+ $this->connection->executeUpdate($sql, []);
}
public function testLogPrepareExecute()
{
- $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL();
+ $sql = $this->connection->getDatabasePlatform()->getDummySelectSQL();
- $logMock = $this->createMock('Doctrine\DBAL\Logging\SQLLogger');
+ $logMock = $this->createMock(SQLLogger::class);
$logMock->expects($this->once())
->method('startQuery')
- ->with($this->equalTo($sql), $this->equalTo(array()));
+ ->with($this->equalTo($sql), $this->equalTo([]));
$logMock->expects($this->at(1))
->method('stopQuery');
- $this->_conn->getConfiguration()->setSQLLogger($logMock);
+ $this->connection->getConfiguration()->setSQLLogger($logMock);
- $stmt = $this->_conn->prepare($sql);
+ $stmt = $this->connection->prepare($sql);
$stmt->execute();
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php
index 8b4c01e31d2..81747c3a996 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php
@@ -4,7 +4,10 @@
use Doctrine\DBAL\Connections\MasterSlaveConnection;
use Doctrine\DBAL\DriverManager;
+use Doctrine\DBAL\Schema\AbstractSchemaManager;
+use Doctrine\DBAL\Schema\Table;
use Doctrine\Tests\DbalFunctionalTestCase;
+use Throwable;
use const CASE_LOWER;
use function array_change_key_case;
use function sprintf;
@@ -21,28 +24,26 @@ protected function setUp()
{
parent::setUp();
- $platformName = $this->_conn->getDatabasePlatform()->getName();
+ $platformName = $this->connection->getDatabasePlatform()->getName();
// This is a MySQL specific test, skip other vendors.
- if ($platformName != 'mysql') {
+ if ($platformName !== 'mysql') {
$this->markTestSkipped(sprintf('Test does not work on %s.', $platformName));
}
try {
- /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
- $table = new \Doctrine\DBAL\Schema\Table("master_slave_table");
+ /** @var AbstractSchemaManager $sm */
+ $table = new Table('master_slave_table');
$table->addColumn('test_int', 'integer');
- $table->setPrimaryKey(array('test_int'));
+ $table->setPrimaryKey(['test_int']);
- $sm = $this->_conn->getSchemaManager();
+ $sm = $this->connection->getSchemaManager();
$sm->createTable($table);
-
-
- } catch(\Exception $e) {
+ } catch (Throwable $e) {
}
- $this->_conn->executeUpdate('DELETE FROM master_slave_table');
- $this->_conn->insert('master_slave_table', array('test_int' => 1));
+ $this->connection->executeUpdate('DELETE FROM master_slave_table');
+ $this->connection->insert('master_slave_table', ['test_int' => 1]);
}
private function createMasterSlaveConnection(bool $keepSlave = false) : MasterSlaveConnection
@@ -50,11 +51,14 @@ private function createMasterSlaveConnection(bool $keepSlave = false) : MasterSl
return DriverManager::getConnection($this->createMasterSlaveConnectionParams($keepSlave));
}
+ /**
+ * @return mixed[]
+ */
private function createMasterSlaveConnectionParams(bool $keepSlave = false) : array
{
- $params = $this->_conn->getParams();
+ $params = $this->connection->getParams();
$params['master'] = $params;
- $params['slaves'] = array($params, $params);
+ $params['slaves'] = [$params, $params];
$params['keepSlave'] = $keepSlave;
$params['wrapperClass'] = MasterSlaveConnection::class;
@@ -65,17 +69,19 @@ public function testInheritCharsetFromMaster() : void
{
$charsets = [
'utf8',
- 'latin1'
+ 'latin1',
];
foreach ($charsets as $charset) {
- $params = $this->createMasterSlaveConnectionParams();
+ $params = $this->createMasterSlaveConnectionParams();
$params['master']['charset'] = $charset;
foreach ($params['slaves'] as $index => $slaveParams) {
- if (isset($slaveParams['charset'])) {
- unset($params['slaves'][$index]['charset']);
+ if (! isset($slaveParams['charset'])) {
+ continue;
}
+
+ unset($params['slaves'][$index]['charset']);
}
/** @var MasterSlaveConnection $conn */
@@ -108,8 +114,8 @@ public function testNoMasterOnExecuteQuery()
{
$conn = $this->createMasterSlaveConnection();
- $sql = "SELECT count(*) as num FROM master_slave_table";
- $data = $conn->fetchAll($sql);
+ $sql = 'SELECT count(*) as num FROM master_slave_table';
+ $data = $conn->fetchAll($sql);
$data[0] = array_change_key_case($data[0], CASE_LOWER);
self::assertEquals(1, $data[0]['num']);
@@ -119,12 +125,12 @@ public function testNoMasterOnExecuteQuery()
public function testMasterOnWriteOperation()
{
$conn = $this->createMasterSlaveConnection();
- $conn->insert('master_slave_table', array('test_int' => 30));
+ $conn->insert('master_slave_table', ['test_int' => 30]);
self::assertTrue($conn->isConnectedToMaster());
- $sql = "SELECT count(*) as num FROM master_slave_table";
- $data = $conn->fetchAll($sql);
+ $sql = 'SELECT count(*) as num FROM master_slave_table';
+ $data = $conn->fetchAll($sql);
$data[0] = array_change_key_case($data[0], CASE_LOWER);
self::assertEquals(2, $data[0]['num']);
@@ -140,7 +146,7 @@ public function testKeepSlaveBeginTransactionStaysOnMaster()
$conn->connect('slave');
$conn->beginTransaction();
- $conn->insert('master_slave_table', array('test_int' => 30));
+ $conn->insert('master_slave_table', ['test_int' => 30]);
$conn->commit();
self::assertTrue($conn->isConnectedToMaster());
@@ -160,7 +166,7 @@ public function testKeepSlaveInsertStaysOnMaster()
$conn = $this->createMasterSlaveConnection($keepSlave = true);
$conn->connect('slave');
- $conn->insert('master_slave_table', array('test_int' => 30));
+ $conn->insert('master_slave_table', ['test_int' => 30]);
self::assertTrue($conn->isConnectedToMaster());
diff --git a/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php b/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php
index 6cd36b74e7e..87f326abdca 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php
@@ -1,141 +1,143 @@
addColumn('test_int', 'integer');
- $table->setPrimaryKey(array('test_int'));
+ $table->setPrimaryKey(['test_int']);
- $table2 = new \Doctrine\DBAL\Schema\Table("modify_limit_table2");
- $table2->addColumn('id', 'integer', array('autoincrement' => true));
+ $table2 = new Table('modify_limit_table2');
+ $table2->addColumn('id', 'integer', ['autoincrement' => true]);
$table2->addColumn('test_int', 'integer');
- $table2->setPrimaryKey(array('id'));
+ $table2->setPrimaryKey(['id']);
- $sm = $this->_conn->getSchemaManager();
+ $sm = $this->connection->getSchemaManager();
$sm->createTable($table);
$sm->createTable($table2);
self::$tableCreated = true;
}
- $this->_conn->exec($this->_conn->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table'));
- $this->_conn->exec($this->_conn->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table2'));
+ $this->connection->exec($this->connection->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table'));
+ $this->connection->exec($this->connection->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table2'));
}
public function testModifyLimitQuerySimpleQuery()
{
- $this->_conn->insert('modify_limit_table', array('test_int' => 1));
- $this->_conn->insert('modify_limit_table', array('test_int' => 2));
- $this->_conn->insert('modify_limit_table', array('test_int' => 3));
- $this->_conn->insert('modify_limit_table', array('test_int' => 4));
+ $this->connection->insert('modify_limit_table', ['test_int' => 1]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 2]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 3]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 4]);
- $sql = "SELECT * FROM modify_limit_table ORDER BY test_int ASC";
+ $sql = 'SELECT * FROM modify_limit_table ORDER BY test_int ASC';
- $this->assertLimitResult(array(1, 2, 3, 4), $sql, 10, 0);
- $this->assertLimitResult(array(1, 2), $sql, 2, 0);
- $this->assertLimitResult(array(3, 4), $sql, 2, 2);
- $this->assertLimitResult(array(2, 3, 4), $sql, null, 1);
+ $this->assertLimitResult([1, 2, 3, 4], $sql, 10, 0);
+ $this->assertLimitResult([1, 2], $sql, 2, 0);
+ $this->assertLimitResult([3, 4], $sql, 2, 2);
+ $this->assertLimitResult([2, 3, 4], $sql, null, 1);
}
public function testModifyLimitQueryJoinQuery()
{
- $this->_conn->insert('modify_limit_table', array('test_int' => 1));
- $this->_conn->insert('modify_limit_table', array('test_int' => 2));
+ $this->connection->insert('modify_limit_table', ['test_int' => 1]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 2]);
- $this->_conn->insert('modify_limit_table2', array('test_int' => 1));
- $this->_conn->insert('modify_limit_table2', array('test_int' => 1));
- $this->_conn->insert('modify_limit_table2', array('test_int' => 1));
- $this->_conn->insert('modify_limit_table2', array('test_int' => 2));
- $this->_conn->insert('modify_limit_table2', array('test_int' => 2));
+ $this->connection->insert('modify_limit_table2', ['test_int' => 1]);
+ $this->connection->insert('modify_limit_table2', ['test_int' => 1]);
+ $this->connection->insert('modify_limit_table2', ['test_int' => 1]);
+ $this->connection->insert('modify_limit_table2', ['test_int' => 2]);
+ $this->connection->insert('modify_limit_table2', ['test_int' => 2]);
- $sql = "SELECT modify_limit_table.test_int FROM modify_limit_table INNER JOIN modify_limit_table2 ON modify_limit_table.test_int = modify_limit_table2.test_int ORDER BY modify_limit_table.test_int DESC";
+ $sql = 'SELECT modify_limit_table.test_int FROM modify_limit_table INNER JOIN modify_limit_table2 ON modify_limit_table.test_int = modify_limit_table2.test_int ORDER BY modify_limit_table.test_int DESC';
- $this->assertLimitResult(array(2, 2, 1, 1, 1), $sql, 10, 0);
- $this->assertLimitResult(array(1, 1, 1), $sql, 3, 2);
- $this->assertLimitResult(array(2, 2), $sql, 2, 0);
+ $this->assertLimitResult([2, 2, 1, 1, 1], $sql, 10, 0);
+ $this->assertLimitResult([1, 1, 1], $sql, 3, 2);
+ $this->assertLimitResult([2, 2], $sql, 2, 0);
}
public function testModifyLimitQueryNonDeterministic()
{
- $this->_conn->insert('modify_limit_table', array('test_int' => 1));
- $this->_conn->insert('modify_limit_table', array('test_int' => 2));
- $this->_conn->insert('modify_limit_table', array('test_int' => 3));
- $this->_conn->insert('modify_limit_table', array('test_int' => 4));
+ $this->connection->insert('modify_limit_table', ['test_int' => 1]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 2]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 3]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 4]);
- $sql = "SELECT * FROM modify_limit_table";
+ $sql = 'SELECT * FROM modify_limit_table';
- $this->assertLimitResult(array(4, 3, 2, 1), $sql, 10, 0, false);
- $this->assertLimitResult(array(4, 3), $sql, 2, 0, false);
- $this->assertLimitResult(array(2, 1), $sql, 2, 2, false);
+ $this->assertLimitResult([4, 3, 2, 1], $sql, 10, 0, false);
+ $this->assertLimitResult([4, 3], $sql, 2, 0, false);
+ $this->assertLimitResult([2, 1], $sql, 2, 2, false);
}
public function testModifyLimitQueryGroupBy()
{
- $this->_conn->insert('modify_limit_table', array('test_int' => 1));
- $this->_conn->insert('modify_limit_table', array('test_int' => 2));
-
- $this->_conn->insert('modify_limit_table2', array('test_int' => 1));
- $this->_conn->insert('modify_limit_table2', array('test_int' => 1));
- $this->_conn->insert('modify_limit_table2', array('test_int' => 1));
- $this->_conn->insert('modify_limit_table2', array('test_int' => 2));
- $this->_conn->insert('modify_limit_table2', array('test_int' => 2));
-
- $sql = "SELECT modify_limit_table.test_int FROM modify_limit_table " .
- "INNER JOIN modify_limit_table2 ON modify_limit_table.test_int = modify_limit_table2.test_int ".
- "GROUP BY modify_limit_table.test_int " .
- "ORDER BY modify_limit_table.test_int ASC";
- $this->assertLimitResult(array(1, 2), $sql, 10, 0);
- $this->assertLimitResult(array(1), $sql, 1, 0);
- $this->assertLimitResult(array(2), $sql, 1, 1);
+ $this->connection->insert('modify_limit_table', ['test_int' => 1]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 2]);
+
+ $this->connection->insert('modify_limit_table2', ['test_int' => 1]);
+ $this->connection->insert('modify_limit_table2', ['test_int' => 1]);
+ $this->connection->insert('modify_limit_table2', ['test_int' => 1]);
+ $this->connection->insert('modify_limit_table2', ['test_int' => 2]);
+ $this->connection->insert('modify_limit_table2', ['test_int' => 2]);
+
+ $sql = 'SELECT modify_limit_table.test_int FROM modify_limit_table ' .
+ 'INNER JOIN modify_limit_table2 ON modify_limit_table.test_int = modify_limit_table2.test_int ' .
+ 'GROUP BY modify_limit_table.test_int ' .
+ 'ORDER BY modify_limit_table.test_int ASC';
+ $this->assertLimitResult([1, 2], $sql, 10, 0);
+ $this->assertLimitResult([1], $sql, 1, 0);
+ $this->assertLimitResult([2], $sql, 1, 1);
}
public function testModifyLimitQuerySubSelect()
{
- $this->_conn->insert('modify_limit_table', array('test_int' => 1));
- $this->_conn->insert('modify_limit_table', array('test_int' => 2));
- $this->_conn->insert('modify_limit_table', array('test_int' => 3));
- $this->_conn->insert('modify_limit_table', array('test_int' => 4));
+ $this->connection->insert('modify_limit_table', ['test_int' => 1]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 2]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 3]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 4]);
- $sql = "SELECT modify_limit_table.*, (SELECT COUNT(*) FROM modify_limit_table) AS cnt FROM modify_limit_table ORDER BY test_int DESC";
+ $sql = 'SELECT modify_limit_table.*, (SELECT COUNT(*) FROM modify_limit_table) AS cnt FROM modify_limit_table ORDER BY test_int DESC';
- $this->assertLimitResult(array(4, 3, 2, 1), $sql, 10, 0);
- $this->assertLimitResult(array(4, 3), $sql, 2, 0);
- $this->assertLimitResult(array(2, 1), $sql, 2, 2);
+ $this->assertLimitResult([4, 3, 2, 1], $sql, 10, 0);
+ $this->assertLimitResult([4, 3], $sql, 2, 0);
+ $this->assertLimitResult([2, 1], $sql, 2, 2);
}
public function testModifyLimitQueryFromSubSelect()
{
- $this->_conn->insert('modify_limit_table', array('test_int' => 1));
- $this->_conn->insert('modify_limit_table', array('test_int' => 2));
- $this->_conn->insert('modify_limit_table', array('test_int' => 3));
- $this->_conn->insert('modify_limit_table', array('test_int' => 4));
+ $this->connection->insert('modify_limit_table', ['test_int' => 1]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 2]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 3]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 4]);
- $sql = "SELECT * FROM (SELECT * FROM modify_limit_table) sub ORDER BY test_int DESC";
+ $sql = 'SELECT * FROM (SELECT * FROM modify_limit_table) sub ORDER BY test_int DESC';
- $this->assertLimitResult(array(4, 3, 2, 1), $sql, 10, 0);
- $this->assertLimitResult(array(4, 3), $sql, 2, 0);
- $this->assertLimitResult(array(2, 1), $sql, 2, 2);
+ $this->assertLimitResult([4, 3, 2, 1], $sql, 10, 0);
+ $this->assertLimitResult([4, 3], $sql, 2, 0);
+ $this->assertLimitResult([2, 1], $sql, 2, 2);
}
public function testModifyLimitQueryLineBreaks()
{
- $this->_conn->insert('modify_limit_table', array('test_int' => 1));
- $this->_conn->insert('modify_limit_table', array('test_int' => 2));
- $this->_conn->insert('modify_limit_table', array('test_int' => 3));
+ $this->connection->insert('modify_limit_table', ['test_int' => 1]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 2]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 3]);
$sql = <<assertLimitResult(array(2), $sql, 1, 1);
+ $this->assertLimitResult([2], $sql, 1, 1);
}
public function testModifyLimitQueryZeroOffsetNoLimit()
{
- $this->_conn->insert('modify_limit_table', array('test_int' => 1));
- $this->_conn->insert('modify_limit_table', array('test_int' => 2));
+ $this->connection->insert('modify_limit_table', ['test_int' => 1]);
+ $this->connection->insert('modify_limit_table', ['test_int' => 2]);
- $sql = "SELECT test_int FROM modify_limit_table ORDER BY test_int ASC";
+ $sql = 'SELECT test_int FROM modify_limit_table ORDER BY test_int ASC';
- $this->assertLimitResult(array(1, 2), $sql, null, 0);
+ $this->assertLimitResult([1, 2], $sql, null, 0);
}
public function assertLimitResult($expectedResults, $sql, $limit, $offset, $deterministic = true)
{
- $p = $this->_conn->getDatabasePlatform();
- $data = array();
- foreach ($this->_conn->fetchAll($p->modifyLimitQuery($sql, $limit, $offset)) as $row) {
- $row = array_change_key_case($row, CASE_LOWER);
+ $p = $this->connection->getDatabasePlatform();
+ $data = [];
+ foreach ($this->connection->fetchAll($p->modifyLimitQuery($sql, $limit, $offset)) as $row) {
+ $row = array_change_key_case($row, CASE_LOWER);
$data[] = $row['test_int'];
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php b/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php
index fd001d496e5..fec2e5944d6 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php
@@ -6,13 +6,15 @@
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Schema\Table;
+use Doctrine\Tests\DbalFunctionalTestCase;
+use Throwable;
use const CASE_LOWER;
use function array_change_key_case;
/**
* @group DDC-1372
*/
-class NamedParametersTest extends \Doctrine\Tests\DbalFunctionalTestCase
+class NamedParametersTest extends DbalFunctionalTestCase
{
public function ticketProvider()
{
@@ -149,63 +151,66 @@ protected function setUp()
{
parent::setUp();
- if (! $this->_conn->getSchemaManager()->tablesExist('ddc1372_foobar')) {
- try {
- $table = new Table('ddc1372_foobar');
- $table->addColumn('id', 'integer');
- $table->addColumn('foo', 'string');
- $table->addColumn('bar', 'string');
- $table->setPrimaryKey(['id']);
-
- $sm = $this->_conn->getSchemaManager();
- $sm->createTable($table);
+ if ($this->connection->getSchemaManager()->tablesExist('ddc1372_foobar')) {
+ return;
+ }
- $this->_conn->insert('ddc1372_foobar', [
- 'id' => 1,
- 'foo' => 1,
- 'bar' => 1,
- ]);
- $this->_conn->insert('ddc1372_foobar', [
- 'id' => 2,
- 'foo' => 1,
- 'bar' => 2,
- ]);
- $this->_conn->insert('ddc1372_foobar', [
- 'id' => 3,
- 'foo' => 1,
- 'bar' => 3,
- ]);
- $this->_conn->insert('ddc1372_foobar', [
- 'id' => 4,
- 'foo' => 1,
- 'bar' => 4,
- ]);
- $this->_conn->insert('ddc1372_foobar', [
- 'id' => 5,
- 'foo' => 2,
- 'bar' => 1,
- ]);
- $this->_conn->insert('ddc1372_foobar', [
- 'id' => 6,
- 'foo' => 2,
- 'bar' => 2,
- ]);
- } catch(\Exception $e) {
- $this->fail($e->getMessage());
- }
+ try {
+ $table = new Table('ddc1372_foobar');
+ $table->addColumn('id', 'integer');
+ $table->addColumn('foo', 'string');
+ $table->addColumn('bar', 'string');
+ $table->setPrimaryKey(['id']);
+
+ $sm = $this->connection->getSchemaManager();
+ $sm->createTable($table);
+
+ $this->connection->insert('ddc1372_foobar', [
+ 'id' => 1,
+ 'foo' => 1,
+ 'bar' => 1,
+ ]);
+ $this->connection->insert('ddc1372_foobar', [
+ 'id' => 2,
+ 'foo' => 1,
+ 'bar' => 2,
+ ]);
+ $this->connection->insert('ddc1372_foobar', [
+ 'id' => 3,
+ 'foo' => 1,
+ 'bar' => 3,
+ ]);
+ $this->connection->insert('ddc1372_foobar', [
+ 'id' => 4,
+ 'foo' => 1,
+ 'bar' => 4,
+ ]);
+ $this->connection->insert('ddc1372_foobar', [
+ 'id' => 5,
+ 'foo' => 2,
+ 'bar' => 1,
+ ]);
+ $this->connection->insert('ddc1372_foobar', [
+ 'id' => 6,
+ 'foo' => 2,
+ 'bar' => 2,
+ ]);
+ } catch (Throwable $e) {
+ $this->fail($e->getMessage());
}
}
/**
+ * @param string $query
+ * @param mixed[] $params
+ * @param int[] $types
+ * @param int[] $expected
+ *
* @dataProvider ticketProvider
- * @param string $query
- * @param array $params
- * @param array $types
- * @param array $expected
*/
- public function testTicket($query,$params,$types,$expected)
+ public function testTicket($query, $params, $types, $expected)
{
- $stmt = $this->_conn->executeQuery($query, $params, $types);
+ $stmt = $this->connection->executeQuery($query, $params, $types);
$result = $stmt->fetchAll(FetchMode::ASSOCIATIVE);
foreach ($result as $k => $v) {
diff --git a/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php
index dd2c61b8fe3..ce859827d83 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php
@@ -18,14 +18,14 @@ protected function setUp()
parent::setUp();
- if (! $this->_conn->getWrappedConnection() instanceof PDOConnection) {
+ if (! $this->connection->getWrappedConnection() instanceof PDOConnection) {
$this->markTestSkipped('PDO-only test');
}
$table = new Table('stmt_test');
$table->addColumn('id', 'integer');
$table->addColumn('name', 'text');
- $this->_conn->getSchemaManager()->dropAndCreateTable($table);
+ $this->connection->getSchemaManager()->dropAndCreateTable($table);
}
/**
@@ -34,16 +34,16 @@ protected function setUp()
*/
public function testPDOSpecificModeIsAccepted()
{
- $this->_conn->insert('stmt_test', [
+ $this->connection->insert('stmt_test', [
'id' => 1,
'name' => 'Alice',
]);
- $this->_conn->insert('stmt_test', [
+ $this->connection->insert('stmt_test', [
'id' => 2,
'name' => 'Bob',
]);
- $data = $this->_conn->query('SELECT id, name FROM stmt_test ORDER BY id')
+ $data = $this->connection->query('SELECT id, name FROM stmt_test ORDER BY id')
->fetchAll(PDO::FETCH_KEY_PAIR);
self::assertSame([
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Platform/DateExpressionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Platform/DateExpressionTest.php
index 46a5efc1aae..5c1789e192d 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Platform/DateExpressionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Platform/DateExpressionTest.php
@@ -17,16 +17,16 @@ public function testDifference(string $date1, string $date2, int $expected) : vo
$table = new Table('date_expr_test');
$table->addColumn('date1', 'datetime');
$table->addColumn('date2', 'datetime');
- $this->_conn->getSchemaManager()->dropAndCreateTable($table);
- $this->_conn->insert('date_expr_test', [
+ $this->connection->getSchemaManager()->dropAndCreateTable($table);
+ $this->connection->insert('date_expr_test', [
'date1' => $date1,
'date2' => $date2,
]);
- $platform = $this->_conn->getDatabasePlatform();
+ $platform = $this->connection->getDatabasePlatform();
$sql = sprintf('SELECT %s FROM date_expr_test', $platform->getDateDiffExpression('date1', 'date2'));
- $diff = $this->_conn->query($sql)->fetchColumn();
+ $diff = $this->connection->query($sql)->fetchColumn();
self::assertEquals($expected, $diff);
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php b/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php
index f95f5bed47a..b120823eefb 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php
@@ -4,19 +4,22 @@
use Doctrine\DBAL\ColumnCase;
use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver\PDOSqlsrv\Driver;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\Portability\Connection as ConnectionPortability;
+use Doctrine\DBAL\Schema\AbstractSchemaManager;
+use Doctrine\DBAL\Schema\Table;
+use Doctrine\Tests\DbalFunctionalTestCase;
+use Throwable;
use function strlen;
/**
* @group DBAL-56
*/
-class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
+class PortabilityTest extends DbalFunctionalTestCase
{
- /**
- * @var Connection
- */
+ /** @var Connection */
private $portableConnection;
protected function tearDown()
@@ -31,36 +34,36 @@ protected function tearDown()
/**
* @param int $portabilityMode
* @param int $case
+ *
* @return Connection
*/
private function getPortableConnection(
$portabilityMode = ConnectionPortability::PORTABILITY_ALL,
$case = ColumnCase::LOWER
) {
- if (!$this->portableConnection) {
- $params = $this->_conn->getParams();
+ if (! $this->portableConnection) {
+ $params = $this->connection->getParams();
$params['wrapperClass'] = ConnectionPortability::class;
$params['portability'] = $portabilityMode;
$params['fetch_case'] = $case;
- $this->portableConnection = DriverManager::getConnection($params, $this->_conn->getConfiguration(), $this->_conn->getEventManager());
+ $this->portableConnection = DriverManager::getConnection($params, $this->connection->getConfiguration(), $this->connection->getEventManager());
try {
- /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
- $table = new \Doctrine\DBAL\Schema\Table("portability_table");
+ /** @var AbstractSchemaManager $sm */
+ $table = new Table('portability_table');
$table->addColumn('Test_Int', 'integer');
- $table->addColumn('Test_String', 'string', array('fixed' => true, 'length' => 32));
- $table->addColumn('Test_Null', 'string', array('notnull' => false));
- $table->setPrimaryKey(array('Test_Int'));
+ $table->addColumn('Test_String', 'string', ['fixed' => true, 'length' => 32]);
+ $table->addColumn('Test_Null', 'string', ['notnull' => false]);
+ $table->setPrimaryKey(['Test_Int']);
$sm = $this->portableConnection->getSchemaManager();
$sm->createTable($table);
- $this->portableConnection->insert('portability_table', array('Test_Int' => 1, 'Test_String' => 'foo', 'Test_Null' => ''));
- $this->portableConnection->insert('portability_table', array('Test_Int' => 2, 'Test_String' => 'foo ', 'Test_Null' => null));
- } catch(\Exception $e) {
-
+ $this->portableConnection->insert('portability_table', ['Test_Int' => 1, 'Test_String' => 'foo', 'Test_Null' => '']);
+ $this->portableConnection->insert('portability_table', ['Test_Int' => 2, 'Test_String' => 'foo ', 'Test_Null' => null]);
+ } catch (Throwable $e) {
}
}
@@ -103,18 +106,18 @@ public function testConnFetchMode()
$stmt = $conn->query('SELECT * FROM portability_table');
foreach ($stmt as $row) {
- $this->assertFetchResultRow($row);
+ $this->assertFetchResultRow($row);
}
$stmt = $conn->query('SELECT * FROM portability_table');
while (($row = $stmt->fetch())) {
- $this->assertFetchResultRow($row);
+ $this->assertFetchResultRow($row);
}
$stmt = $conn->prepare('SELECT * FROM portability_table');
$stmt->execute();
while (($row = $stmt->fetch())) {
- $this->assertFetchResultRow($row);
+ $this->assertFetchResultRow($row);
}
}
@@ -128,9 +131,9 @@ public function assertFetchResultRows($rows)
public function assertFetchResultRow($row)
{
- self::assertContains($row['test_int'], array(1, 2), "Primary key test_int should either be 1 or 2.");
- self::assertArrayHasKey('test_string', $row, "Case should be lowered.");
- self::assertEquals(3, strlen($row['test_string']), "test_string should be rtrimed to length of three for CHAR(32) column.");
+ self::assertContains($row['test_int'], [1, 2], 'Primary key test_int should either be 1 or 2.');
+ self::assertArrayHasKey('test_string', $row, 'Case should be lowered.');
+ self::assertEquals(3, strlen($row['test_string']), 'test_string should be rtrimed to length of three for CHAR(32) column.');
self::assertNull($row['test_null']);
self::assertArrayNotHasKey(0, $row, 'The row should not contain numerical keys.');
}
@@ -141,12 +144,10 @@ public function assertFetchResultRow($row)
public function testPortabilityPdoSqlServer()
{
$portability = ConnectionPortability::PORTABILITY_SQLSRV;
- $params = array(
- 'portability' => $portability
- );
+ $params = ['portability' => $portability];
- $driverMock = $this->getMockBuilder('Doctrine\\DBAL\\Driver\\PDOSqlsrv\\Driver')
- ->setMethods(array('connect'))
+ $driverMock = $this->getMockBuilder(Driver::class)
+ ->setMethods(['connect'])
->getMock();
$driverMock->expects($this->once())
@@ -161,6 +162,9 @@ public function testPortabilityPdoSqlServer()
}
/**
+ * @param string $field
+ * @param mixed[] $expected
+ *
* @dataProvider fetchAllColumnProvider
*/
public function testFetchAllColumn($field, array $expected)
@@ -174,16 +178,16 @@ public function testFetchAllColumn($field, array $expected)
public static function fetchAllColumnProvider()
{
- return array(
- 'int' => array(
+ return [
+ 'int' => [
'Test_Int',
- array(1, 2),
- ),
- 'string' => array(
+ [1, 2],
+ ],
+ 'string' => [
'Test_String',
- array('foo', 'foo'),
- ),
- );
+ ['foo', 'foo'],
+ ],
+ ];
}
public function testFetchAllNullColumn()
@@ -192,6 +196,6 @@ public function testFetchAllNullColumn()
$stmt = $conn->query('SELECT Test_Null FROM portability_table');
$column = $stmt->fetchAll(FetchMode::COLUMN);
- self::assertSame(array(null, null), $column);
+ self::assertSame([null, null], $column);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
index 63d82ad42c8..ae4259da91f 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
@@ -2,9 +2,12 @@
namespace Doctrine\Tests\DBAL\Functional;
+use Doctrine\Common\Cache\ArrayCache;
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\Logging\DebugStack;
+use Doctrine\DBAL\Schema\Table;
+use Doctrine\Tests\DbalFunctionalTestCase;
use const CASE_LOWER;
use function array_change_key_case;
use function array_merge;
@@ -15,44 +18,40 @@
/**
* @group DDC-217
*/
-class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
+class ResultCacheTest extends DbalFunctionalTestCase
{
- /**
- * @var int[][]|string[][]
- */
- private $expectedResult = array(array('test_int' => 100, 'test_string' => 'foo'), array('test_int' => 200, 'test_string' => 'bar'), array('test_int' => 300, 'test_string' => 'baz'));
-
- /**
- * @var DebugStack
- */
+ /** @var int[][]|string[][] */
+ private $expectedResult = [['test_int' => 100, 'test_string' => 'foo'], ['test_int' => 200, 'test_string' => 'bar'], ['test_int' => 300, 'test_string' => 'baz']];
+
+ /** @var DebugStack */
private $sqlLogger;
protected function setUp()
{
parent::setUp();
- $table = new \Doctrine\DBAL\Schema\Table("caching");
+ $table = new Table('caching');
$table->addColumn('test_int', 'integer');
- $table->addColumn('test_string', 'string', array('notnull' => false));
- $table->setPrimaryKey(array('test_int'));
+ $table->addColumn('test_string', 'string', ['notnull' => false]);
+ $table->setPrimaryKey(['test_int']);
- $sm = $this->_conn->getSchemaManager();
+ $sm = $this->connection->getSchemaManager();
$sm->createTable($table);
foreach ($this->expectedResult as $row) {
- $this->_conn->insert('caching', $row);
+ $this->connection->insert('caching', $row);
}
- $config = $this->_conn->getConfiguration();
- $config->setSQLLogger($this->sqlLogger = new DebugStack);
+ $config = $this->connection->getConfiguration();
+ $config->setSQLLogger($this->sqlLogger = new DebugStack());
- $cache = new \Doctrine\Common\Cache\ArrayCache;
+ $cache = new ArrayCache();
$config->setResultCacheImpl($cache);
}
protected function tearDown()
{
- $this->_conn->getSchemaManager()->dropTable('caching');
+ $this->connection->getSchemaManager()->dropTable('caching');
parent::tearDown();
}
@@ -67,7 +66,7 @@ public function testCacheFetchAssoc()
public function testFetchNum()
{
- $expectedResult = array();
+ $expectedResult = [];
foreach ($this->expectedResult as $v) {
$expectedResult[] = array_values($v);
}
@@ -77,7 +76,7 @@ public function testFetchNum()
public function testFetchBoth()
{
- $expectedResult = array();
+ $expectedResult = [];
foreach ($this->expectedResult as $v) {
$expectedResult[] = array_merge($v, array_values($v));
}
@@ -87,7 +86,7 @@ public function testFetchBoth()
public function testFetchColumn()
{
- $expectedResult = array();
+ $expectedResult = [];
foreach ($this->expectedResult as $v) {
$expectedResult[] = array_shift($v);
}
@@ -97,17 +96,17 @@ public function testFetchColumn()
public function testMixingFetch()
{
- $numExpectedResult = array();
+ $numExpectedResult = [];
foreach ($this->expectedResult as $v) {
$numExpectedResult[] = array_values($v);
}
- $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
+ $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
$data = $this->hydrateStmt($stmt, FetchMode::ASSOCIATIVE);
self::assertEquals($this->expectedResult, $data);
- $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
+ $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
$data = $this->hydrateStmt($stmt, FetchMode::NUMERIC);
@@ -123,10 +122,10 @@ public function testIteratorFetch()
public function assertStandardAndIteratorFetchAreEqual($fetchMode)
{
- $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
+ $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
$data = $this->hydrateStmt($stmt, $fetchMode);
- $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
+ $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
$data_iterator = $this->hydrateStmtIterator($stmt, $fetchMode);
self::assertEquals($data, $data_iterator);
@@ -134,17 +133,17 @@ public function assertStandardAndIteratorFetchAreEqual($fetchMode)
public function testDontCloseNoCache()
{
- $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
+ $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
- $data = array();
+ $data = [];
while ($row = $stmt->fetch(FetchMode::ASSOCIATIVE)) {
$data[] = $row;
}
- $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
+ $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
- $data = array();
+ $data = [];
while ($row = $stmt->fetch(FetchMode::NUMERIC)) {
$data[] = $row;
@@ -155,12 +154,12 @@ public function testDontCloseNoCache()
public function testDontFinishNoCache()
{
- $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
+ $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
$stmt->fetch(FetchMode::ASSOCIATIVE);
$stmt->closeCursor();
- $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
+ $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
$this->hydrateStmt($stmt, FetchMode::NUMERIC);
@@ -169,47 +168,47 @@ public function testDontFinishNoCache()
public function assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, $fetchMode)
{
- $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
+ $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
self::assertEquals(2, $stmt->columnCount());
$data = $this->hydrateStmt($stmt, $fetchMode);
self::assertEquals($expectedResult, $data);
- $stmt = $this->_conn->executeQuery("SELECT * FROM caching ORDER BY test_int ASC", array(), array(), new QueryCacheProfile(10, "testcachekey"));
+ $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
self::assertEquals(2, $stmt->columnCount());
$data = $this->hydrateStmt($stmt, $fetchMode);
self::assertEquals($expectedResult, $data);
- self::assertCount(1, $this->sqlLogger->queries, "just one dbal hit");
+ self::assertCount(1, $this->sqlLogger->queries, 'just one dbal hit');
}
public function testEmptyResultCache()
{
- $stmt = $this->_conn->executeQuery("SELECT * FROM caching WHERE test_int > 500", array(), array(), new QueryCacheProfile(10, "emptycachekey"));
+ $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'emptycachekey'));
$data = $this->hydrateStmt($stmt);
- $stmt = $this->_conn->executeQuery("SELECT * FROM caching WHERE test_int > 500", array(), array(), new QueryCacheProfile(10, "emptycachekey"));
+ $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'emptycachekey'));
$data = $this->hydrateStmt($stmt);
- self::assertCount(1, $this->sqlLogger->queries, "just one dbal hit");
+ self::assertCount(1, $this->sqlLogger->queries, 'just one dbal hit');
}
public function testChangeCacheImpl()
{
- $stmt = $this->_conn->executeQuery("SELECT * FROM caching WHERE test_int > 500", array(), array(), new QueryCacheProfile(10, "emptycachekey"));
+ $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'emptycachekey'));
$data = $this->hydrateStmt($stmt);
- $secondCache = new \Doctrine\Common\Cache\ArrayCache;
- $stmt = $this->_conn->executeQuery("SELECT * FROM caching WHERE test_int > 500", array(), array(), new QueryCacheProfile(10, "emptycachekey", $secondCache));
- $data = $this->hydrateStmt($stmt);
+ $secondCache = new ArrayCache();
+ $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'emptycachekey', $secondCache));
+ $data = $this->hydrateStmt($stmt);
- self::assertCount(2, $this->sqlLogger->queries, "two hits");
- self::assertCount(1, $secondCache->fetch("emptycachekey"));
+ self::assertCount(2, $this->sqlLogger->queries, 'two hits');
+ self::assertCount(1, $secondCache->fetch('emptycachekey'));
}
private function hydrateStmt($stmt, $fetchMode = FetchMode::ASSOCIATIVE)
{
- $data = array();
+ $data = [];
while ($row = $stmt->fetch($fetchMode)) {
$data[] = is_array($row) ? array_change_key_case($row, CASE_LOWER) : $row;
}
@@ -219,7 +218,7 @@ private function hydrateStmt($stmt, $fetchMode = FetchMode::ASSOCIATIVE)
private function hydrateStmtIterator($stmt, $fetchMode = FetchMode::ASSOCIATIVE)
{
- $data = array();
+ $data = [];
$stmt->setFetchMode($fetchMode);
foreach ($stmt as $row) {
$data[] = is_array($row) ? array_change_key_case($row, CASE_LOWER) : $row;
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php
index e81cc4a3978..102fd1bb495 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php
@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Schema\Table;
+use Doctrine\DBAL\Types\BooleanType;
class Db2SchemaManagerTest extends SchemaManagerFunctionalTestCase
{
@@ -13,14 +14,14 @@ public function testGetBooleanColumn()
{
$table = new Table('boolean_column_test');
$table->addColumn('bool', 'boolean');
- $table->addColumn('bool_commented', 'boolean', array('comment' => "That's a comment"));
+ $table->addColumn('bool_commented', 'boolean', ['comment' => "That's a comment"]);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $columns = $this->_sm->listTableColumns('boolean_column_test');
+ $columns = $this->schemaManager->listTableColumns('boolean_column_test');
- self::assertInstanceOf('Doctrine\DBAL\Types\BooleanType', $columns['bool']->getType());
- self::assertInstanceOf('Doctrine\DBAL\Types\BooleanType', $columns['bool_commented']->getType());
+ self::assertInstanceOf(BooleanType::class, $columns['bool']->getType());
+ self::assertInstanceOf(BooleanType::class, $columns['bool_commented']->getType());
self::assertNull($columns['bool']->getComment());
self::assertSame("That's a comment", $columns['bool_commented']->getComment());
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php
index 5b63b363a51..070e2173d63 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php
@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Schema\Table;
+use Doctrine\DBAL\Types\BinaryType;
class DrizzleSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
@@ -12,32 +13,32 @@ public function testListTableWithBinary()
$table = new Table($tableName);
$table->addColumn('id', 'integer');
- $table->addColumn('column_varbinary', 'binary', array());
- $table->addColumn('column_binary', 'binary', array('fixed' => true));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('column_varbinary', 'binary', []);
+ $table->addColumn('column_binary', 'binary', ['fixed' => true]);
+ $table->setPrimaryKey(['id']);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $table = $this->_sm->listTableDetails($tableName);
+ $table = $this->schemaManager->listTableDetails($tableName);
- self::assertInstanceOf('Doctrine\DBAL\Types\BinaryType', $table->getColumn('column_varbinary')->getType());
+ self::assertInstanceOf(BinaryType::class, $table->getColumn('column_varbinary')->getType());
self::assertFalse($table->getColumn('column_varbinary')->getFixed());
- self::assertInstanceOf('Doctrine\DBAL\Types\BinaryType', $table->getColumn('column_binary')->getType());
+ self::assertInstanceOf(BinaryType::class, $table->getColumn('column_binary')->getType());
self::assertFalse($table->getColumn('column_binary')->getFixed());
}
public function testColumnCollation()
{
- $table = new Table('test_collation');
+ $table = new Table('test_collation');
$table->addOption('collate', $collation = 'utf8_unicode_ci');
$table->addColumn('id', 'integer');
$table->addColumn('text', 'text');
$table->addColumn('foo', 'text')->setPlatformOption('collation', 'utf8_swedish_ci');
$table->addColumn('bar', 'text')->setPlatformOption('collation', 'utf8_general_ci');
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns('test_collation');
+ $columns = $this->schemaManager->listTableColumns('test_collation');
self::assertArrayNotHasKey('collation', $columns['id']->getPlatformOptions());
self::assertEquals('utf8_unicode_ci', $columns['text']->getPlatformOption('collation'));
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
index 9f246ad4119..7dd9409b30c 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional\Schema;
+use DateTime;
use Doctrine\DBAL\Platforms\MariaDb1027Platform;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\Comparator;
@@ -10,6 +11,7 @@
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\Types\MySqlPointType;
use function implode;
+use function sprintf;
class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
@@ -17,26 +19,28 @@ protected function setUp()
{
parent::setUp();
- if ( ! Type::hasType('point')) {
- Type::addType('point', MySqlPointType::class);
+ if (Type::hasType('point')) {
+ return;
}
+
+ Type::addType('point', MySqlPointType::class);
}
public function testSwitchPrimaryKeyColumns()
{
- $tableOld = new Table("switch_primary_key_columns");
+ $tableOld = new Table('switch_primary_key_columns');
$tableOld->addColumn('foo_id', 'integer');
$tableOld->addColumn('bar_id', 'integer');
- $this->_sm->createTable($tableOld);
- $tableFetched = $this->_sm->listTableDetails("switch_primary_key_columns");
- $tableNew = clone $tableFetched;
- $tableNew->setPrimaryKey(array('bar_id', 'foo_id'));
+ $this->schemaManager->createTable($tableOld);
+ $tableFetched = $this->schemaManager->listTableDetails('switch_primary_key_columns');
+ $tableNew = clone $tableFetched;
+ $tableNew->setPrimaryKey(['bar_id', 'foo_id']);
- $comparator = new Comparator;
- $this->_sm->alterTable($comparator->diffTable($tableFetched, $tableNew));
+ $comparator = new Comparator();
+ $this->schemaManager->alterTable($comparator->diffTable($tableFetched, $tableNew));
- $table = $this->_sm->listTableDetails('switch_primary_key_columns');
+ $table = $this->schemaManager->listTableDetails('switch_primary_key_columns');
$primaryKey = $table->getPrimaryKeyColumns();
self::assertCount(2, $primaryKey);
@@ -47,39 +51,39 @@ public function testSwitchPrimaryKeyColumns()
public function testDiffTableBug()
{
$schema = new Schema();
- $table = $schema->createTable('diffbug_routing_translations');
+ $table = $schema->createTable('diffbug_routing_translations');
$table->addColumn('id', 'integer');
$table->addColumn('route', 'string');
$table->addColumn('locale', 'string');
$table->addColumn('attribute', 'string');
$table->addColumn('localized_value', 'string');
$table->addColumn('original_value', 'string');
- $table->setPrimaryKey(array('id'));
- $table->addUniqueIndex(array('route', 'locale', 'attribute'));
- $table->addIndex(array('localized_value')); // this is much more selective than the unique index
+ $table->setPrimaryKey(['id']);
+ $table->addUniqueIndex(['route', 'locale', 'attribute']);
+ $table->addIndex(['localized_value']); // this is much more selective than the unique index
- $this->_sm->createTable($table);
- $tableFetched = $this->_sm->listTableDetails("diffbug_routing_translations");
+ $this->schemaManager->createTable($table);
+ $tableFetched = $this->schemaManager->listTableDetails('diffbug_routing_translations');
- $comparator = new Comparator;
- $diff = $comparator->diffTable($tableFetched, $table);
+ $comparator = new Comparator();
+ $diff = $comparator->diffTable($tableFetched, $table);
- self::assertFalse($diff, "no changes expected.");
+ self::assertFalse($diff, 'no changes expected.');
}
public function testFulltextIndex()
{
$table = new Table('fulltext_index');
$table->addColumn('text', 'text');
- $table->addIndex(array('text'), 'f_index');
+ $table->addIndex(['text'], 'f_index');
$table->addOption('engine', 'MyISAM');
$index = $table->getIndex('f_index');
$index->addFlag('fulltext');
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $indexes = $this->_sm->listTableIndexes('fulltext_index');
+ $indexes = $this->schemaManager->listTableIndexes('fulltext_index');
self::assertArrayHasKey('f_index', $indexes);
self::assertTrue($indexes['f_index']->hasFlag('fulltext'));
}
@@ -88,15 +92,15 @@ public function testSpatialIndex()
{
$table = new Table('spatial_index');
$table->addColumn('point', 'point');
- $table->addIndex(array('point'), 's_index');
+ $table->addIndex(['point'], 's_index');
$table->addOption('engine', 'MyISAM');
$index = $table->getIndex('s_index');
$index->addFlag('spatial');
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $indexes = $this->_sm->listTableIndexes('spatial_index');
+ $indexes = $this->schemaManager->listTableIndexes('spatial_index');
self::assertArrayHasKey('s_index', $indexes);
self::assertTrue($indexes['s_index']->hasFlag('spatial'));
}
@@ -109,19 +113,19 @@ public function testAlterTableAddPrimaryKey()
$table = new Table('alter_table_add_pk');
$table->addColumn('id', 'integer');
$table->addColumn('foo', 'integer');
- $table->addIndex(array('id'), 'idx_id');
+ $table->addIndex(['id'], 'idx_id');
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
$comparator = new Comparator();
$diffTable = clone $table;
$diffTable->dropIndex('idx_id');
- $diffTable->setPrimaryKey(array('id'));
+ $diffTable->setPrimaryKey(['id']);
- $this->_sm->alterTable($comparator->diffTable($table, $diffTable));
+ $this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
- $table = $this->_sm->listTableDetails("alter_table_add_pk");
+ $table = $this->schemaManager->listTableDetails('alter_table_add_pk');
self::assertFalse($table->hasIndex('idx_id'));
self::assertTrue($table->hasPrimaryKey());
@@ -132,12 +136,12 @@ public function testAlterTableAddPrimaryKey()
*/
public function testDropPrimaryKeyWithAutoincrementColumn()
{
- $table = new Table("drop_primary_key");
- $table->addColumn('id', 'integer', array('autoincrement' => true));
+ $table = new Table('drop_primary_key');
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('foo', 'integer');
- $table->setPrimaryKey(array('id', 'foo'));
+ $table->setPrimaryKey(['id', 'foo']);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
$diffTable = clone $table;
@@ -145,9 +149,9 @@ public function testDropPrimaryKeyWithAutoincrementColumn()
$comparator = new Comparator();
- $this->_sm->alterTable($comparator->diffTable($table, $diffTable));
+ $this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
- $table = $this->_sm->listTableDetails("drop_primary_key");
+ $table = $this->schemaManager->listTableDetails('drop_primary_key');
self::assertFalse($table->hasPrimaryKey());
self::assertFalse($table->getColumn('id')->getAutoincrement());
@@ -158,21 +162,21 @@ public function testDropPrimaryKeyWithAutoincrementColumn()
*/
public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes()
{
- if ($this->_sm->getDatabasePlatform() instanceof MariaDb1027Platform) {
+ if ($this->schemaManager->getDatabasePlatform() instanceof MariaDb1027Platform) {
$this->markTestSkipped(
'MariaDb102Platform supports default values for BLOB and TEXT columns and will propagate values'
);
}
- $table = new Table("text_blob_default_value");
+ $table = new Table('text_blob_default_value');
$table->addColumn('def_text', 'text', ['default' => 'def']);
$table->addColumn('def_text_null', 'text', ['notnull' => false, 'default' => 'def']);
$table->addColumn('def_blob', 'blob', ['default' => 'def']);
$table->addColumn('def_blob_null', 'blob', ['notnull' => false, 'default' => 'def']);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $onlineTable = $this->_sm->listTableDetails("text_blob_default_value");
+ $onlineTable = $this->schemaManager->listTableDetails('text_blob_default_value');
self::assertNull($onlineTable->getColumn('def_text')->getDefault());
self::assertNull($onlineTable->getColumn('def_text_null')->getDefault());
@@ -183,9 +187,9 @@ public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes()
$comparator = new Comparator();
- $this->_sm->alterTable($comparator->diffTable($table, $onlineTable));
+ $this->schemaManager->alterTable($comparator->diffTable($table, $onlineTable));
- $onlineTable = $this->_sm->listTableDetails("text_blob_default_value");
+ $onlineTable = $this->schemaManager->listTableDetails('text_blob_default_value');
self::assertNull($onlineTable->getColumn('def_text')->getDefault());
self::assertNull($onlineTable->getColumn('def_text_null')->getDefault());
@@ -197,16 +201,16 @@ public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes()
public function testColumnCollation()
{
- $table = new Table('test_collation');
+ $table = new Table('test_collation');
$table->addOption('collate', $collation = 'latin1_swedish_ci');
$table->addOption('charset', 'latin1');
$table->addColumn('id', 'integer');
$table->addColumn('text', 'text');
$table->addColumn('foo', 'text')->setPlatformOption('collation', 'latin1_swedish_ci');
$table->addColumn('bar', 'text')->setPlatformOption('collation', 'utf8_general_ci');
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns('test_collation');
+ $columns = $this->schemaManager->listTableColumns('test_collation');
self::assertArrayNotHasKey('collation', $columns['id']->getPlatformOptions());
self::assertEquals('latin1_swedish_ci', $columns['text']->getPlatformOption('collation'));
@@ -220,23 +224,23 @@ public function testColumnCollation()
public function testListLobTypeColumns()
{
$tableName = 'lob_type_columns';
- $table = new Table($tableName);
+ $table = new Table($tableName);
- $table->addColumn('col_tinytext', 'text', array('length' => MySqlPlatform::LENGTH_LIMIT_TINYTEXT));
- $table->addColumn('col_text', 'text', array('length' => MySqlPlatform::LENGTH_LIMIT_TEXT));
- $table->addColumn('col_mediumtext', 'text', array('length' => MySqlPlatform::LENGTH_LIMIT_MEDIUMTEXT));
+ $table->addColumn('col_tinytext', 'text', ['length' => MySqlPlatform::LENGTH_LIMIT_TINYTEXT]);
+ $table->addColumn('col_text', 'text', ['length' => MySqlPlatform::LENGTH_LIMIT_TEXT]);
+ $table->addColumn('col_mediumtext', 'text', ['length' => MySqlPlatform::LENGTH_LIMIT_MEDIUMTEXT]);
$table->addColumn('col_longtext', 'text');
- $table->addColumn('col_tinyblob', 'text', array('length' => MySqlPlatform::LENGTH_LIMIT_TINYBLOB));
- $table->addColumn('col_blob', 'blob', array('length' => MySqlPlatform::LENGTH_LIMIT_BLOB));
- $table->addColumn('col_mediumblob', 'blob', array('length' => MySqlPlatform::LENGTH_LIMIT_MEDIUMBLOB));
+ $table->addColumn('col_tinyblob', 'text', ['length' => MySqlPlatform::LENGTH_LIMIT_TINYBLOB]);
+ $table->addColumn('col_blob', 'blob', ['length' => MySqlPlatform::LENGTH_LIMIT_BLOB]);
+ $table->addColumn('col_mediumblob', 'blob', ['length' => MySqlPlatform::LENGTH_LIMIT_MEDIUMBLOB]);
$table->addColumn('col_longblob', 'blob');
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $platform = $this->_sm->getDatabasePlatform();
+ $platform = $this->schemaManager->getDatabasePlatform();
$offlineColumns = $table->getColumns();
- $onlineColumns = $this->_sm->listTableColumns($tableName);
+ $onlineColumns = $this->schemaManager->listTableColumns($tableName);
self::assertSame(
$platform->getClobTypeDeclarationSQL($offlineColumns['col_tinytext']->toArray()),
@@ -281,15 +285,15 @@ public function testDiffListGuidTableColumn()
$offlineTable = new Table('list_guid_table_column');
$offlineTable->addColumn('col_guid', 'guid');
- $this->_sm->dropAndCreateTable($offlineTable);
+ $this->schemaManager->dropAndCreateTable($offlineTable);
- $onlineTable = $this->_sm->listTableDetails('list_guid_table_column');
+ $onlineTable = $this->schemaManager->listTableDetails('list_guid_table_column');
$comparator = new Comparator();
self::assertFalse(
$comparator->diffTable($offlineTable, $onlineTable),
- "No differences should be detected with the offline vs online schema."
+ 'No differences should be detected with the offline vs online schema.'
);
}
@@ -299,14 +303,14 @@ public function testDiffListGuidTableColumn()
public function testListDecimalTypeColumns()
{
$tableName = 'test_list_decimal_columns';
- $table = new Table($tableName);
+ $table = new Table($tableName);
$table->addColumn('col', 'decimal');
- $table->addColumn('col_unsigned', 'decimal', array('unsigned' => true));
+ $table->addColumn('col_unsigned', 'decimal', ['unsigned' => true]);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns($tableName);
+ $columns = $this->schemaManager->listTableColumns($tableName);
self::assertArrayHasKey('col', $columns);
self::assertArrayHasKey('col_unsigned', $columns);
@@ -320,14 +324,14 @@ public function testListDecimalTypeColumns()
public function testListFloatTypeColumns()
{
$tableName = 'test_list_float_columns';
- $table = new Table($tableName);
+ $table = new Table($tableName);
$table->addColumn('col', 'float');
- $table->addColumn('col_unsigned', 'float', array('unsigned' => true));
+ $table->addColumn('col_unsigned', 'float', ['unsigned' => true]);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns($tableName);
+ $columns = $this->schemaManager->listTableColumns($tableName);
self::assertArrayHasKey('col', $columns);
self::assertArrayHasKey('col_unsigned', $columns);
@@ -339,41 +343,41 @@ public function testJsonColumnType() : void
{
$table = new Table('test_mysql_json');
$table->addColumn('col_json', 'json');
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns('test_mysql_json');
+ $columns = $this->schemaManager->listTableColumns('test_mysql_json');
- self::assertSame(TYPE::JSON, $columns['col_json']->getType()->getName());
+ self::assertSame(Type::JSON, $columns['col_json']->getType()->getName());
}
public function testColumnDefaultCurrentTimestamp() : void
{
- $platform = $this->_sm->getDatabasePlatform();
+ $platform = $this->schemaManager->getDatabasePlatform();
- $table = new Table("test_column_defaults_current_timestamp");
+ $table = new Table('test_column_defaults_current_timestamp');
$currentTimeStampSql = $platform->getCurrentTimestampSQL();
$table->addColumn('col_datetime', 'datetime', ['notnull' => true, 'default' => $currentTimeStampSql]);
$table->addColumn('col_datetime_nullable', 'datetime', ['default' => $currentTimeStampSql]);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $onlineTable = $this->_sm->listTableDetails("test_column_defaults_current_timestamp");
+ $onlineTable = $this->schemaManager->listTableDetails('test_column_defaults_current_timestamp');
self::assertSame($currentTimeStampSql, $onlineTable->getColumn('col_datetime')->getDefault());
self::assertSame($currentTimeStampSql, $onlineTable->getColumn('col_datetime_nullable')->getDefault());
$comparator = new Comparator();
$diff = $comparator->diffTable($table, $onlineTable);
- self::assertFalse($diff, "Tables should be identical with column defaults.");
+ self::assertFalse($diff, 'Tables should be identical with column defaults.');
}
public function testColumnDefaultsAreValid()
{
- $table = new Table("test_column_defaults_are_valid");
+ $table = new Table('test_column_defaults_are_valid');
- $currentTimeStampSql = $this->_sm->getDatabasePlatform()->getCurrentTimestampSQL();
+ $currentTimeStampSql = $this->schemaManager->getDatabasePlatform()->getCurrentTimestampSQL();
$table->addColumn('col_datetime', 'datetime', ['default' => $currentTimeStampSql]);
$table->addColumn('col_datetime_null', 'datetime', ['notnull' => false, 'default' => null]);
$table->addColumn('col_int', 'integer', ['default' => 1]);
@@ -382,17 +386,17 @@ public function testColumnDefaultsAreValid()
$table->addColumn('col_decimal', 'decimal', ['scale' => 3, 'precision' => 6, 'default' => -2.3]);
$table->addColumn('col_date', 'date', ['default' => '2012-12-12']);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $this->_conn->executeUpdate(
- "INSERT INTO test_column_defaults_are_valid () VALUES()"
+ $this->connection->executeUpdate(
+ 'INSERT INTO test_column_defaults_are_valid () VALUES()'
);
- $row = $this->_conn->fetchAssoc(
+ $row = $this->connection->fetchAssoc(
'SELECT *, DATEDIFF(CURRENT_TIMESTAMP(), col_datetime) as diff_seconds FROM test_column_defaults_are_valid'
);
- self::assertInstanceOf(\DateTime::class, \DateTime::createFromFormat('Y-m-d H:i:s', $row['col_datetime']));
+ self::assertInstanceOf(DateTime::class, DateTime::createFromFormat('Y-m-d H:i:s', $row['col_datetime']));
self::assertNull($row['col_datetime_null']);
self::assertSame('2012-12-12', $row['col_date']);
self::assertSame('A', $row['col_string']);
@@ -414,13 +418,13 @@ public function testColumnDefaultsAreValid()
*/
public function testColumnDefaultValuesCurrentTimeAndDate() : void
{
- if ( ! $this->_sm->getDatabasePlatform() instanceof MariaDb1027Platform) {
+ if (! $this->schemaManager->getDatabasePlatform() instanceof MariaDb1027Platform) {
$this->markTestSkipped('Only relevant for MariaDb102Platform.');
}
- $platform = $this->_sm->getDatabasePlatform();
+ $platform = $this->schemaManager->getDatabasePlatform();
- $table = new Table("test_column_defaults_current_time_and_date");
+ $table = new Table('test_column_defaults_current_time_and_date');
$currentTimestampSql = $platform->getCurrentTimestampSQL();
$currentTimeSql = $platform->getCurrentTimeSQL();
@@ -430,9 +434,9 @@ public function testColumnDefaultValuesCurrentTimeAndDate() : void
$table->addColumn('col_date', 'date', ['default' => $currentDateSql]);
$table->addColumn('col_time', 'time', ['default' => $currentTimeSql]);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $onlineTable = $this->_sm->listTableDetails("test_column_defaults_current_time_and_date");
+ $onlineTable = $this->schemaManager->listTableDetails('test_column_defaults_current_time_and_date');
self::assertSame($currentTimestampSql, $onlineTable->getColumn('col_datetime')->getDefault());
self::assertSame($currentDateSql, $onlineTable->getColumn('col_date')->getDefault());
@@ -441,24 +445,27 @@ public function testColumnDefaultValuesCurrentTimeAndDate() : void
$comparator = new Comparator();
$diff = $comparator->diffTable($table, $onlineTable);
- self::assertFalse($diff, "Tables should be identical with column defauts time and date.");
+ self::assertFalse($diff, 'Tables should be identical with column defauts time and date.');
}
/**
* Ensure default values (un-)escaping is properly done by mysql platforms.
* The test is voluntarily relying on schema introspection due to current
* doctrine limitations. Once #2850 is landed, this test can be removed.
+ *
* @see https://dev.mysql.com/doc/refman/5.7/en/string-literals.html
*/
public function testEnsureDefaultsAreUnescapedFromSchemaIntrospection() : void
{
- $platform = $this->_sm->getDatabasePlatform();
- $this->_conn->query('DROP TABLE IF EXISTS test_column_defaults_with_create');
+ $platform = $this->schemaManager->getDatabasePlatform();
+ $this->connection->query('DROP TABLE IF EXISTS test_column_defaults_with_create');
$escapeSequences = [
"\\0", // An ASCII NUL (X'00') character
- "\\'", "''", // Single quote
- '\\"', '""', // Double quote
+ "\\'",
+ "''", // Single quote
+ '\\"',
+ '""', // Double quote
'\\b', // A backspace character
'\\n', // A new-line character
'\\r', // A carriage return character
@@ -471,11 +478,12 @@ public function testEnsureDefaultsAreUnescapedFromSchemaIntrospection() : void
$default = implode('+', $escapeSequences);
- $sql = "CREATE TABLE test_column_defaults_with_create(
- col1 VARCHAR(255) NULL DEFAULT {$platform->quoteStringLiteral($default)}
- )";
- $this->_conn->query($sql);
- $onlineTable = $this->_sm->listTableDetails("test_column_defaults_with_create");
+ $sql = sprintf(
+ 'CREATE TABLE test_column_defaults_with_create(col1 VARCHAR(255) NULL DEFAULT %s)',
+ $platform->quoteStringLiteral($default)
+ );
+ $this->connection->query($sql);
+ $onlineTable = $this->schemaManager->listTableDetails('test_column_defaults_with_create');
self::assertSame($default, $onlineTable->getColumn('col1')->getDefault());
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php
index d1f0245b015..33d1131eadc 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php
@@ -4,6 +4,7 @@
use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Table;
+use Doctrine\DBAL\Types\BinaryType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\TestUtil;
use function array_map;
@@ -14,27 +15,27 @@ protected function setUp()
{
parent::setUp();
- if(!isset($GLOBALS['db_username'])) {
+ if (! isset($GLOBALS['db_username'])) {
$this->markTestSkipped('Foo');
}
$username = $GLOBALS['db_username'];
- $query = "GRANT ALL PRIVILEGES TO ".$username;
+ $query = 'GRANT ALL PRIVILEGES TO ' . $username;
- $conn = \Doctrine\Tests\TestUtil::getTempConnection();
+ $conn = TestUtil::getTempConnection();
$conn->executeUpdate($query);
}
public function testRenameTable()
{
- $this->_sm->tryMethod('DropTable', 'list_tables_test');
- $this->_sm->tryMethod('DropTable', 'list_tables_test_new_name');
+ $this->schemaManager->tryMethod('DropTable', 'list_tables_test');
+ $this->schemaManager->tryMethod('DropTable', 'list_tables_test_new_name');
$this->createTestTable('list_tables_test');
- $this->_sm->renameTable('list_tables_test', 'list_tables_test_new_name');
+ $this->schemaManager->renameTable('list_tables_test', 'list_tables_test_new_name');
- $tables = $this->_sm->listTables();
+ $tables = $this->schemaManager->listTables();
self::assertHasTable($tables, 'list_tables_test_new_name');
}
@@ -43,20 +44,20 @@ public function testListTableWithBinary()
{
$tableName = 'test_binary_table';
- $table = new \Doctrine\DBAL\Schema\Table($tableName);
+ $table = new Table($tableName);
$table->addColumn('id', 'integer');
- $table->addColumn('column_varbinary', 'binary', array());
- $table->addColumn('column_binary', 'binary', array('fixed' => true));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('column_varbinary', 'binary', []);
+ $table->addColumn('column_binary', 'binary', ['fixed' => true]);
+ $table->setPrimaryKey(['id']);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $table = $this->_sm->listTableDetails($tableName);
+ $table = $this->schemaManager->listTableDetails($tableName);
- self::assertInstanceOf('Doctrine\DBAL\Types\BinaryType', $table->getColumn('column_varbinary')->getType());
+ self::assertInstanceOf(BinaryType::class, $table->getColumn('column_varbinary')->getType());
self::assertFalse($table->getColumn('column_varbinary')->getFixed());
- self::assertInstanceOf('Doctrine\DBAL\Types\BinaryType', $table->getColumn('column_binary')->getType());
+ self::assertInstanceOf(BinaryType::class, $table->getColumn('column_binary')->getType());
self::assertFalse($table->getColumn('column_binary')->getFixed());
}
@@ -73,23 +74,23 @@ public function testAlterTableColumnNotNull()
$table->addColumn('id', 'integer');
$table->addColumn('foo', 'integer');
$table->addColumn('bar', 'string');
- $table->setPrimaryKey(array('id'));
+ $table->setPrimaryKey(['id']);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns($tableName);
+ $columns = $this->schemaManager->listTableColumns($tableName);
self::assertTrue($columns['id']->getNotnull());
self::assertTrue($columns['foo']->getNotnull());
self::assertTrue($columns['bar']->getNotnull());
$diffTable = clone $table;
- $diffTable->changeColumn('foo', array('notnull' => false));
- $diffTable->changeColumn('bar', array('length' => 1024));
+ $diffTable->changeColumn('foo', ['notnull' => false]);
+ $diffTable->changeColumn('bar', ['length' => 1024]);
- $this->_sm->alterTable($comparator->diffTable($table, $diffTable));
+ $this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
- $columns = $this->_sm->listTableColumns($tableName);
+ $columns = $this->schemaManager->listTableColumns($tableName);
self::assertTrue($columns['id']->getNotnull());
self::assertFalse($columns['foo']->getNotnull());
@@ -103,7 +104,7 @@ public function testListDatabases()
$sm->dropAndCreateDatabase('c##test_create_database');
- $databases = $this->_sm->listDatabases();
+ $databases = $this->schemaManager->listDatabases();
$databases = array_map('strtolower', $databases);
self::assertContains('c##test_create_database', $databases);
@@ -114,47 +115,47 @@ public function testListDatabases()
*/
public function testListTableDetailsWithDifferentIdentifierQuotingRequirements()
{
- $primaryTableName = '"Primary_Table"';
+ $primaryTableName = '"Primary_Table"';
$offlinePrimaryTable = new Schema\Table($primaryTableName);
$offlinePrimaryTable->addColumn(
'"Id"',
'integer',
- array('autoincrement' => true, 'comment' => 'Explicit casing.')
+ ['autoincrement' => true, 'comment' => 'Explicit casing.']
);
- $offlinePrimaryTable->addColumn('select', 'integer', array('comment' => 'Reserved keyword.'));
- $offlinePrimaryTable->addColumn('foo', 'integer', array('comment' => 'Implicit uppercasing.'));
+ $offlinePrimaryTable->addColumn('select', 'integer', ['comment' => 'Reserved keyword.']);
+ $offlinePrimaryTable->addColumn('foo', 'integer', ['comment' => 'Implicit uppercasing.']);
$offlinePrimaryTable->addColumn('BAR', 'integer');
$offlinePrimaryTable->addColumn('"BAZ"', 'integer');
- $offlinePrimaryTable->addIndex(array('select'), 'from');
- $offlinePrimaryTable->addIndex(array('foo'), 'foo_index');
- $offlinePrimaryTable->addIndex(array('BAR'), 'BAR_INDEX');
- $offlinePrimaryTable->addIndex(array('"BAZ"'), 'BAZ_INDEX');
- $offlinePrimaryTable->setPrimaryKey(array('"Id"'));
+ $offlinePrimaryTable->addIndex(['select'], 'from');
+ $offlinePrimaryTable->addIndex(['foo'], 'foo_index');
+ $offlinePrimaryTable->addIndex(['BAR'], 'BAR_INDEX');
+ $offlinePrimaryTable->addIndex(['"BAZ"'], 'BAZ_INDEX');
+ $offlinePrimaryTable->setPrimaryKey(['"Id"']);
- $foreignTableName = 'foreign';
+ $foreignTableName = 'foreign';
$offlineForeignTable = new Schema\Table($foreignTableName);
- $offlineForeignTable->addColumn('id', 'integer', array('autoincrement' => true));
+ $offlineForeignTable->addColumn('id', 'integer', ['autoincrement' => true]);
$offlineForeignTable->addColumn('"Fk"', 'integer');
- $offlineForeignTable->addIndex(array('"Fk"'), '"Fk_index"');
+ $offlineForeignTable->addIndex(['"Fk"'], '"Fk_index"');
$offlineForeignTable->addForeignKeyConstraint(
$primaryTableName,
- array('"Fk"'),
- array('"Id"'),
- array(),
+ ['"Fk"'],
+ ['"Id"'],
+ [],
'"Primary_Table_Fk"'
);
- $offlineForeignTable->setPrimaryKey(array('id'));
+ $offlineForeignTable->setPrimaryKey(['id']);
- $this->_sm->tryMethod('dropTable', $foreignTableName);
- $this->_sm->tryMethod('dropTable', $primaryTableName);
+ $this->schemaManager->tryMethod('dropTable', $foreignTableName);
+ $this->schemaManager->tryMethod('dropTable', $primaryTableName);
- $this->_sm->createTable($offlinePrimaryTable);
- $this->_sm->createTable($offlineForeignTable);
+ $this->schemaManager->createTable($offlinePrimaryTable);
+ $this->schemaManager->createTable($offlineForeignTable);
- $onlinePrimaryTable = $this->_sm->listTableDetails($primaryTableName);
- $onlineForeignTable = $this->_sm->listTableDetails($foreignTableName);
+ $onlinePrimaryTable = $this->schemaManager->listTableDetails($primaryTableName);
+ $onlineForeignTable = $this->schemaManager->listTableDetails($foreignTableName);
- $platform = $this->_sm->getDatabasePlatform();
+ $platform = $this->schemaManager->getDatabasePlatform();
// Primary table assertions
self::assertSame($primaryTableName, $onlinePrimaryTable->getQuotedName($platform));
@@ -162,7 +163,7 @@ public function testListTableDetailsWithDifferentIdentifierQuotingRequirements()
self::assertTrue($onlinePrimaryTable->hasColumn('"Id"'));
self::assertSame('"Id"', $onlinePrimaryTable->getColumn('"Id"')->getQuotedName($platform));
self::assertTrue($onlinePrimaryTable->hasPrimaryKey());
- self::assertSame(array('"Id"'), $onlinePrimaryTable->getPrimaryKey()->getQuotedColumns($platform));
+ self::assertSame(['"Id"'], $onlinePrimaryTable->getPrimaryKey()->getQuotedColumns($platform));
self::assertTrue($onlinePrimaryTable->hasColumn('select'));
self::assertSame('"select"', $onlinePrimaryTable->getColumn('select')->getQuotedName($platform));
@@ -178,32 +179,32 @@ public function testListTableDetailsWithDifferentIdentifierQuotingRequirements()
self::assertTrue($onlinePrimaryTable->hasIndex('from'));
self::assertTrue($onlinePrimaryTable->getIndex('from')->hasColumnAtPosition('"select"'));
- self::assertSame(array('"select"'), $onlinePrimaryTable->getIndex('from')->getQuotedColumns($platform));
+ self::assertSame(['"select"'], $onlinePrimaryTable->getIndex('from')->getQuotedColumns($platform));
self::assertTrue($onlinePrimaryTable->hasIndex('foo_index'));
self::assertTrue($onlinePrimaryTable->getIndex('foo_index')->hasColumnAtPosition('foo'));
- self::assertSame(array('FOO'), $onlinePrimaryTable->getIndex('foo_index')->getQuotedColumns($platform));
+ self::assertSame(['FOO'], $onlinePrimaryTable->getIndex('foo_index')->getQuotedColumns($platform));
self::assertTrue($onlinePrimaryTable->hasIndex('BAR_INDEX'));
self::assertTrue($onlinePrimaryTable->getIndex('BAR_INDEX')->hasColumnAtPosition('BAR'));
- self::assertSame(array('BAR'), $onlinePrimaryTable->getIndex('BAR_INDEX')->getQuotedColumns($platform));
+ self::assertSame(['BAR'], $onlinePrimaryTable->getIndex('BAR_INDEX')->getQuotedColumns($platform));
self::assertTrue($onlinePrimaryTable->hasIndex('BAZ_INDEX'));
self::assertTrue($onlinePrimaryTable->getIndex('BAZ_INDEX')->hasColumnAtPosition('"BAZ"'));
- self::assertSame(array('BAZ'), $onlinePrimaryTable->getIndex('BAZ_INDEX')->getQuotedColumns($platform));
+ self::assertSame(['BAZ'], $onlinePrimaryTable->getIndex('BAZ_INDEX')->getQuotedColumns($platform));
// Foreign table assertions
self::assertTrue($onlineForeignTable->hasColumn('id'));
self::assertSame('ID', $onlineForeignTable->getColumn('id')->getQuotedName($platform));
self::assertTrue($onlineForeignTable->hasPrimaryKey());
- self::assertSame(array('ID'), $onlineForeignTable->getPrimaryKey()->getQuotedColumns($platform));
+ self::assertSame(['ID'], $onlineForeignTable->getPrimaryKey()->getQuotedColumns($platform));
self::assertTrue($onlineForeignTable->hasColumn('"Fk"'));
self::assertSame('"Fk"', $onlineForeignTable->getColumn('"Fk"')->getQuotedName($platform));
self::assertTrue($onlineForeignTable->hasIndex('"Fk_index"'));
self::assertTrue($onlineForeignTable->getIndex('"Fk_index"')->hasColumnAtPosition('"Fk"'));
- self::assertSame(array('"Fk"'), $onlineForeignTable->getIndex('"Fk_index"')->getQuotedColumns($platform));
+ self::assertSame(['"Fk"'], $onlineForeignTable->getIndex('"Fk_index"')->getQuotedColumns($platform));
self::assertTrue($onlineForeignTable->hasForeignKey('"Primary_Table_Fk"'));
self::assertSame(
@@ -211,11 +212,11 @@ public function testListTableDetailsWithDifferentIdentifierQuotingRequirements()
$onlineForeignTable->getForeignKey('"Primary_Table_Fk"')->getQuotedForeignTableName($platform)
);
self::assertSame(
- array('"Fk"'),
+ ['"Fk"'],
$onlineForeignTable->getForeignKey('"Primary_Table_Fk"')->getQuotedLocalColumns($platform)
);
self::assertSame(
- array('"Id"'),
+ ['"Id"'],
$onlineForeignTable->getForeignKey('"Primary_Table_Fk"')->getQuotedForeignColumns($platform)
);
}
@@ -223,13 +224,13 @@ public function testListTableDetailsWithDifferentIdentifierQuotingRequirements()
public function testListTableColumnsSameTableNamesInDifferentSchemas()
{
$table = $this->createListTableColumns();
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
$otherTable = new Table($table->getName());
$otherTable->addColumn('id', Type::STRING);
TestUtil::getTempConnection()->getSchemaManager()->dropAndCreateTable($otherTable);
- $columns = $this->_sm->listTableColumns($table->getName(), $this->_conn->getUsername());
+ $columns = $this->schemaManager->listTableColumns($table->getName(), $this->connection->getUsername());
self::assertCount(7, $columns);
}
@@ -239,19 +240,19 @@ public function testListTableColumnsSameTableNamesInDifferentSchemas()
public function testListTableIndexesPrimaryKeyConstraintNameDiffersFromIndexName()
{
$table = new Table('list_table_indexes_pk_id_test');
- $table->setSchemaConfig($this->_sm->createSchemaConfig());
- $table->addColumn('id', 'integer', array('notnull' => true));
- $table->addUniqueIndex(array('id'), 'id_unique_index');
- $this->_sm->dropAndCreateTable($table);
+ $table->setSchemaConfig($this->schemaManager->createSchemaConfig());
+ $table->addColumn('id', 'integer', ['notnull' => true]);
+ $table->addUniqueIndex(['id'], 'id_unique_index');
+ $this->schemaManager->dropAndCreateTable($table);
// Adding a primary key on already indexed columns
// Oracle will reuse the unique index, which cause a constraint name differing from the index name
- $this->_sm->createConstraint(new Schema\Index('id_pk_id_index', array('id'), true, true), 'list_table_indexes_pk_id_test');
+ $this->schemaManager->createConstraint(new Schema\Index('id_pk_id_index', ['id'], true, true), 'list_table_indexes_pk_id_test');
- $tableIndexes = $this->_sm->listTableIndexes('list_table_indexes_pk_id_test');
+ $tableIndexes = $this->schemaManager->listTableIndexes('list_table_indexes_pk_id_test');
self::assertArrayHasKey('primary', $tableIndexes, 'listTableIndexes() has to return a "primary" array key.');
- self::assertEquals(array('id'), array_map('strtolower', $tableIndexes['primary']->getColumns()));
+ self::assertEquals(['id'], array_map('strtolower', $tableIndexes['primary']->getColumns()));
self::assertTrue($tableIndexes['primary']->isUnique());
self::assertTrue($tableIndexes['primary']->isPrimary());
}
@@ -266,9 +267,9 @@ public function testListTableDateTypeColumns()
$table->addColumn('col_datetime', 'datetime');
$table->addColumn('col_datetimetz', 'datetimetz');
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns('tbl_date');
+ $columns = $this->schemaManager->listTableColumns('tbl_date');
self::assertSame('date', $columns['col_date']->getType()->getName());
self::assertSame('datetime', $columns['col_datetime']->getType()->getName());
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
index 40d0f03f108..e007eabda2a 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
@@ -6,8 +6,11 @@
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Comparator;
+use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
+use Doctrine\DBAL\Types\BlobType;
+use Doctrine\DBAL\Types\DecimalType;
use Doctrine\DBAL\Types\Type;
use function array_map;
use function array_pop;
@@ -20,11 +23,11 @@ protected function tearDown()
{
parent::tearDown();
- if (!$this->_conn) {
+ if (! $this->connection) {
return;
}
- $this->_conn->getConfiguration()->setFilterSchemaAssetsExpression(null);
+ $this->connection->getConfiguration()->setFilterSchemaAssetsExpression(null);
}
/**
@@ -32,9 +35,9 @@ protected function tearDown()
*/
public function testGetSearchPath()
{
- $params = $this->_conn->getParams();
+ $params = $this->connection->getParams();
- $paths = $this->_sm->getSchemaSearchPaths();
+ $paths = $this->schemaManager->getSchemaSearchPaths();
self::assertEquals([$params['user'], 'public'], $paths);
}
@@ -43,7 +46,7 @@ public function testGetSearchPath()
*/
public function testGetSchemaNames()
{
- $names = $this->_sm->getSchemaNames();
+ $names = $this->schemaManager->getSchemaNames();
self::assertInternalType('array', $names);
self::assertNotEmpty($names);
@@ -55,20 +58,20 @@ public function testGetSchemaNames()
*/
public function testSupportDomainTypeFallback()
{
- $createDomainTypeSQL = "CREATE DOMAIN MyMoney AS DECIMAL(18,2)";
- $this->_conn->exec($createDomainTypeSQL);
+ $createDomainTypeSQL = 'CREATE DOMAIN MyMoney AS DECIMAL(18,2)';
+ $this->connection->exec($createDomainTypeSQL);
- $createTableSQL = "CREATE TABLE domain_type_test (id INT PRIMARY KEY, value MyMoney)";
- $this->_conn->exec($createTableSQL);
+ $createTableSQL = 'CREATE TABLE domain_type_test (id INT PRIMARY KEY, value MyMoney)';
+ $this->connection->exec($createTableSQL);
- $table = $this->_conn->getSchemaManager()->listTableDetails('domain_type_test');
- self::assertInstanceOf('Doctrine\DBAL\Types\DecimalType', $table->getColumn('value')->getType());
+ $table = $this->connection->getSchemaManager()->listTableDetails('domain_type_test');
+ self::assertInstanceOf(DecimalType::class, $table->getColumn('value')->getType());
- Type::addType('MyMoney', 'Doctrine\Tests\DBAL\Functional\Schema\MoneyType');
- $this->_conn->getDatabasePlatform()->registerDoctrineTypeMapping('MyMoney', 'MyMoney');
+ Type::addType('MyMoney', MoneyType::class);
+ $this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('MyMoney', 'MyMoney');
- $table = $this->_conn->getSchemaManager()->listTableDetails('domain_type_test');
- self::assertInstanceOf('Doctrine\Tests\DBAL\Functional\Schema\MoneyType', $table->getColumn('value')->getType());
+ $table = $this->connection->getSchemaManager()->listTableDetails('domain_type_test');
+ self::assertInstanceOf(MoneyType::class, $table->getColumn('value')->getType());
}
/**
@@ -76,11 +79,11 @@ public function testSupportDomainTypeFallback()
*/
public function testDetectsAutoIncrement()
{
- $autoincTable = new \Doctrine\DBAL\Schema\Table('autoinc_table');
- $column = $autoincTable->addColumn('id', 'integer');
+ $autoincTable = new Table('autoinc_table');
+ $column = $autoincTable->addColumn('id', 'integer');
$column->setAutoincrement(true);
- $this->_sm->createTable($autoincTable);
- $autoincTable = $this->_sm->listTableDetails('autoinc_table');
+ $this->schemaManager->createTable($autoincTable);
+ $autoincTable = $this->schemaManager->listTableDetails('autoinc_table');
self::assertTrue($autoincTable->getColumn('id')->getAutoincrement());
}
@@ -90,27 +93,27 @@ public function testDetectsAutoIncrement()
*/
public function testAlterTableAutoIncrementAdd()
{
- $tableFrom = new \Doctrine\DBAL\Schema\Table('autoinc_table_add');
- $column = $tableFrom->addColumn('id', 'integer');
- $this->_sm->createTable($tableFrom);
- $tableFrom = $this->_sm->listTableDetails('autoinc_table_add');
+ $tableFrom = new Table('autoinc_table_add');
+ $column = $tableFrom->addColumn('id', 'integer');
+ $this->schemaManager->createTable($tableFrom);
+ $tableFrom = $this->schemaManager->listTableDetails('autoinc_table_add');
self::assertFalse($tableFrom->getColumn('id')->getAutoincrement());
- $tableTo = new \Doctrine\DBAL\Schema\Table('autoinc_table_add');
- $column = $tableTo->addColumn('id', 'integer');
+ $tableTo = new Table('autoinc_table_add');
+ $column = $tableTo->addColumn('id', 'integer');
$column->setAutoincrement(true);
- $c = new \Doctrine\DBAL\Schema\Comparator();
+ $c = new Comparator();
$diff = $c->diffTable($tableFrom, $tableTo);
- $sql = $this->_conn->getDatabasePlatform()->getAlterTableSQL($diff);
- self::assertEquals(array(
- "CREATE SEQUENCE autoinc_table_add_id_seq",
+ $sql = $this->connection->getDatabasePlatform()->getAlterTableSQL($diff);
+ self::assertEquals([
+ 'CREATE SEQUENCE autoinc_table_add_id_seq',
"SELECT setval('autoinc_table_add_id_seq', (SELECT MAX(id) FROM autoinc_table_add))",
"ALTER TABLE autoinc_table_add ALTER id SET DEFAULT nextval('autoinc_table_add_id_seq')",
- ), $sql);
+ ], $sql);
- $this->_sm->alterTable($diff);
- $tableFinal = $this->_sm->listTableDetails('autoinc_table_add');
+ $this->schemaManager->alterTable($diff);
+ $tableFinal = $this->schemaManager->listTableDetails('autoinc_table_add');
self::assertTrue($tableFinal->getColumn('id')->getAutoincrement());
}
@@ -119,23 +122,23 @@ public function testAlterTableAutoIncrementAdd()
*/
public function testAlterTableAutoIncrementDrop()
{
- $tableFrom = new \Doctrine\DBAL\Schema\Table('autoinc_table_drop');
- $column = $tableFrom->addColumn('id', 'integer');
+ $tableFrom = new Table('autoinc_table_drop');
+ $column = $tableFrom->addColumn('id', 'integer');
$column->setAutoincrement(true);
- $this->_sm->createTable($tableFrom);
- $tableFrom = $this->_sm->listTableDetails('autoinc_table_drop');
+ $this->schemaManager->createTable($tableFrom);
+ $tableFrom = $this->schemaManager->listTableDetails('autoinc_table_drop');
self::assertTrue($tableFrom->getColumn('id')->getAutoincrement());
- $tableTo = new \Doctrine\DBAL\Schema\Table('autoinc_table_drop');
- $column = $tableTo->addColumn('id', 'integer');
+ $tableTo = new Table('autoinc_table_drop');
+ $column = $tableTo->addColumn('id', 'integer');
- $c = new \Doctrine\DBAL\Schema\Comparator();
+ $c = new Comparator();
$diff = $c->diffTable($tableFrom, $tableTo);
- self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $diff, "There should be a difference and not false being returned from the table comparison");
- self::assertEquals(array("ALTER TABLE autoinc_table_drop ALTER id DROP DEFAULT"), $this->_conn->getDatabasePlatform()->getAlterTableSQL($diff));
+ self::assertInstanceOf(TableDiff::class, $diff, 'There should be a difference and not false being returned from the table comparison');
+ self::assertEquals(['ALTER TABLE autoinc_table_drop ALTER id DROP DEFAULT'], $this->connection->getDatabasePlatform()->getAlterTableSQL($diff));
- $this->_sm->alterTable($diff);
- $tableFinal = $this->_sm->listTableDetails('autoinc_table_drop');
+ $this->schemaManager->alterTable($diff);
+ $tableFinal = $this->schemaManager->listTableDetails('autoinc_table_drop');
self::assertFalse($tableFinal->getColumn('id')->getAutoincrement());
}
@@ -144,33 +147,33 @@ public function testAlterTableAutoIncrementDrop()
*/
public function testTableWithSchema()
{
- $this->_conn->exec('CREATE SCHEMA nested');
+ $this->connection->exec('CREATE SCHEMA nested');
- $nestedRelatedTable = new \Doctrine\DBAL\Schema\Table('nested.schemarelated');
- $column = $nestedRelatedTable->addColumn('id', 'integer');
+ $nestedRelatedTable = new Table('nested.schemarelated');
+ $column = $nestedRelatedTable->addColumn('id', 'integer');
$column->setAutoincrement(true);
- $nestedRelatedTable->setPrimaryKey(array('id'));
+ $nestedRelatedTable->setPrimaryKey(['id']);
- $nestedSchemaTable = new \Doctrine\DBAL\Schema\Table('nested.schematable');
- $column = $nestedSchemaTable->addColumn('id', 'integer');
+ $nestedSchemaTable = new Table('nested.schematable');
+ $column = $nestedSchemaTable->addColumn('id', 'integer');
$column->setAutoincrement(true);
- $nestedSchemaTable->setPrimaryKey(array('id'));
- $nestedSchemaTable->addUnnamedForeignKeyConstraint($nestedRelatedTable, array('id'), array('id'));
+ $nestedSchemaTable->setPrimaryKey(['id']);
+ $nestedSchemaTable->addUnnamedForeignKeyConstraint($nestedRelatedTable, ['id'], ['id']);
- $this->_sm->createTable($nestedRelatedTable);
- $this->_sm->createTable($nestedSchemaTable);
+ $this->schemaManager->createTable($nestedRelatedTable);
+ $this->schemaManager->createTable($nestedSchemaTable);
- $tables = $this->_sm->listTableNames();
- self::assertContains('nested.schematable', $tables, "The table should be detected with its non-public schema.");
+ $tables = $this->schemaManager->listTableNames();
+ self::assertContains('nested.schematable', $tables, 'The table should be detected with its non-public schema.');
- $nestedSchemaTable = $this->_sm->listTableDetails('nested.schematable');
+ $nestedSchemaTable = $this->schemaManager->listTableDetails('nested.schematable');
self::assertTrue($nestedSchemaTable->hasColumn('id'));
- self::assertEquals(array('id'), $nestedSchemaTable->getPrimaryKey()->getColumns());
+ self::assertEquals(['id'], $nestedSchemaTable->getPrimaryKey()->getColumns());
$relatedFks = $nestedSchemaTable->getForeignKeys();
self::assertCount(1, $relatedFks);
$relatedFk = array_pop($relatedFks);
- self::assertEquals("nested.schemarelated", $relatedFk->getForeignTableName());
+ self::assertEquals('nested.schemarelated', $relatedFk->getForeignTableName());
}
/**
@@ -180,19 +183,19 @@ public function testTableWithSchema()
public function testReturnQuotedAssets()
{
$sql = 'create table dbal91_something ( id integer CONSTRAINT id_something PRIMARY KEY NOT NULL ,"table" integer );';
- $this->_conn->exec($sql);
+ $this->connection->exec($sql);
$sql = 'ALTER TABLE dbal91_something ADD CONSTRAINT something_input FOREIGN KEY( "table" ) REFERENCES dbal91_something ON UPDATE CASCADE;';
- $this->_conn->exec($sql);
+ $this->connection->exec($sql);
- $table = $this->_sm->listTableDetails('dbal91_something');
+ $table = $this->schemaManager->listTableDetails('dbal91_something');
self::assertEquals(
- array(
- "CREATE TABLE dbal91_something (id INT NOT NULL, \"table\" INT DEFAULT NULL, PRIMARY KEY(id))",
- "CREATE INDEX IDX_A9401304ECA7352B ON dbal91_something (\"table\")",
- ),
- $this->_conn->getDatabasePlatform()->getCreateTableSQL($table)
+ [
+ 'CREATE TABLE dbal91_something (id INT NOT NULL, "table" INT DEFAULT NULL, PRIMARY KEY(id))',
+ 'CREATE INDEX IDX_A9401304ECA7352B ON dbal91_something ("table")',
+ ],
+ $this->connection->getDatabasePlatform()->getCreateTableSQL($table)
);
}
@@ -201,50 +204,55 @@ public function testReturnQuotedAssets()
*/
public function testFilterSchemaExpression()
{
- $testTable = new \Doctrine\DBAL\Schema\Table('dbal204_test_prefix');
- $column = $testTable->addColumn('id', 'integer');
- $this->_sm->createTable($testTable);
- $testTable = new \Doctrine\DBAL\Schema\Table('dbal204_without_prefix');
- $column = $testTable->addColumn('id', 'integer');
- $this->_sm->createTable($testTable);
-
- $this->_conn->getConfiguration()->setFilterSchemaAssetsExpression('#^dbal204_#');
- $names = $this->_sm->listTableNames();
+ $testTable = new Table('dbal204_test_prefix');
+ $column = $testTable->addColumn('id', 'integer');
+ $this->schemaManager->createTable($testTable);
+ $testTable = new Table('dbal204_without_prefix');
+ $column = $testTable->addColumn('id', 'integer');
+ $this->schemaManager->createTable($testTable);
+
+ $this->connection->getConfiguration()->setFilterSchemaAssetsExpression('#^dbal204_#');
+ $names = $this->schemaManager->listTableNames();
self::assertCount(2, $names);
- $this->_conn->getConfiguration()->setFilterSchemaAssetsExpression('#^dbal204_test#');
- $names = $this->_sm->listTableNames();
+ $this->connection->getConfiguration()->setFilterSchemaAssetsExpression('#^dbal204_test#');
+ $names = $this->schemaManager->listTableNames();
self::assertCount(1, $names);
}
public function testListForeignKeys()
{
- if(!$this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) {
+ if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$this->markTestSkipped('Does not support foreign key constraints.');
}
- $fkOptions = array('SET NULL', 'SET DEFAULT', 'NO ACTION','CASCADE', 'RESTRICT');
- $foreignKeys = array();
- $fkTable = $this->getTestTable('test_create_fk1');
- for($i = 0; $i < count($fkOptions); $i++) {
- $fkTable->addColumn("foreign_key_test$i", 'integer');
- $foreignKeys[] = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
- array("foreign_key_test$i"), 'test_create_fk2', array('id'), "foreign_key_test_$i"."_fk", array('onDelete' => $fkOptions[$i]));
+ $fkOptions = ['SET NULL', 'SET DEFAULT', 'NO ACTION','CASCADE', 'RESTRICT'];
+ $foreignKeys = [];
+ $fkTable = $this->getTestTable('test_create_fk1');
+ for ($i = 0; $i < count($fkOptions); $i++) {
+ $fkTable->addColumn('foreign_key_test' . $i, 'integer');
+ $foreignKeys[] = new ForeignKeyConstraint(
+ ['foreign_key_test' . $i],
+ 'test_create_fk2',
+ ['id'],
+ 'foreign_key_test' . $i . '_fk',
+ ['onDelete' => $fkOptions[$i]]
+ );
}
- $this->_sm->dropAndCreateTable($fkTable);
+ $this->schemaManager->dropAndCreateTable($fkTable);
$this->createTestTable('test_create_fk2');
- foreach($foreignKeys as $foreignKey) {
- $this->_sm->createForeignKey($foreignKey, 'test_create_fk1');
+ foreach ($foreignKeys as $foreignKey) {
+ $this->schemaManager->createForeignKey($foreignKey, 'test_create_fk1');
}
- $fkeys = $this->_sm->listTableForeignKeys('test_create_fk1');
- self::assertEquals(count($foreignKeys), count($fkeys), "Table 'test_create_fk1' has to have " . count($foreignKeys) . " foreign keys.");
+ $fkeys = $this->schemaManager->listTableForeignKeys('test_create_fk1');
+ self::assertEquals(count($foreignKeys), count($fkeys), "Table 'test_create_fk1' has to have " . count($foreignKeys) . ' foreign keys.');
for ($i = 0; $i < count($fkeys); $i++) {
- self::assertEquals(array("foreign_key_test$i"), array_map('strtolower', $fkeys[$i]->getLocalColumns()));
- self::assertEquals(array('id'), array_map('strtolower', $fkeys[$i]->getForeignColumns()));
+ self::assertEquals(['foreign_key_test' . $i], array_map('strtolower', $fkeys[$i]->getLocalColumns()));
+ self::assertEquals(['id'], array_map('strtolower', $fkeys[$i]->getForeignColumns()));
self::assertEquals('test_create_fk2', strtolower($fkeys[0]->getForeignTableName()));
- if ($foreignKeys[$i]->getOption('onDelete') == 'NO ACTION') {
- self::assertFalse($fkeys[$i]->hasOption('onDelete'), 'Unexpected option: '. $fkeys[$i]->getOption('onDelete'));
+ if ($foreignKeys[$i]->getOption('onDelete') === 'NO ACTION') {
+ self::assertFalse($fkeys[$i]->hasOption('onDelete'), 'Unexpected option: ' . $fkeys[$i]->getOption('onDelete'));
} else {
self::assertEquals($foreignKeys[$i]->getOption('onDelete'), $fkeys[$i]->getOption('onDelete'));
}
@@ -256,14 +264,14 @@ public function testListForeignKeys()
*/
public function testDefaultValueCharacterVarying()
{
- $testTable = new \Doctrine\DBAL\Schema\Table('dbal511_default');
+ $testTable = new Table('dbal511_default');
$testTable->addColumn('id', 'integer');
- $testTable->addColumn('def', 'string', array('default' => 'foo'));
- $testTable->setPrimaryKey(array('id'));
+ $testTable->addColumn('def', 'string', ['default' => 'foo']);
+ $testTable->setPrimaryKey(['id']);
- $this->_sm->createTable($testTable);
+ $this->schemaManager->createTable($testTable);
- $databaseTable = $this->_sm->listTableDetails($testTable->getName());
+ $databaseTable = $this->schemaManager->listTableDetails($testTable->getName());
self::assertEquals('foo', $databaseTable->getColumn('def')->getDefault());
}
@@ -273,15 +281,15 @@ public function testDefaultValueCharacterVarying()
*/
public function testBooleanDefault()
{
- $table = new \Doctrine\DBAL\Schema\Table('ddc2843_bools');
+ $table = new Table('ddc2843_bools');
$table->addColumn('id', 'integer');
- $table->addColumn('checked', 'boolean', array('default' => false));
+ $table->addColumn('checked', 'boolean', ['default' => false]);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $databaseTable = $this->_sm->listTableDetails($table->getName());
+ $databaseTable = $this->schemaManager->listTableDetails($table->getName());
- $c = new \Doctrine\DBAL\Schema\Comparator();
+ $c = new Comparator();
$diff = $c->diffTable($table, $databaseTable);
self::assertFalse($diff);
@@ -291,20 +299,20 @@ public function testListTableWithBinary()
{
$tableName = 'test_binary_table';
- $table = new \Doctrine\DBAL\Schema\Table($tableName);
+ $table = new Table($tableName);
$table->addColumn('id', 'integer');
- $table->addColumn('column_varbinary', 'binary', array());
- $table->addColumn('column_binary', 'binary', array('fixed' => true));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('column_varbinary', 'binary', []);
+ $table->addColumn('column_binary', 'binary', ['fixed' => true]);
+ $table->setPrimaryKey(['id']);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $table = $this->_sm->listTableDetails($tableName);
+ $table = $this->schemaManager->listTableDetails($tableName);
- self::assertInstanceOf('Doctrine\DBAL\Types\BlobType', $table->getColumn('column_varbinary')->getType());
+ self::assertInstanceOf(BlobType::class, $table->getColumn('column_varbinary')->getType());
self::assertFalse($table->getColumn('column_varbinary')->getFixed());
- self::assertInstanceOf('Doctrine\DBAL\Types\BlobType', $table->getColumn('column_binary')->getType());
+ self::assertInstanceOf(BlobType::class, $table->getColumn('column_binary')->getType());
self::assertFalse($table->getColumn('column_binary')->getFixed());
}
@@ -314,12 +322,12 @@ public function testListQuotedTable()
$offlineTable->addColumn('id', 'integer');
$offlineTable->addColumn('username', 'string');
$offlineTable->addColumn('fk', 'integer');
- $offlineTable->setPrimaryKey(array('id'));
- $offlineTable->addForeignKeyConstraint($offlineTable, array('fk'), array('id'));
+ $offlineTable->setPrimaryKey(['id']);
+ $offlineTable->addForeignKeyConstraint($offlineTable, ['fk'], ['id']);
- $this->_sm->dropAndCreateTable($offlineTable);
+ $this->schemaManager->dropAndCreateTable($offlineTable);
- $onlineTable = $this->_sm->listTableDetails('"user"');
+ $onlineTable = $this->schemaManager->listTableDetails('"user"');
$comparator = new Schema\Comparator();
@@ -330,21 +338,23 @@ public function testListTablesExcludesViews()
{
$this->createTestTable('list_tables_excludes_views');
- $name = "list_tables_excludes_views_test_view";
- $sql = "SELECT * from list_tables_excludes_views";
+ $name = 'list_tables_excludes_views_test_view';
+ $sql = 'SELECT * from list_tables_excludes_views';
$view = new Schema\View($name, $sql);
- $this->_sm->dropAndCreateView($view);
+ $this->schemaManager->dropAndCreateView($view);
- $tables = $this->_sm->listTables();
+ $tables = $this->schemaManager->listTables();
$foundTable = false;
foreach ($tables as $table) {
- self::assertInstanceOf('Doctrine\DBAL\Schema\Table', $table, 'No Table instance was found in tables array.');
- if (strtolower($table->getName()) == 'list_tables_excludes_views_test_view') {
- $foundTable = true;
+ self::assertInstanceOf(Table::class, $table, 'No Table instance was found in tables array.');
+ if (strtolower($table->getName()) !== 'list_tables_excludes_views_test_view') {
+ continue;
}
+
+ $foundTable = true;
}
self::assertFalse($foundTable, 'View "list_tables_excludes_views_test_view" must not be found in table list');
@@ -359,11 +369,11 @@ public function testPartialIndexes()
$offlineTable->addColumn('id', 'integer');
$offlineTable->addColumn('name', 'string');
$offlineTable->addColumn('email', 'string');
- $offlineTable->addUniqueIndex(array('id', 'name'), 'simple_partial_index', array('where' => '(id IS NULL)'));
+ $offlineTable->addUniqueIndex(['id', 'name'], 'simple_partial_index', ['where' => '(id IS NULL)']);
- $this->_sm->dropAndCreateTable($offlineTable);
+ $this->schemaManager->dropAndCreateTable($offlineTable);
- $onlineTable = $this->_sm->listTableDetails('person');
+ $onlineTable = $this->schemaManager->listTableDetails('person');
$comparator = new Schema\Comparator();
@@ -376,25 +386,28 @@ public function testPartialIndexes()
/**
* @dataProvider jsonbColumnTypeProvider
*/
- public function testJsonbColumn(string $type): void
+ public function testJsonbColumn(string $type) : void
{
- if (!$this->_sm->getDatabasePlatform() instanceof PostgreSQL94Platform) {
- $this->markTestSkipped("Requires PostgresSQL 9.4+");
+ if (! $this->schemaManager->getDatabasePlatform() instanceof PostgreSQL94Platform) {
+ $this->markTestSkipped('Requires PostgresSQL 9.4+');
return;
}
$table = new Schema\Table('test_jsonb');
$table->addColumn('foo', $type)->setPlatformOption('jsonb', true);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
/** @var Schema\Column[] $columns */
- $columns = $this->_sm->listTableColumns('test_jsonb');
+ $columns = $this->schemaManager->listTableColumns('test_jsonb');
self::assertSame($type, $columns['foo']->getType()->getName());
self::assertTrue(true, $columns['foo']->getPlatformOption('jsonb'));
}
- public function jsonbColumnTypeProvider(): array
+ /**
+ * @return mixed[][]
+ */
+ public function jsonbColumnTypeProvider() : array
{
return [
[Type::JSON],
@@ -408,16 +421,16 @@ public function jsonbColumnTypeProvider(): array
public function testListNegativeColumnDefaultValue()
{
$table = new Schema\Table('test_default_negative');
- $table->addColumn('col_smallint', 'smallint', array('default' => -1));
- $table->addColumn('col_integer', 'integer', array('default' => -1));
- $table->addColumn('col_bigint', 'bigint', array('default' => -1));
- $table->addColumn('col_float', 'float', array('default' => -1.1));
- $table->addColumn('col_decimal', 'decimal', array('default' => -1.1));
- $table->addColumn('col_string', 'string', array('default' => '(-1)'));
+ $table->addColumn('col_smallint', 'smallint', ['default' => -1]);
+ $table->addColumn('col_integer', 'integer', ['default' => -1]);
+ $table->addColumn('col_bigint', 'bigint', ['default' => -1]);
+ $table->addColumn('col_float', 'float', ['default' => -1.1]);
+ $table->addColumn('col_decimal', 'decimal', ['default' => -1.1]);
+ $table->addColumn('col_string', 'string', ['default' => '(-1)']);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns('test_default_negative');
+ $columns = $this->schemaManager->listTableColumns('test_default_negative');
self::assertEquals(-1, $columns['col_smallint']->getDefault());
self::assertEquals(-1, $columns['col_integer']->getDefault());
@@ -427,6 +440,9 @@ public function testListNegativeColumnDefaultValue()
self::assertEquals('(-1)', $columns['col_string']->getDefault());
}
+ /**
+ * @return mixed[][]
+ */
public static function serialTypes() : array
{
return [
@@ -441,14 +457,14 @@ public static function serialTypes() : array
*/
public function testAutoIncrementCreatesSerialDataTypesWithoutADefaultValue(string $type) : void
{
- $tableName = "test_serial_type_$type";
+ $tableName = 'test_serial_type_' . $type;
$table = new Schema\Table($tableName);
$table->addColumn('id', $type, ['autoincrement' => true, 'notnull' => false]);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns($tableName);
+ $columns = $this->schemaManager->listTableColumns($tableName);
self::assertNull($columns['id']->getDefault());
}
@@ -459,46 +475,48 @@ public function testAutoIncrementCreatesSerialDataTypesWithoutADefaultValue(stri
*/
public function testAutoIncrementCreatesSerialDataTypesWithoutADefaultValueEvenWhenDefaultIsSet(string $type) : void
{
- $tableName = "test_serial_type_with_default_$type";
+ $tableName = 'test_serial_type_with_default_' . $type;
$table = new Schema\Table($tableName);
$table->addColumn('id', $type, ['autoincrement' => true, 'notnull' => false, 'default' => 1]);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns($tableName);
+ $columns = $this->schemaManager->listTableColumns($tableName);
self::assertNull($columns['id']->getDefault());
}
/**
* @group 2916
- *
* @dataProvider autoIncrementTypeMigrations
*/
public function testAlterTableAutoIncrementIntToBigInt(string $from, string $to, string $expected) : void
{
$tableFrom = new Table('autoinc_type_modification');
- $column = $tableFrom->addColumn('id', $from);
+ $column = $tableFrom->addColumn('id', $from);
$column->setAutoincrement(true);
- $this->_sm->dropAndCreateTable($tableFrom);
- $tableFrom = $this->_sm->listTableDetails('autoinc_type_modification');
+ $this->schemaManager->dropAndCreateTable($tableFrom);
+ $tableFrom = $this->schemaManager->listTableDetails('autoinc_type_modification');
self::assertTrue($tableFrom->getColumn('id')->getAutoincrement());
$tableTo = new Table('autoinc_type_modification');
- $column = $tableTo->addColumn('id', $to);
+ $column = $tableTo->addColumn('id', $to);
$column->setAutoincrement(true);
- $c = new Comparator();
+ $c = new Comparator();
$diff = $c->diffTable($tableFrom, $tableTo);
- self::assertInstanceOf(TableDiff::class, $diff, "There should be a difference and not false being returned from the table comparison");
- self::assertSame(['ALTER TABLE autoinc_type_modification ALTER id TYPE ' . $expected], $this->_conn->getDatabasePlatform()->getAlterTableSQL($diff));
+ self::assertInstanceOf(TableDiff::class, $diff, 'There should be a difference and not false being returned from the table comparison');
+ self::assertSame(['ALTER TABLE autoinc_type_modification ALTER id TYPE ' . $expected], $this->connection->getDatabasePlatform()->getAlterTableSQL($diff));
- $this->_sm->alterTable($diff);
- $tableFinal = $this->_sm->listTableDetails('autoinc_type_modification');
+ $this->schemaManager->alterTable($diff);
+ $tableFinal = $this->schemaManager->listTableDetails('autoinc_type_modification');
self::assertTrue($tableFinal->getColumn('id')->getAutoincrement());
}
+ /**
+ * @return mixed[][]
+ */
public function autoIncrementTypeMigrations() : array
{
return [
@@ -510,15 +528,16 @@ public function autoIncrementTypeMigrations() : array
class MoneyType extends Type
{
-
public function getName()
{
- return "MyMoney";
+ return 'MyMoney';
}
+ /**
+ * {@inheritDoc}
+ */
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return 'MyMoney';
}
-
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php
index 996e91699bb..f48c5157256 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php
@@ -12,17 +12,17 @@ public function testCreateAndListViews()
{
$this->createTestTable('view_test_table');
- $name = "doctrine_test_view";
- $sql = "SELECT * from DBA.view_test_table";
+ $name = 'doctrine_test_view';
+ $sql = 'SELECT * from DBA.view_test_table';
$view = new View($name, $sql);
- $this->_sm->dropAndCreateView($view);
+ $this->schemaManager->dropAndCreateView($view);
- $views = $this->_sm->listViews();
+ $views = $this->schemaManager->listViews();
- self::assertCount(1, $views, "Database has to have one view.");
- self::assertInstanceOf('Doctrine\DBAL\Schema\View', $views[$name]);
+ self::assertCount(1, $views, 'Database has to have one view.');
+ self::assertInstanceOf(View::class, $views[$name]);
self::assertEquals($name, $views[$name]->getName());
self::assertEquals($sql, $views[$name]->getSql());
}
@@ -30,16 +30,16 @@ public function testCreateAndListViews()
public function testDropAndCreateAdvancedIndex()
{
$table = $this->getTestTable('test_create_advanced_index');
- $this->_sm->dropAndCreateTable($table);
- $this->_sm->dropAndCreateIndex(
- new Index('test', array('test'), true, false, array('clustered', 'with_nulls_not_distinct', 'for_olap_workload')),
+ $this->schemaManager->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateIndex(
+ new Index('test', ['test'], true, false, ['clustered', 'with_nulls_not_distinct', 'for_olap_workload']),
$table->getName()
);
- $tableIndexes = $this->_sm->listTableIndexes('test_create_advanced_index');
+ $tableIndexes = $this->schemaManager->listTableIndexes('test_create_advanced_index');
self::assertInternalType('array', $tableIndexes);
self::assertEquals('test', $tableIndexes['test']->getName());
- self::assertEquals(array('test'), $tableIndexes['test']->getColumns());
+ self::assertEquals(['test'], $tableIndexes['test']->getColumns());
self::assertTrue($tableIndexes['test']->isUnique());
self::assertFalse($tableIndexes['test']->isPrimary());
self::assertTrue($tableIndexes['test']->hasFlag('clustered'));
@@ -50,13 +50,13 @@ public function testDropAndCreateAdvancedIndex()
public function testListTableColumnsWithFixedStringTypeColumn()
{
$table = new Table('list_table_columns_char');
- $table->addColumn('id', 'integer', array('notnull' => true));
- $table->addColumn('test', 'string', array('fixed' => true));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('id', 'integer', ['notnull' => true]);
+ $table->addColumn('test', 'string', ['fixed' => true]);
+ $table->setPrimaryKey(['id']);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns('list_table_columns_char');
+ $columns = $this->schemaManager->listTableColumns('list_table_columns_char');
self::assertArrayHasKey('test', $columns);
self::assertTrue($columns['test']->getFixed());
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php
index feee67710c2..cb7f37f15d5 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php
@@ -13,7 +13,7 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
protected function getPlatformName()
{
- return "mssql";
+ return 'mssql';
}
/**
@@ -23,53 +23,51 @@ public function testDropColumnConstraints()
{
$table = new Table('sqlsrv_drop_column');
$table->addColumn('id', 'integer');
- $table->addColumn('todrop', 'decimal', array('default' => 10.2));
+ $table->addColumn('todrop', 'decimal', ['default' => 10.2]);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $diff = new TableDiff('sqlsrv_drop_column', array(), array(), array(
- new Column('todrop', Type::getType('decimal'))
- ));
- $this->_sm->alterTable($diff);
+ $diff = new TableDiff('sqlsrv_drop_column', [], [], [new Column('todrop', Type::getType('decimal'))]);
+ $this->schemaManager->alterTable($diff);
- $columns = $this->_sm->listTableColumns('sqlsrv_drop_column');
+ $columns = $this->schemaManager->listTableColumns('sqlsrv_drop_column');
self::assertCount(1, $columns);
}
public function testColumnCollation()
{
- $table = new \Doctrine\DBAL\Schema\Table($tableName = 'test_collation');
+ $table = new Table($tableName = 'test_collation');
$column = $table->addColumn($columnName = 'test', 'string');
- $this->_sm->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns($tableName);
+ $this->schemaManager->dropAndCreateTable($table);
+ $columns = $this->schemaManager->listTableColumns($tableName);
self::assertTrue($columns[$columnName]->hasPlatformOption('collation')); // SQL Server should report a default collation on the column
$column->setPlatformOption('collation', $collation = 'Icelandic_CS_AS');
- $this->_sm->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns($tableName);
+ $this->schemaManager->dropAndCreateTable($table);
+ $columns = $this->schemaManager->listTableColumns($tableName);
self::assertEquals($collation, $columns[$columnName]->getPlatformOption('collation'));
}
public function testDefaultConstraints()
{
- $platform = $this->_sm->getDatabasePlatform();
- $table = new Table('sqlsrv_default_constraints');
+ $platform = $this->schemaManager->getDatabasePlatform();
+ $table = new Table('sqlsrv_default_constraints');
$table->addColumn('no_default', 'string');
- $table->addColumn('df_integer', 'integer', array('default' => 666));
- $table->addColumn('df_string_1', 'string', array('default' => 'foobar'));
- $table->addColumn('df_string_2', 'string', array('default' => 'Doctrine rocks!!!'));
- $table->addColumn('df_string_3', 'string', array('default' => 'another default value'));
- $table->addColumn('df_string_4', 'string', array('default' => 'column to rename'));
- $table->addColumn('df_boolean', 'boolean', array('default' => true));
- $table->addColumn('df_current_date', 'date', array('default' => $platform->getCurrentDateSQL()));
- $table->addColumn('df_current_time', 'time', array('default' => $platform->getCurrentTimeSQL()));
-
- $this->_sm->createTable($table);
- $columns = $this->_sm->listTableColumns('sqlsrv_default_constraints');
+ $table->addColumn('df_integer', 'integer', ['default' => 666]);
+ $table->addColumn('df_string_1', 'string', ['default' => 'foobar']);
+ $table->addColumn('df_string_2', 'string', ['default' => 'Doctrine rocks!!!']);
+ $table->addColumn('df_string_3', 'string', ['default' => 'another default value']);
+ $table->addColumn('df_string_4', 'string', ['default' => 'column to rename']);
+ $table->addColumn('df_boolean', 'boolean', ['default' => true]);
+ $table->addColumn('df_current_date', 'date', ['default' => $platform->getCurrentDateSQL()]);
+ $table->addColumn('df_current_time', 'time', ['default' => $platform->getCurrentTimeSQL()]);
+
+ $this->schemaManager->createTable($table);
+ $columns = $this->schemaManager->listTableColumns('sqlsrv_default_constraints');
self::assertNull($columns['no_default']->getDefault());
self::assertEquals(666, $columns['df_integer']->getDefault());
@@ -80,54 +78,52 @@ public function testDefaultConstraints()
self::assertSame($platform->getCurrentDateSQL(), $columns['df_current_date']->getDefault());
self::assertSame($platform->getCurrentTimeSQL(), $columns['df_current_time']->getDefault());
- $diff = new TableDiff(
+ $diff = new TableDiff(
'sqlsrv_default_constraints',
- array(
- new Column('df_current_timestamp', Type::getType('datetime'), array('default' => 'CURRENT_TIMESTAMP'))
- ),
- array(
+ [new Column('df_current_timestamp', Type::getType('datetime'), ['default' => 'CURRENT_TIMESTAMP'])],
+ [
'df_integer' => new ColumnDiff(
'df_integer',
- new Column('df_integer', Type::getType('integer'), array('default' => 0)),
- array('default'),
- new Column('df_integer', Type::getType('integer'), array('default' => 666))
+ new Column('df_integer', Type::getType('integer'), ['default' => 0]),
+ ['default'],
+ new Column('df_integer', Type::getType('integer'), ['default' => 666])
),
'df_string_2' => new ColumnDiff(
'df_string_2',
new Column('df_string_2', Type::getType('string')),
- array('default'),
- new Column('df_string_2', Type::getType('string'), array('default' => 'Doctrine rocks!!!'))
+ ['default'],
+ new Column('df_string_2', Type::getType('string'), ['default' => 'Doctrine rocks!!!'])
),
'df_string_3' => new ColumnDiff(
'df_string_3',
- new Column('df_string_3', Type::getType('string'), array('length' => 50, 'default' => 'another default value')),
- array('length'),
- new Column('df_string_3', Type::getType('string'), array('length' => 50, 'default' => 'another default value'))
+ new Column('df_string_3', Type::getType('string'), ['length' => 50, 'default' => 'another default value']),
+ ['length'],
+ new Column('df_string_3', Type::getType('string'), ['length' => 50, 'default' => 'another default value'])
),
'df_boolean' => new ColumnDiff(
'df_boolean',
- new Column('df_boolean', Type::getType('boolean'), array('default' => false)),
- array('default'),
- new Column('df_boolean', Type::getType('boolean'), array('default' => true))
- )
- ),
- array(
- 'df_string_1' => new Column('df_string_1', Type::getType('string'))
- ),
- array(),
- array(),
- array(),
+ new Column('df_boolean', Type::getType('boolean'), ['default' => false]),
+ ['default'],
+ new Column('df_boolean', Type::getType('boolean'), ['default' => true])
+ ),
+ ],
+ [
+ 'df_string_1' => new Column('df_string_1', Type::getType('string')),
+ ],
+ [],
+ [],
+ [],
$table
);
- $diff->newName = 'sqlsrv_default_constraints';
+ $diff->newName = 'sqlsrv_default_constraints';
$diff->renamedColumns['df_string_4'] = new Column(
'df_string_renamed',
Type::getType('string'),
- array('default' => 'column to rename')
+ ['default' => 'column to rename']
);
- $this->_sm->alterTable($diff);
- $columns = $this->_sm->listTableColumns('sqlsrv_default_constraints');
+ $this->schemaManager->alterTable($diff);
+ $columns = $this->schemaManager->listTableColumns('sqlsrv_default_constraints');
self::assertNull($columns['no_default']->getDefault());
self::assertEquals('CURRENT_TIMESTAMP', $columns['df_current_timestamp']->getDefault());
@@ -142,30 +138,30 @@ public function testDefaultConstraints()
*/
$diff = new TableDiff(
'sqlsrv_default_constraints',
- array(),
- array(
+ [],
+ [
'df_current_timestamp' => new ColumnDiff(
'df_current_timestamp',
new Column('df_current_timestamp', Type::getType('datetime')),
- array('default'),
- new Column('df_current_timestamp', Type::getType('datetime'), array('default' => 'CURRENT_TIMESTAMP'))
+ ['default'],
+ new Column('df_current_timestamp', Type::getType('datetime'), ['default' => 'CURRENT_TIMESTAMP'])
),
'df_integer' => new ColumnDiff(
'df_integer',
- new Column('df_integer', Type::getType('integer'), array('default' => 666)),
- array('default'),
- new Column('df_integer', Type::getType('integer'), array('default' => 0))
- )
- ),
- array(),
- array(),
- array(),
- array(),
+ new Column('df_integer', Type::getType('integer'), ['default' => 666]),
+ ['default'],
+ new Column('df_integer', Type::getType('integer'), ['default' => 0])
+ ),
+ ],
+ [],
+ [],
+ [],
+ [],
$table
);
- $this->_sm->alterTable($diff);
- $columns = $this->_sm->listTableColumns('sqlsrv_default_constraints');
+ $this->schemaManager->alterTable($diff);
+ $columns = $this->schemaManager->listTableColumns('sqlsrv_default_constraints');
self::assertNull($columns['df_current_timestamp']->getDefault());
self::assertEquals(666, $columns['df_integer']->getDefault());
@@ -177,23 +173,23 @@ public function testDefaultConstraints()
public function testColumnComments()
{
$table = new Table('sqlsrv_column_comment');
- $table->addColumn('id', 'integer', array('autoincrement' => true));
- $table->addColumn('comment_null', 'integer', array('comment' => null));
- $table->addColumn('comment_false', 'integer', array('comment' => false));
- $table->addColumn('comment_empty_string', 'integer', array('comment' => ''));
- $table->addColumn('comment_integer_0', 'integer', array('comment' => 0));
- $table->addColumn('comment_float_0', 'integer', array('comment' => 0.0));
- $table->addColumn('comment_string_0', 'integer', array('comment' => '0'));
- $table->addColumn('comment', 'integer', array('comment' => 'Doctrine 0wnz you!'));
- $table->addColumn('`comment_quoted`', 'integer', array('comment' => 'Doctrine 0wnz comments for explicitly quoted columns!'));
- $table->addColumn('create', 'integer', array('comment' => 'Doctrine 0wnz comments for reserved keyword columns!'));
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
+ $table->addColumn('comment_null', 'integer', ['comment' => null]);
+ $table->addColumn('comment_false', 'integer', ['comment' => false]);
+ $table->addColumn('comment_empty_string', 'integer', ['comment' => '']);
+ $table->addColumn('comment_integer_0', 'integer', ['comment' => 0]);
+ $table->addColumn('comment_float_0', 'integer', ['comment' => 0.0]);
+ $table->addColumn('comment_string_0', 'integer', ['comment' => '0']);
+ $table->addColumn('comment', 'integer', ['comment' => 'Doctrine 0wnz you!']);
+ $table->addColumn('`comment_quoted`', 'integer', ['comment' => 'Doctrine 0wnz comments for explicitly quoted columns!']);
+ $table->addColumn('create', 'integer', ['comment' => 'Doctrine 0wnz comments for reserved keyword columns!']);
$table->addColumn('commented_type', 'object');
- $table->addColumn('commented_type_with_comment', 'array', array('comment' => 'Doctrine array type.'));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('commented_type_with_comment', 'array', ['comment' => 'Doctrine array type.']);
+ $table->setPrimaryKey(['id']);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $columns = $this->_sm->listTableColumns("sqlsrv_column_comment");
+ $columns = $this->schemaManager->listTableColumns('sqlsrv_column_comment');
self::assertCount(12, $columns);
self::assertNull($columns['id']->getComment());
self::assertNull($columns['comment_null']->getComment());
@@ -208,92 +204,92 @@ public function testColumnComments()
self::assertNull($columns['commented_type']->getComment());
self::assertEquals('Doctrine array type.', $columns['commented_type_with_comment']->getComment());
- $tableDiff = new TableDiff('sqlsrv_column_comment');
- $tableDiff->fromTable = $table;
- $tableDiff->addedColumns['added_comment_none'] = new Column('added_comment_none', Type::getType('integer'));
- $tableDiff->addedColumns['added_comment_null'] = new Column('added_comment_null', Type::getType('integer'), array('comment' => null));
- $tableDiff->addedColumns['added_comment_false'] = new Column('added_comment_false', Type::getType('integer'), array('comment' => false));
- $tableDiff->addedColumns['added_comment_empty_string'] = new Column('added_comment_empty_string', Type::getType('integer'), array('comment' => ''));
- $tableDiff->addedColumns['added_comment_integer_0'] = new Column('added_comment_integer_0', Type::getType('integer'), array('comment' => 0));
- $tableDiff->addedColumns['added_comment_float_0'] = new Column('added_comment_float_0', Type::getType('integer'), array('comment' => 0.0));
- $tableDiff->addedColumns['added_comment_string_0'] = new Column('added_comment_string_0', Type::getType('integer'), array('comment' => '0'));
- $tableDiff->addedColumns['added_comment'] = new Column('added_comment', Type::getType('integer'), array('comment' => 'Doctrine'));
- $tableDiff->addedColumns['`added_comment_quoted`'] = new Column('`added_comment_quoted`', Type::getType('integer'), array('comment' => 'rulez'));
- $tableDiff->addedColumns['select'] = new Column('select', Type::getType('integer'), array('comment' => '666'));
- $tableDiff->addedColumns['added_commented_type'] = new Column('added_commented_type', Type::getType('object'));
- $tableDiff->addedColumns['added_commented_type_with_comment'] = new Column('added_commented_type_with_comment', Type::getType('array'), array('comment' => '666'));
-
- $tableDiff->renamedColumns['comment_float_0'] = new Column('comment_double_0', Type::getType('decimal'), array('comment' => 'Double for real!'));
+ $tableDiff = new TableDiff('sqlsrv_column_comment');
+ $tableDiff->fromTable = $table;
+ $tableDiff->addedColumns['added_comment_none'] = new Column('added_comment_none', Type::getType('integer'));
+ $tableDiff->addedColumns['added_comment_null'] = new Column('added_comment_null', Type::getType('integer'), ['comment' => null]);
+ $tableDiff->addedColumns['added_comment_false'] = new Column('added_comment_false', Type::getType('integer'), ['comment' => false]);
+ $tableDiff->addedColumns['added_comment_empty_string'] = new Column('added_comment_empty_string', Type::getType('integer'), ['comment' => '']);
+ $tableDiff->addedColumns['added_comment_integer_0'] = new Column('added_comment_integer_0', Type::getType('integer'), ['comment' => 0]);
+ $tableDiff->addedColumns['added_comment_float_0'] = new Column('added_comment_float_0', Type::getType('integer'), ['comment' => 0.0]);
+ $tableDiff->addedColumns['added_comment_string_0'] = new Column('added_comment_string_0', Type::getType('integer'), ['comment' => '0']);
+ $tableDiff->addedColumns['added_comment'] = new Column('added_comment', Type::getType('integer'), ['comment' => 'Doctrine']);
+ $tableDiff->addedColumns['`added_comment_quoted`'] = new Column('`added_comment_quoted`', Type::getType('integer'), ['comment' => 'rulez']);
+ $tableDiff->addedColumns['select'] = new Column('select', Type::getType('integer'), ['comment' => '666']);
+ $tableDiff->addedColumns['added_commented_type'] = new Column('added_commented_type', Type::getType('object'));
+ $tableDiff->addedColumns['added_commented_type_with_comment'] = new Column('added_commented_type_with_comment', Type::getType('array'), ['comment' => '666']);
+
+ $tableDiff->renamedColumns['comment_float_0'] = new Column('comment_double_0', Type::getType('decimal'), ['comment' => 'Double for real!']);
// Add comment to non-commented column.
$tableDiff->changedColumns['id'] = new ColumnDiff(
'id',
- new Column('id', Type::getType('integer'), array('autoincrement' => true, 'comment' => 'primary')),
- array('comment'),
- new Column('id', Type::getType('integer'), array('autoincrement' => true))
+ new Column('id', Type::getType('integer'), ['autoincrement' => true, 'comment' => 'primary']),
+ ['comment'],
+ new Column('id', Type::getType('integer'), ['autoincrement' => true])
);
// Remove comment from null-commented column.
$tableDiff->changedColumns['comment_null'] = new ColumnDiff(
'comment_null',
new Column('comment_null', Type::getType('string')),
- array('type'),
- new Column('comment_null', Type::getType('integer'), array('comment' => null))
+ ['type'],
+ new Column('comment_null', Type::getType('integer'), ['comment' => null])
);
// Add comment to false-commented column.
$tableDiff->changedColumns['comment_false'] = new ColumnDiff(
'comment_false',
- new Column('comment_false', Type::getType('integer'), array('comment' => 'false')),
- array('comment'),
- new Column('comment_false', Type::getType('integer'), array('comment' => false))
+ new Column('comment_false', Type::getType('integer'), ['comment' => 'false']),
+ ['comment'],
+ new Column('comment_false', Type::getType('integer'), ['comment' => false])
);
// Change type to custom type from empty string commented column.
$tableDiff->changedColumns['comment_empty_string'] = new ColumnDiff(
'comment_empty_string',
new Column('comment_empty_string', Type::getType('object')),
- array('type'),
- new Column('comment_empty_string', Type::getType('integer'), array('comment' => ''))
+ ['type'],
+ new Column('comment_empty_string', Type::getType('integer'), ['comment' => ''])
);
// Change comment to false-comment from zero-string commented column.
$tableDiff->changedColumns['comment_string_0'] = new ColumnDiff(
'comment_string_0',
- new Column('comment_string_0', Type::getType('integer'), array('comment' => false)),
- array('comment'),
- new Column('comment_string_0', Type::getType('integer'), array('comment' => '0'))
+ new Column('comment_string_0', Type::getType('integer'), ['comment' => false]),
+ ['comment'],
+ new Column('comment_string_0', Type::getType('integer'), ['comment' => '0'])
);
// Remove comment from regular commented column.
$tableDiff->changedColumns['comment'] = new ColumnDiff(
'comment',
new Column('comment', Type::getType('integer')),
- array('comment'),
- new Column('comment', Type::getType('integer'), array('comment' => 'Doctrine 0wnz you!'))
+ ['comment'],
+ new Column('comment', Type::getType('integer'), ['comment' => 'Doctrine 0wnz you!'])
);
// Change comment and change type to custom type from regular commented column.
$tableDiff->changedColumns['`comment_quoted`'] = new ColumnDiff(
'`comment_quoted`',
- new Column('`comment_quoted`', Type::getType('array'), array('comment' => 'Doctrine array.')),
- array('comment', 'type'),
- new Column('`comment_quoted`', Type::getType('integer'), array('comment' => 'Doctrine 0wnz you!'))
+ new Column('`comment_quoted`', Type::getType('array'), ['comment' => 'Doctrine array.']),
+ ['comment', 'type'],
+ new Column('`comment_quoted`', Type::getType('integer'), ['comment' => 'Doctrine 0wnz you!'])
);
// Remove comment and change type to custom type from regular commented column.
$tableDiff->changedColumns['create'] = new ColumnDiff(
'create',
new Column('create', Type::getType('object')),
- array('comment', 'type'),
- new Column('create', Type::getType('integer'), array('comment' => 'Doctrine 0wnz comments for reserved keyword columns!'))
+ ['comment', 'type'],
+ new Column('create', Type::getType('integer'), ['comment' => 'Doctrine 0wnz comments for reserved keyword columns!'])
);
// Add comment and change custom type to regular type from non-commented column.
$tableDiff->changedColumns['commented_type'] = new ColumnDiff(
'commented_type',
- new Column('commented_type', Type::getType('integer'), array('comment' => 'foo')),
- array('comment', 'type'),
+ new Column('commented_type', Type::getType('integer'), ['comment' => 'foo']),
+ ['comment', 'type'],
new Column('commented_type', Type::getType('object'))
);
@@ -301,15 +297,15 @@ public function testColumnComments()
$tableDiff->changedColumns['commented_type_with_comment'] = new ColumnDiff(
'commented_type_with_comment',
new Column('commented_type_with_comment', Type::getType('array')),
- array('comment'),
- new Column('commented_type_with_comment', Type::getType('array'), array('comment' => 'Doctrine array type.'))
+ ['comment'],
+ new Column('commented_type_with_comment', Type::getType('array'), ['comment' => 'Doctrine array type.'])
);
- $tableDiff->removedColumns['comment_integer_0'] = new Column('comment_integer_0', Type::getType('integer'), array('comment' => 0));
+ $tableDiff->removedColumns['comment_integer_0'] = new Column('comment_integer_0', Type::getType('integer'), ['comment' => 0]);
- $this->_sm->alterTable($tableDiff);
+ $this->schemaManager->alterTable($tableDiff);
- $columns = $this->_sm->listTableColumns("sqlsrv_column_comment");
+ $columns = $this->schemaManager->listTableColumns('sqlsrv_column_comment');
self::assertCount(23, $columns);
self::assertEquals('primary', $columns['id']->getComment());
self::assertNull($columns['comment_null']->getComment());
@@ -346,17 +342,17 @@ public function testPkOrdering()
// key_ordinal holds the index ordering. index_column_id is just a unique identifier
// for index columns within the given index.
$table = new Table('sqlsrv_pk_ordering');
- $table->addColumn('colA', 'integer', array('notnull' => true));
- $table->addColumn('colB', 'integer', array('notnull' => true));
- $table->setPrimaryKey(array('colB', 'colA'));
- $this->_sm->createTable($table);
+ $table->addColumn('colA', 'integer', ['notnull' => true]);
+ $table->addColumn('colB', 'integer', ['notnull' => true]);
+ $table->setPrimaryKey(['colB', 'colA']);
+ $this->schemaManager->createTable($table);
- $indexes = $this->_sm->listTableIndexes('sqlsrv_pk_ordering');
+ $indexes = $this->schemaManager->listTableIndexes('sqlsrv_pk_ordering');
self::assertCount(1, $indexes);
$firstIndex = current($indexes);
- $columns = $firstIndex->getColumns();
+ $columns = $firstIndex->getColumns();
self::assertCount(2, $columns);
self::assertEquals('colB', $columns[0]);
self::assertEquals('colA', $columns[1]);
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
index 6c5329a0bab..425039fa023 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
@@ -4,16 +4,32 @@
use Doctrine\Common\EventManager;
use Doctrine\DBAL\DBALException;
+use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Platforms\OraclePlatform;
+use Doctrine\DBAL\Schema\AbstractAsset;
+use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Comparator;
+use Doctrine\DBAL\Schema\ForeignKeyConstraint;
+use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\SchemaDiff;
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
+use Doctrine\DBAL\Schema\View;
+use Doctrine\DBAL\Types\ArrayType;
+use Doctrine\DBAL\Types\BinaryType;
+use Doctrine\DBAL\Types\DateIntervalType;
+use Doctrine\DBAL\Types\DateTimeType;
+use Doctrine\DBAL\Types\DecimalType;
+use Doctrine\DBAL\Types\IntegerType;
+use Doctrine\DBAL\Types\ObjectType;
+use Doctrine\DBAL\Types\StringType;
+use Doctrine\DBAL\Types\TextType;
use Doctrine\DBAL\Types\Type;
+use Doctrine\Tests\DbalFunctionalTestCase;
use function array_filter;
use function array_keys;
use function array_map;
@@ -23,7 +39,6 @@
use function current;
use function end;
use function explode;
-use function get_class;
use function in_array;
use function str_replace;
use function strcasecmp;
@@ -31,20 +46,17 @@
use function strtolower;
use function substr;
-class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTestCase
+class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
{
- /**
- * @var \Doctrine\DBAL\Schema\AbstractSchemaManager
- */
- protected $_sm;
+ /** @var AbstractSchemaManager */
+ protected $schemaManager;
protected function getPlatformName()
{
- $class = get_class($this);
- $e = explode('\\', $class);
+ $class = static::class;
+ $e = explode('\\', $class);
$testClass = end($e);
- $dbms = strtolower(str_replace('SchemaManagerTest', null, $testClass));
- return $dbms;
+ return strtolower(str_replace('SchemaManagerTest', null, $testClass));
}
protected function setUp()
@@ -53,11 +65,11 @@ protected function setUp()
$dbms = $this->getPlatformName();
- if ($this->_conn->getDatabasePlatform()->getName() !== $dbms) {
- $this->markTestSkipped(get_class($this) . ' requires the use of ' . $dbms);
+ if ($this->connection->getDatabasePlatform()->getName() !== $dbms) {
+ $this->markTestSkipped(static::class . ' requires the use of ' . $dbms);
}
- $this->_sm = $this->_conn->getSchemaManager();
+ $this->schemaManager = $this->connection->getSchemaManager();
}
@@ -65,12 +77,12 @@ protected function tearDown()
{
parent::tearDown();
- $this->_sm->tryMethod('dropTable', 'testschema.my_table_in_namespace');
+ $this->schemaManager->tryMethod('dropTable', 'testschema.my_table_in_namespace');
//TODO: SchemaDiff does not drop removed namespaces?
try {
//sql server versions below 2016 do not support 'IF EXISTS' so we have to catch the exception here
- $this->_conn->exec('DROP SCHEMA testschema');
+ $this->connection->exec('DROP SCHEMA testschema');
} catch (DBALException $e) {
return;
}
@@ -82,36 +94,36 @@ protected function tearDown()
*/
public function testDropsDatabaseWithActiveConnections()
{
- if (! $this->_sm->getDatabasePlatform()->supportsCreateDropDatabase()) {
+ if (! $this->schemaManager->getDatabasePlatform()->supportsCreateDropDatabase()) {
$this->markTestSkipped('Cannot drop Database client side with this Driver.');
}
- $this->_sm->dropAndCreateDatabase('test_drop_database');
+ $this->schemaManager->dropAndCreateDatabase('test_drop_database');
- $knownDatabases = $this->_sm->listDatabases();
- if ($this->_conn->getDatabasePlatform() instanceof OraclePlatform) {
+ $knownDatabases = $this->schemaManager->listDatabases();
+ if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
self::assertContains('TEST_DROP_DATABASE', $knownDatabases);
} else {
self::assertContains('test_drop_database', $knownDatabases);
}
- $params = $this->_conn->getParams();
- if ($this->_conn->getDatabasePlatform() instanceof OraclePlatform) {
+ $params = $this->connection->getParams();
+ if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
$params['user'] = 'test_drop_database';
} else {
$params['dbname'] = 'test_drop_database';
}
- $user = $params['user'] ?? null;
+ $user = $params['user'] ?? null;
$password = $params['password'] ?? null;
- $connection = $this->_conn->getDriver()->connect($params, $user, $password);
+ $connection = $this->connection->getDriver()->connect($params, $user, $password);
- self::assertInstanceOf('Doctrine\DBAL\Driver\Connection', $connection);
+ self::assertInstanceOf(Connection::class, $connection);
- $this->_sm->dropDatabase('test_drop_database');
+ $this->schemaManager->dropDatabase('test_drop_database');
- self::assertNotContains('test_drop_database', $this->_sm->listDatabases());
+ self::assertNotContains('test_drop_database', $this->schemaManager->listDatabases());
}
/**
@@ -119,22 +131,25 @@ public function testDropsDatabaseWithActiveConnections()
*/
public function testDropAndCreateSequence()
{
- if ( ! $this->_conn->getDatabasePlatform()->supportsSequences()) {
- $this->markTestSkipped($this->_conn->getDriver()->getName().' does not support sequences.');
+ if (! $this->connection->getDatabasePlatform()->supportsSequences()) {
+ $this->markTestSkipped($this->connection->getDriver()->getName() . ' does not support sequences.');
}
$name = 'dropcreate_sequences_test_seq';
- $this->_sm->dropAndCreateSequence(new Sequence($name, 20, 10));
+ $this->schemaManager->dropAndCreateSequence(new Sequence($name, 20, 10));
- self::assertTrue($this->hasElementWithName($this->_sm->listSequences(), $name));
+ self::assertTrue($this->hasElementWithName($this->schemaManager->listSequences(), $name));
}
+ /**
+ * @param AbstractAsset[] $items
+ */
private function hasElementWithName(array $items, string $name) : bool
{
$filteredList = array_filter(
$items,
- function (\Doctrine\DBAL\Schema\AbstractAsset $item) use ($name) : bool {
+ static function (AbstractAsset $item) use ($name) : bool {
return $item->getShortestName($item->getNamespaceName()) === $name;
}
);
@@ -144,14 +159,14 @@ function (\Doctrine\DBAL\Schema\AbstractAsset $item) use ($name) : bool {
public function testListSequences()
{
- if (! $this->_conn->getDatabasePlatform()->supportsSequences()) {
- $this->markTestSkipped($this->_conn->getDriver()->getName() . ' does not support sequences.');
+ if (! $this->connection->getDatabasePlatform()->supportsSequences()) {
+ $this->markTestSkipped($this->connection->getDriver()->getName() . ' does not support sequences.');
}
$sequence = new Sequence('list_sequences_test_seq', 20, 10);
- $this->_sm->createSequence($sequence);
+ $this->schemaManager->createSequence($sequence);
- $sequences = $this->_sm->listSequences();
+ $sequences = $this->schemaManager->listSequences();
self::assertInternalType('array', $sequences, 'listSequences() should return an array.');
@@ -172,12 +187,12 @@ public function testListSequences()
public function testListDatabases()
{
- if (!$this->_sm->getDatabasePlatform()->supportsCreateDropDatabase()) {
+ if (! $this->schemaManager->getDatabasePlatform()->supportsCreateDropDatabase()) {
$this->markTestSkipped('Cannot drop Database client side with this Driver.');
}
- $this->_sm->dropAndCreateDatabase('test_create_database');
- $databases = $this->_sm->listDatabases();
+ $this->schemaManager->dropAndCreateDatabase('test_create_database');
+ $databases = $this->schemaManager->listDatabases();
$databases = array_map('strtolower', $databases);
@@ -189,18 +204,18 @@ public function testListDatabases()
*/
public function testListNamespaceNames()
{
- if (!$this->_sm->getDatabasePlatform()->supportsSchemas()) {
+ if (! $this->schemaManager->getDatabasePlatform()->supportsSchemas()) {
$this->markTestSkipped('Platform does not support schemas.');
}
// Currently dropping schemas is not supported, so we have to workaround here.
- $namespaces = $this->_sm->listNamespaceNames();
+ $namespaces = $this->schemaManager->listNamespaceNames();
$namespaces = array_map('strtolower', $namespaces);
- if (!in_array('test_create_schema', $namespaces)) {
- $this->_conn->executeUpdate($this->_sm->getDatabasePlatform()->getCreateSchemaSQL('test_create_schema'));
+ if (! in_array('test_create_schema', $namespaces)) {
+ $this->connection->executeUpdate($this->schemaManager->getDatabasePlatform()->getCreateSchemaSQL('test_create_schema'));
- $namespaces = $this->_sm->listNamespaceNames();
+ $namespaces = $this->schemaManager->listNamespaceNames();
$namespaces = array_map('strtolower', $namespaces);
}
@@ -210,37 +225,39 @@ public function testListNamespaceNames()
public function testListTables()
{
$this->createTestTable('list_tables_test');
- $tables = $this->_sm->listTables();
+ $tables = $this->schemaManager->listTables();
self::assertInternalType('array', $tables);
self::assertTrue(count($tables) > 0, "List Tables has to find at least one table named 'list_tables_test'.");
$foundTable = false;
foreach ($tables as $table) {
- self::assertInstanceOf('Doctrine\DBAL\Schema\Table', $table);
- if (strtolower($table->getName()) == 'list_tables_test') {
- $foundTable = true;
-
- self::assertTrue($table->hasColumn('id'));
- self::assertTrue($table->hasColumn('test'));
- self::assertTrue($table->hasColumn('foreign_key_test'));
+ self::assertInstanceOf(Table::class, $table);
+ if (strtolower($table->getName()) !== 'list_tables_test') {
+ continue;
}
+
+ $foundTable = true;
+
+ self::assertTrue($table->hasColumn('id'));
+ self::assertTrue($table->hasColumn('test'));
+ self::assertTrue($table->hasColumn('foreign_key_test'));
}
- self::assertTrue( $foundTable , "The 'list_tables_test' table has to be found.");
+ self::assertTrue($foundTable, "The 'list_tables_test' table has to be found.");
}
public function createListTableColumns()
{
$table = new Table('list_table_columns');
- $table->addColumn('id', 'integer', array('notnull' => true));
- $table->addColumn('test', 'string', array('length' => 255, 'notnull' => false, 'default' => 'expected default'));
- $table->addColumn('foo', 'text', array('notnull' => true));
- $table->addColumn('bar', 'decimal', array('precision' => 10, 'scale' => 4, 'notnull' => false));
+ $table->addColumn('id', 'integer', ['notnull' => true]);
+ $table->addColumn('test', 'string', ['length' => 255, 'notnull' => false, 'default' => 'expected default']);
+ $table->addColumn('foo', 'text', ['notnull' => true]);
+ $table->addColumn('bar', 'decimal', ['precision' => 10, 'scale' => 4, 'notnull' => false]);
$table->addColumn('baz1', 'datetime');
$table->addColumn('baz2', 'time');
$table->addColumn('baz3', 'date');
- $table->setPrimaryKey(array('id'));
+ $table->setPrimaryKey(['id']);
return $table;
}
@@ -249,71 +266,71 @@ public function testListTableColumns()
{
$table = $this->createListTableColumns();
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns('list_table_columns');
+ $columns = $this->schemaManager->listTableColumns('list_table_columns');
$columnsKeys = array_keys($columns);
self::assertArrayHasKey('id', $columns);
self::assertEquals(0, array_search('id', $columnsKeys));
- self::assertEquals('id', strtolower($columns['id']->getname()));
- self::assertInstanceOf('Doctrine\DBAL\Types\IntegerType', $columns['id']->gettype());
- self::assertEquals(false, $columns['id']->getunsigned());
- self::assertEquals(true, $columns['id']->getnotnull());
- self::assertEquals(null, $columns['id']->getdefault());
- self::assertInternalType('array', $columns['id']->getPlatformOptions());
+ self::assertEquals('id', strtolower($columns['id']->getname()));
+ self::assertInstanceOf(IntegerType::class, $columns['id']->gettype());
+ self::assertEquals(false, $columns['id']->getunsigned());
+ self::assertEquals(true, $columns['id']->getnotnull());
+ self::assertEquals(null, $columns['id']->getdefault());
+ self::assertInternalType('array', $columns['id']->getPlatformOptions());
self::assertArrayHasKey('test', $columns);
self::assertEquals(1, array_search('test', $columnsKeys));
self::assertEquals('test', strtolower($columns['test']->getname()));
- self::assertInstanceOf('Doctrine\DBAL\Types\StringType', $columns['test']->gettype());
- self::assertEquals(255, $columns['test']->getlength());
- self::assertEquals(false, $columns['test']->getfixed());
- self::assertEquals(false, $columns['test']->getnotnull());
- self::assertEquals('expected default', $columns['test']->getdefault());
- self::assertInternalType('array', $columns['test']->getPlatformOptions());
-
- self::assertEquals('foo', strtolower($columns['foo']->getname()));
+ self::assertInstanceOf(StringType::class, $columns['test']->gettype());
+ self::assertEquals(255, $columns['test']->getlength());
+ self::assertEquals(false, $columns['test']->getfixed());
+ self::assertEquals(false, $columns['test']->getnotnull());
+ self::assertEquals('expected default', $columns['test']->getdefault());
+ self::assertInternalType('array', $columns['test']->getPlatformOptions());
+
+ self::assertEquals('foo', strtolower($columns['foo']->getname()));
self::assertEquals(2, array_search('foo', $columnsKeys));
- self::assertInstanceOf('Doctrine\DBAL\Types\TextType', $columns['foo']->gettype());
- self::assertEquals(false, $columns['foo']->getunsigned());
- self::assertEquals(false, $columns['foo']->getfixed());
- self::assertEquals(true, $columns['foo']->getnotnull());
- self::assertEquals(null, $columns['foo']->getdefault());
- self::assertInternalType('array', $columns['foo']->getPlatformOptions());
-
- self::assertEquals('bar', strtolower($columns['bar']->getname()));
+ self::assertInstanceOf(TextType::class, $columns['foo']->gettype());
+ self::assertEquals(false, $columns['foo']->getunsigned());
+ self::assertEquals(false, $columns['foo']->getfixed());
+ self::assertEquals(true, $columns['foo']->getnotnull());
+ self::assertEquals(null, $columns['foo']->getdefault());
+ self::assertInternalType('array', $columns['foo']->getPlatformOptions());
+
+ self::assertEquals('bar', strtolower($columns['bar']->getname()));
self::assertEquals(3, array_search('bar', $columnsKeys));
- self::assertInstanceOf('Doctrine\DBAL\Types\DecimalType', $columns['bar']->gettype());
- self::assertEquals(null, $columns['bar']->getlength());
- self::assertEquals(10, $columns['bar']->getprecision());
- self::assertEquals(4, $columns['bar']->getscale());
- self::assertEquals(false, $columns['bar']->getunsigned());
- self::assertEquals(false, $columns['bar']->getfixed());
- self::assertEquals(false, $columns['bar']->getnotnull());
- self::assertEquals(null, $columns['bar']->getdefault());
- self::assertInternalType('array', $columns['bar']->getPlatformOptions());
+ self::assertInstanceOf(DecimalType::class, $columns['bar']->gettype());
+ self::assertEquals(null, $columns['bar']->getlength());
+ self::assertEquals(10, $columns['bar']->getprecision());
+ self::assertEquals(4, $columns['bar']->getscale());
+ self::assertEquals(false, $columns['bar']->getunsigned());
+ self::assertEquals(false, $columns['bar']->getfixed());
+ self::assertEquals(false, $columns['bar']->getnotnull());
+ self::assertEquals(null, $columns['bar']->getdefault());
+ self::assertInternalType('array', $columns['bar']->getPlatformOptions());
self::assertEquals('baz1', strtolower($columns['baz1']->getname()));
self::assertEquals(4, array_search('baz1', $columnsKeys));
- self::assertInstanceOf('Doctrine\DBAL\Types\DateTimeType', $columns['baz1']->gettype());
- self::assertEquals(true, $columns['baz1']->getnotnull());
- self::assertEquals(null, $columns['baz1']->getdefault());
- self::assertInternalType('array', $columns['baz1']->getPlatformOptions());
+ self::assertInstanceOf(DateTimeType::class, $columns['baz1']->gettype());
+ self::assertEquals(true, $columns['baz1']->getnotnull());
+ self::assertEquals(null, $columns['baz1']->getdefault());
+ self::assertInternalType('array', $columns['baz1']->getPlatformOptions());
self::assertEquals('baz2', strtolower($columns['baz2']->getname()));
self::assertEquals(5, array_search('baz2', $columnsKeys));
- self::assertContains($columns['baz2']->gettype()->getName(), array('time', 'date', 'datetime'));
- self::assertEquals(true, $columns['baz2']->getnotnull());
- self::assertEquals(null, $columns['baz2']->getdefault());
- self::assertInternalType('array', $columns['baz2']->getPlatformOptions());
+ self::assertContains($columns['baz2']->gettype()->getName(), ['time', 'date', 'datetime']);
+ self::assertEquals(true, $columns['baz2']->getnotnull());
+ self::assertEquals(null, $columns['baz2']->getdefault());
+ self::assertInternalType('array', $columns['baz2']->getPlatformOptions());
self::assertEquals('baz3', strtolower($columns['baz3']->getname()));
self::assertEquals(6, array_search('baz3', $columnsKeys));
- self::assertContains($columns['baz3']->gettype()->getName(), array('time', 'date', 'datetime'));
- self::assertEquals(true, $columns['baz3']->getnotnull());
- self::assertEquals(null, $columns['baz3']->getdefault());
- self::assertInternalType('array', $columns['baz3']->getPlatformOptions());
+ self::assertContains($columns['baz3']->gettype()->getName(), ['time', 'date', 'datetime']);
+ self::assertEquals(true, $columns['baz3']->getnotnull());
+ self::assertEquals(null, $columns['baz3']->getdefault());
+ self::assertInternalType('array', $columns['baz3']->getPlatformOptions());
}
/**
@@ -324,14 +341,14 @@ public function testListTableColumnsWithFixedStringColumn()
$tableName = 'test_list_table_fixed_string';
$table = new Table($tableName);
- $table->addColumn('column_char', 'string', array('fixed' => true, 'length' => 2));
+ $table->addColumn('column_char', 'string', ['fixed' => true, 'length' => 2]);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $columns = $this->_sm->listTableColumns($tableName);
+ $columns = $this->schemaManager->listTableColumns($tableName);
self::assertArrayHasKey('column_char', $columns);
- self::assertInstanceOf('Doctrine\DBAL\Types\StringType', $columns['column_char']->getType());
+ self::assertInstanceOf(StringType::class, $columns['column_char']->getType());
self::assertTrue($columns['column_char']->getFixed());
self::assertSame(2, $columns['column_char']->getLength());
}
@@ -340,7 +357,7 @@ public function testListTableColumnsDispatchEvent()
{
$table = $this->createListTableColumns();
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
$listenerMock = $this
->getMockBuilder('ListTableColumnsDispatchEventListener')
@@ -350,25 +367,25 @@ public function testListTableColumnsDispatchEvent()
->expects($this->exactly(7))
->method('onSchemaColumnDefinition');
- $oldEventManager = $this->_sm->getDatabasePlatform()->getEventManager();
+ $oldEventManager = $this->schemaManager->getDatabasePlatform()->getEventManager();
$eventManager = new EventManager();
- $eventManager->addEventListener(array(Events::onSchemaColumnDefinition), $listenerMock);
+ $eventManager->addEventListener([Events::onSchemaColumnDefinition], $listenerMock);
- $this->_sm->getDatabasePlatform()->setEventManager($eventManager);
+ $this->schemaManager->getDatabasePlatform()->setEventManager($eventManager);
- $this->_sm->listTableColumns('list_table_columns');
+ $this->schemaManager->listTableColumns('list_table_columns');
- $this->_sm->getDatabasePlatform()->setEventManager($oldEventManager);
+ $this->schemaManager->getDatabasePlatform()->setEventManager($oldEventManager);
}
public function testListTableIndexesDispatchEvent()
{
$table = $this->getTestTable('list_table_indexes_test');
- $table->addUniqueIndex(array('test'), 'test_index_name');
- $table->addIndex(array('id', 'test'), 'test_composite_idx');
+ $table->addUniqueIndex(['test'], 'test_index_name');
+ $table->addIndex(['id', 'test'], 'test_composite_idx');
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
$listenerMock = $this
->getMockBuilder('ListTableIndexesDispatchEventListener')
@@ -378,58 +395,58 @@ public function testListTableIndexesDispatchEvent()
->expects($this->exactly(3))
->method('onSchemaIndexDefinition');
- $oldEventManager = $this->_sm->getDatabasePlatform()->getEventManager();
+ $oldEventManager = $this->schemaManager->getDatabasePlatform()->getEventManager();
$eventManager = new EventManager();
- $eventManager->addEventListener(array(Events::onSchemaIndexDefinition), $listenerMock);
+ $eventManager->addEventListener([Events::onSchemaIndexDefinition], $listenerMock);
- $this->_sm->getDatabasePlatform()->setEventManager($eventManager);
+ $this->schemaManager->getDatabasePlatform()->setEventManager($eventManager);
- $this->_sm->listTableIndexes('list_table_indexes_test');
+ $this->schemaManager->listTableIndexes('list_table_indexes_test');
- $this->_sm->getDatabasePlatform()->setEventManager($oldEventManager);
+ $this->schemaManager->getDatabasePlatform()->setEventManager($oldEventManager);
}
public function testDiffListTableColumns()
{
- if ($this->_sm->getDatabasePlatform()->getName() == 'oracle') {
+ if ($this->schemaManager->getDatabasePlatform()->getName() === 'oracle') {
$this->markTestSkipped('Does not work with Oracle, since it cannot detect DateTime, Date and Time differenecs (at the moment).');
}
$offlineTable = $this->createListTableColumns();
- $this->_sm->dropAndCreateTable($offlineTable);
- $onlineTable = $this->_sm->listTableDetails('list_table_columns');
+ $this->schemaManager->dropAndCreateTable($offlineTable);
+ $onlineTable = $this->schemaManager->listTableDetails('list_table_columns');
- $comparator = new \Doctrine\DBAL\Schema\Comparator();
- $diff = $comparator->diffTable($offlineTable, $onlineTable);
+ $comparator = new Comparator();
+ $diff = $comparator->diffTable($offlineTable, $onlineTable);
- self::assertFalse($diff, "No differences should be detected with the offline vs online schema.");
+ self::assertFalse($diff, 'No differences should be detected with the offline vs online schema.');
}
public function testListTableIndexes()
{
$table = $this->getTestCompositeTable('list_table_indexes_test');
- $table->addUniqueIndex(array('test'), 'test_index_name');
- $table->addIndex(array('id', 'test'), 'test_composite_idx');
+ $table->addUniqueIndex(['test'], 'test_index_name');
+ $table->addIndex(['id', 'test'], 'test_composite_idx');
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $tableIndexes = $this->_sm->listTableIndexes('list_table_indexes_test');
+ $tableIndexes = $this->schemaManager->listTableIndexes('list_table_indexes_test');
self::assertEquals(3, count($tableIndexes));
self::assertArrayHasKey('primary', $tableIndexes, 'listTableIndexes() has to return a "primary" array key.');
- self::assertEquals(array('id', 'other_id'), array_map('strtolower', $tableIndexes['primary']->getColumns()));
+ self::assertEquals(['id', 'other_id'], array_map('strtolower', $tableIndexes['primary']->getColumns()));
self::assertTrue($tableIndexes['primary']->isUnique());
self::assertTrue($tableIndexes['primary']->isPrimary());
self::assertEquals('test_index_name', strtolower($tableIndexes['test_index_name']->getName()));
- self::assertEquals(array('test'), array_map('strtolower', $tableIndexes['test_index_name']->getColumns()));
+ self::assertEquals(['test'], array_map('strtolower', $tableIndexes['test_index_name']->getColumns()));
self::assertTrue($tableIndexes['test_index_name']->isUnique());
self::assertFalse($tableIndexes['test_index_name']->isPrimary());
self::assertEquals('test_composite_idx', strtolower($tableIndexes['test_composite_idx']->getName()));
- self::assertEquals(array('id', 'test'), array_map('strtolower', $tableIndexes['test_composite_idx']->getColumns()));
+ self::assertEquals(['id', 'test'], array_map('strtolower', $tableIndexes['test_composite_idx']->getColumns()));
self::assertFalse($tableIndexes['test_composite_idx']->isUnique());
self::assertFalse($tableIndexes['test_composite_idx']->isPrimary());
}
@@ -437,74 +454,80 @@ public function testListTableIndexes()
public function testDropAndCreateIndex()
{
$table = $this->getTestTable('test_create_index');
- $table->addUniqueIndex(array('test'), 'test');
- $this->_sm->dropAndCreateTable($table);
+ $table->addUniqueIndex(['test'], 'test');
+ $this->schemaManager->dropAndCreateTable($table);
- $this->_sm->dropAndCreateIndex($table->getIndex('test'), $table);
- $tableIndexes = $this->_sm->listTableIndexes('test_create_index');
+ $this->schemaManager->dropAndCreateIndex($table->getIndex('test'), $table);
+ $tableIndexes = $this->schemaManager->listTableIndexes('test_create_index');
self::assertInternalType('array', $tableIndexes);
- self::assertEquals('test', strtolower($tableIndexes['test']->getName()));
- self::assertEquals(array('test'), array_map('strtolower', $tableIndexes['test']->getColumns()));
+ self::assertEquals('test', strtolower($tableIndexes['test']->getName()));
+ self::assertEquals(['test'], array_map('strtolower', $tableIndexes['test']->getColumns()));
self::assertTrue($tableIndexes['test']->isUnique());
self::assertFalse($tableIndexes['test']->isPrimary());
}
public function testCreateTableWithForeignKeys()
{
- if(!$this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
+ if (! $this->schemaManager->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$this->markTestSkipped('Platform does not support foreign keys.');
}
$tableB = $this->getTestTable('test_foreign');
- $this->_sm->dropAndCreateTable($tableB);
+ $this->schemaManager->dropAndCreateTable($tableB);
$tableA = $this->getTestTable('test_create_fk');
- $tableA->addForeignKeyConstraint('test_foreign', array('foreign_key_test'), array('id'));
+ $tableA->addForeignKeyConstraint('test_foreign', ['foreign_key_test'], ['id']);
- $this->_sm->dropAndCreateTable($tableA);
+ $this->schemaManager->dropAndCreateTable($tableA);
- $fkTable = $this->_sm->listTableDetails('test_create_fk');
+ $fkTable = $this->schemaManager->listTableDetails('test_create_fk');
$fkConstraints = $fkTable->getForeignKeys();
self::assertEquals(1, count($fkConstraints), "Table 'test_create_fk1' has to have one foreign key.");
$fkConstraint = current($fkConstraints);
- self::assertInstanceOf('\Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkConstraint);
- self::assertEquals('test_foreign', strtolower($fkConstraint->getForeignTableName()));
- self::assertEquals(array('foreign_key_test'), array_map('strtolower', $fkConstraint->getColumns()));
- self::assertEquals(array('id'), array_map('strtolower', $fkConstraint->getForeignColumns()));
+ self::assertInstanceOf(ForeignKeyConstraint::class, $fkConstraint);
+ self::assertEquals('test_foreign', strtolower($fkConstraint->getForeignTableName()));
+ self::assertEquals(['foreign_key_test'], array_map('strtolower', $fkConstraint->getColumns()));
+ self::assertEquals(['id'], array_map('strtolower', $fkConstraint->getForeignColumns()));
- self::assertTrue($fkTable->columnsAreIndexed($fkConstraint->getColumns()), "The columns of a foreign key constraint should always be indexed.");
+ self::assertTrue($fkTable->columnsAreIndexed($fkConstraint->getColumns()), 'The columns of a foreign key constraint should always be indexed.');
}
public function testListForeignKeys()
{
- if(!$this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) {
+ if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$this->markTestSkipped('Does not support foreign key constraints.');
}
$this->createTestTable('test_create_fk1');
$this->createTestTable('test_create_fk2');
- $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
- array('foreign_key_test'), 'test_create_fk2', array('id'), 'foreign_key_test_fk', array('onDelete' => 'CASCADE')
+ $foreignKey = new ForeignKeyConstraint(
+ ['foreign_key_test'],
+ 'test_create_fk2',
+ ['id'],
+ 'foreign_key_test_fk',
+ ['onDelete' => 'CASCADE']
);
- $this->_sm->createForeignKey($foreignKey, 'test_create_fk1');
+ $this->schemaManager->createForeignKey($foreignKey, 'test_create_fk1');
- $fkeys = $this->_sm->listTableForeignKeys('test_create_fk1');
+ $fkeys = $this->schemaManager->listTableForeignKeys('test_create_fk1');
self::assertEquals(1, count($fkeys), "Table 'test_create_fk1' has to have one foreign key.");
- self::assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]);
- self::assertEquals(array('foreign_key_test'), array_map('strtolower', $fkeys[0]->getLocalColumns()));
- self::assertEquals(array('id'), array_map('strtolower', $fkeys[0]->getForeignColumns()));
- self::assertEquals('test_create_fk2', strtolower($fkeys[0]->getForeignTableName()));
+ self::assertInstanceOf(ForeignKeyConstraint::class, $fkeys[0]);
+ self::assertEquals(['foreign_key_test'], array_map('strtolower', $fkeys[0]->getLocalColumns()));
+ self::assertEquals(['id'], array_map('strtolower', $fkeys[0]->getForeignColumns()));
+ self::assertEquals('test_create_fk2', strtolower($fkeys[0]->getForeignTableName()));
- if($fkeys[0]->hasOption('onDelete')) {
- self::assertEquals('CASCADE', $fkeys[0]->getOption('onDelete'));
+ if (! $fkeys[0]->hasOption('onDelete')) {
+ return;
}
+
+ self::assertEquals('CASCADE', $fkeys[0]->getOption('onDelete'));
}
protected function getCreateExampleViewSql()
@@ -516,101 +539,103 @@ public function testCreateSchema()
{
$this->createTestTable('test_table');
- $schema = $this->_sm->createSchema();
+ $schema = $this->schemaManager->createSchema();
self::assertTrue($schema->hasTable('test_table'));
}
public function testAlterTableScenario()
{
- if(!$this->_sm->getDatabasePlatform()->supportsAlterTable()) {
+ if (! $this->schemaManager->getDatabasePlatform()->supportsAlterTable()) {
$this->markTestSkipped('Alter Table is not supported by this platform.');
}
$alterTable = $this->createTestTable('alter_table');
$this->createTestTable('alter_table_foreign');
- $table = $this->_sm->listTableDetails('alter_table');
+ $table = $this->schemaManager->listTableDetails('alter_table');
self::assertTrue($table->hasColumn('id'));
self::assertTrue($table->hasColumn('test'));
self::assertTrue($table->hasColumn('foreign_key_test'));
self::assertEquals(0, count($table->getForeignKeys()));
self::assertEquals(1, count($table->getIndexes()));
- $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table");
- $tableDiff->fromTable = $alterTable;
- $tableDiff->addedColumns['foo'] = new \Doctrine\DBAL\Schema\Column('foo', Type::getType('integer'));
+ $tableDiff = new TableDiff('alter_table');
+ $tableDiff->fromTable = $alterTable;
+ $tableDiff->addedColumns['foo'] = new Column('foo', Type::getType('integer'));
$tableDiff->removedColumns['test'] = $table->getColumn('test');
- $this->_sm->alterTable($tableDiff);
+ $this->schemaManager->alterTable($tableDiff);
- $table = $this->_sm->listTableDetails('alter_table');
+ $table = $this->schemaManager->listTableDetails('alter_table');
self::assertFalse($table->hasColumn('test'));
self::assertTrue($table->hasColumn('foo'));
- $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table");
- $tableDiff->fromTable = $table;
- $tableDiff->addedIndexes[] = new \Doctrine\DBAL\Schema\Index('foo_idx', array('foo'));
+ $tableDiff = new TableDiff('alter_table');
+ $tableDiff->fromTable = $table;
+ $tableDiff->addedIndexes[] = new Index('foo_idx', ['foo']);
- $this->_sm->alterTable($tableDiff);
+ $this->schemaManager->alterTable($tableDiff);
- $table = $this->_sm->listTableDetails('alter_table');
+ $table = $this->schemaManager->listTableDetails('alter_table');
self::assertEquals(2, count($table->getIndexes()));
self::assertTrue($table->hasIndex('foo_idx'));
- self::assertEquals(array('foo'), array_map('strtolower', $table->getIndex('foo_idx')->getColumns()));
+ self::assertEquals(['foo'], array_map('strtolower', $table->getIndex('foo_idx')->getColumns()));
self::assertFalse($table->getIndex('foo_idx')->isPrimary());
self::assertFalse($table->getIndex('foo_idx')->isUnique());
- $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table");
- $tableDiff->fromTable = $table;
- $tableDiff->changedIndexes[] = new \Doctrine\DBAL\Schema\Index('foo_idx', array('foo', 'foreign_key_test'));
+ $tableDiff = new TableDiff('alter_table');
+ $tableDiff->fromTable = $table;
+ $tableDiff->changedIndexes[] = new Index('foo_idx', ['foo', 'foreign_key_test']);
- $this->_sm->alterTable($tableDiff);
+ $this->schemaManager->alterTable($tableDiff);
- $table = $this->_sm->listTableDetails('alter_table');
+ $table = $this->schemaManager->listTableDetails('alter_table');
self::assertEquals(2, count($table->getIndexes()));
self::assertTrue($table->hasIndex('foo_idx'));
- self::assertEquals(array('foo', 'foreign_key_test'), array_map('strtolower', $table->getIndex('foo_idx')->getColumns()));
+ self::assertEquals(['foo', 'foreign_key_test'], array_map('strtolower', $table->getIndex('foo_idx')->getColumns()));
- $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table");
- $tableDiff->fromTable = $table;
- $tableDiff->renamedIndexes['foo_idx'] = new \Doctrine\DBAL\Schema\Index('bar_idx', array('foo', 'foreign_key_test'));
+ $tableDiff = new TableDiff('alter_table');
+ $tableDiff->fromTable = $table;
+ $tableDiff->renamedIndexes['foo_idx'] = new Index('bar_idx', ['foo', 'foreign_key_test']);
- $this->_sm->alterTable($tableDiff);
+ $this->schemaManager->alterTable($tableDiff);
- $table = $this->_sm->listTableDetails('alter_table');
+ $table = $this->schemaManager->listTableDetails('alter_table');
self::assertEquals(2, count($table->getIndexes()));
self::assertTrue($table->hasIndex('bar_idx'));
self::assertFalse($table->hasIndex('foo_idx'));
- self::assertEquals(array('foo', 'foreign_key_test'), array_map('strtolower', $table->getIndex('bar_idx')->getColumns()));
+ self::assertEquals(['foo', 'foreign_key_test'], array_map('strtolower', $table->getIndex('bar_idx')->getColumns()));
self::assertFalse($table->getIndex('bar_idx')->isPrimary());
self::assertFalse($table->getIndex('bar_idx')->isUnique());
- $tableDiff = new \Doctrine\DBAL\Schema\TableDiff("alter_table");
- $tableDiff->fromTable = $table;
- $tableDiff->removedIndexes[] = new \Doctrine\DBAL\Schema\Index('bar_idx', array('foo', 'foreign_key_test'));
- $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('foreign_key_test'), 'alter_table_foreign', array('id'));
+ $tableDiff = new TableDiff('alter_table');
+ $tableDiff->fromTable = $table;
+ $tableDiff->removedIndexes[] = new Index('bar_idx', ['foo', 'foreign_key_test']);
+ $fk = new ForeignKeyConstraint(['foreign_key_test'], 'alter_table_foreign', ['id']);
$tableDiff->addedForeignKeys[] = $fk;
- $this->_sm->alterTable($tableDiff);
- $table = $this->_sm->listTableDetails('alter_table');
+ $this->schemaManager->alterTable($tableDiff);
+ $table = $this->schemaManager->listTableDetails('alter_table');
// dont check for index size here, some platforms automatically add indexes for foreign keys.
self::assertFalse($table->hasIndex('bar_idx'));
- if ($this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
- $fks = $table->getForeignKeys();
- self::assertCount(1, $fks);
- $foreignKey = current($fks);
- self::assertEquals('alter_table_foreign', strtolower($foreignKey->getForeignTableName()));
- self::assertEquals(array('foreign_key_test'), array_map('strtolower', $foreignKey->getColumns()));
- self::assertEquals(array('id'), array_map('strtolower', $foreignKey->getForeignColumns()));
+ if (! $this->schemaManager->getDatabasePlatform()->supportsForeignKeyConstraints()) {
+ return;
}
+
+ $fks = $table->getForeignKeys();
+ self::assertCount(1, $fks);
+ $foreignKey = current($fks);
+ self::assertEquals('alter_table_foreign', strtolower($foreignKey->getForeignTableName()));
+ self::assertEquals(['foreign_key_test'], array_map('strtolower', $foreignKey->getColumns()));
+ self::assertEquals(['id'], array_map('strtolower', $foreignKey->getForeignColumns()));
}
public function testTableInNamespace()
{
- if (! $this->_sm->getDatabasePlatform()->supportsSchemas()) {
+ if (! $this->schemaManager->getDatabasePlatform()->supportsSchemas()) {
$this->markTestSkipped('Schema definition is not supported by this platform.');
}
@@ -618,52 +643,52 @@ public function testTableInNamespace()
$diff = new SchemaDiff();
$diff->newNamespaces[] = 'testschema';
- foreach ($diff->toSql($this->_sm->getDatabasePlatform()) as $sql) {
- $this->_conn->exec($sql);
+ foreach ($diff->toSql($this->schemaManager->getDatabasePlatform()) as $sql) {
+ $this->connection->exec($sql);
}
//test if table is create in namespace
$this->createTestTable('testschema.my_table_in_namespace');
- self::assertContains('testschema.my_table_in_namespace', $this->_sm->listTableNames());
+ self::assertContains('testschema.my_table_in_namespace', $this->schemaManager->listTableNames());
//tables without namespace should be created in default namespace
//default namespaces are ignored in table listings
$this->createTestTable('my_table_not_in_namespace');
- self::assertContains('my_table_not_in_namespace', $this->_sm->listTableNames());
+ self::assertContains('my_table_not_in_namespace', $this->schemaManager->listTableNames());
}
public function testCreateAndListViews()
{
- if (!$this->_sm->getDatabasePlatform()->supportsViews()) {
+ if (! $this->schemaManager->getDatabasePlatform()->supportsViews()) {
$this->markTestSkipped('Views is not supported by this platform.');
}
$this->createTestTable('view_test_table');
- $name = "doctrine_test_view";
- $sql = "SELECT * FROM view_test_table";
+ $name = 'doctrine_test_view';
+ $sql = 'SELECT * FROM view_test_table';
- $view = new \Doctrine\DBAL\Schema\View($name, $sql);
+ $view = new View($name, $sql);
- $this->_sm->dropAndCreateView($view);
+ $this->schemaManager->dropAndCreateView($view);
- self::assertTrue($this->hasElementWithName($this->_sm->listViews(), $name));
+ self::assertTrue($this->hasElementWithName($this->schemaManager->listViews(), $name));
}
public function testAutoincrementDetection()
{
- if (!$this->_sm->getDatabasePlatform()->supportsIdentityColumns()) {
+ if (! $this->schemaManager->getDatabasePlatform()->supportsIdentityColumns()) {
$this->markTestSkipped('This test is only supported on platforms that have autoincrement');
}
$table = new Table('test_autoincrement');
- $table->setSchemaConfig($this->_sm->createSchemaConfig());
- $table->addColumn('id', 'integer', array('autoincrement' => true));
- $table->setPrimaryKey(array('id'));
+ $table->setSchemaConfig($this->schemaManager->createSchemaConfig());
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
+ $table->setPrimaryKey(['id']);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $inferredTable = $this->_sm->listTableDetails('test_autoincrement');
+ $inferredTable = $this->schemaManager->listTableDetails('test_autoincrement');
self::assertTrue($inferredTable->hasColumn('id'));
self::assertTrue($inferredTable->getColumn('id')->getAutoincrement());
}
@@ -673,19 +698,19 @@ public function testAutoincrementDetection()
*/
public function testAutoincrementDetectionMulticolumns()
{
- if (!$this->_sm->getDatabasePlatform()->supportsIdentityColumns()) {
+ if (! $this->schemaManager->getDatabasePlatform()->supportsIdentityColumns()) {
$this->markTestSkipped('This test is only supported on platforms that have autoincrement');
}
$table = new Table('test_not_autoincrement');
- $table->setSchemaConfig($this->_sm->createSchemaConfig());
+ $table->setSchemaConfig($this->schemaManager->createSchemaConfig());
$table->addColumn('id', 'integer');
$table->addColumn('other_id', 'integer');
- $table->setPrimaryKey(array('id', 'other_id'));
+ $table->setPrimaryKey(['id', 'other_id']);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $inferredTable = $this->_sm->listTableDetails('test_not_autoincrement');
+ $inferredTable = $this->schemaManager->listTableDetails('test_not_autoincrement');
self::assertTrue($inferredTable->hasColumn('id'));
self::assertFalse($inferredTable->getColumn('id')->getAutoincrement());
}
@@ -695,39 +720,39 @@ public function testAutoincrementDetectionMulticolumns()
*/
public function testUpdateSchemaWithForeignKeyRenaming()
{
- if (!$this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
+ if (! $this->schemaManager->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$this->markTestSkipped('This test is only supported on platforms that have foreign keys.');
}
$table = new Table('test_fk_base');
$table->addColumn('id', 'integer');
- $table->setPrimaryKey(array('id'));
+ $table->setPrimaryKey(['id']);
$tableFK = new Table('test_fk_rename');
- $tableFK->setSchemaConfig($this->_sm->createSchemaConfig());
+ $tableFK->setSchemaConfig($this->schemaManager->createSchemaConfig());
$tableFK->addColumn('id', 'integer');
$tableFK->addColumn('fk_id', 'integer');
- $tableFK->setPrimaryKey(array('id'));
- $tableFK->addIndex(array('fk_id'), 'fk_idx');
- $tableFK->addForeignKeyConstraint('test_fk_base', array('fk_id'), array('id'));
+ $tableFK->setPrimaryKey(['id']);
+ $tableFK->addIndex(['fk_id'], 'fk_idx');
+ $tableFK->addForeignKeyConstraint('test_fk_base', ['fk_id'], ['id']);
- $this->_sm->createTable($table);
- $this->_sm->createTable($tableFK);
+ $this->schemaManager->createTable($table);
+ $this->schemaManager->createTable($tableFK);
$tableFKNew = new Table('test_fk_rename');
- $tableFKNew->setSchemaConfig($this->_sm->createSchemaConfig());
+ $tableFKNew->setSchemaConfig($this->schemaManager->createSchemaConfig());
$tableFKNew->addColumn('id', 'integer');
$tableFKNew->addColumn('rename_fk_id', 'integer');
- $tableFKNew->setPrimaryKey(array('id'));
- $tableFKNew->addIndex(array('rename_fk_id'), 'fk_idx');
- $tableFKNew->addForeignKeyConstraint('test_fk_base', array('rename_fk_id'), array('id'));
+ $tableFKNew->setPrimaryKey(['id']);
+ $tableFKNew->addIndex(['rename_fk_id'], 'fk_idx');
+ $tableFKNew->addForeignKeyConstraint('test_fk_base', ['rename_fk_id'], ['id']);
- $c = new \Doctrine\DBAL\Schema\Comparator();
+ $c = new Comparator();
$tableDiff = $c->diffTable($tableFK, $tableFKNew);
- $this->_sm->alterTable($tableDiff);
+ $this->schemaManager->alterTable($tableDiff);
- $table = $this->_sm->listTableDetails('test_fk_rename');
+ $table = $this->schemaManager->listTableDetails('test_fk_rename');
$foreignKeys = $table->getForeignKeys();
self::assertTrue($table->hasColumn('rename_fk_id'));
@@ -740,36 +765,36 @@ public function testUpdateSchemaWithForeignKeyRenaming()
*/
public function testRenameIndexUsedInForeignKeyConstraint()
{
- if (! $this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
+ if (! $this->schemaManager->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$this->markTestSkipped('This test is only supported on platforms that have foreign keys.');
}
$primaryTable = new Table('test_rename_index_primary');
$primaryTable->addColumn('id', 'integer');
- $primaryTable->setPrimaryKey(array('id'));
+ $primaryTable->setPrimaryKey(['id']);
$foreignTable = new Table('test_rename_index_foreign');
$foreignTable->addColumn('fk', 'integer');
- $foreignTable->addIndex(array('fk'), 'rename_index_fk_idx');
+ $foreignTable->addIndex(['fk'], 'rename_index_fk_idx');
$foreignTable->addForeignKeyConstraint(
'test_rename_index_primary',
- array('fk'),
- array('id'),
- array(),
+ ['fk'],
+ ['id'],
+ [],
'fk_constraint'
);
- $this->_sm->dropAndCreateTable($primaryTable);
- $this->_sm->dropAndCreateTable($foreignTable);
+ $this->schemaManager->dropAndCreateTable($primaryTable);
+ $this->schemaManager->dropAndCreateTable($foreignTable);
$foreignTable2 = clone $foreignTable;
$foreignTable2->renameIndex('rename_index_fk_idx', 'renamed_index_fk_idx');
$comparator = new Comparator();
- $this->_sm->alterTable($comparator->diffTable($foreignTable, $foreignTable2));
+ $this->schemaManager->alterTable($comparator->diffTable($foreignTable, $foreignTable2));
- $foreignTable = $this->_sm->listTableDetails('test_rename_index_foreign');
+ $foreignTable = $this->schemaManager->listTableDetails('test_rename_index_foreign');
self::assertFalse($foreignTable->hasIndex('rename_index_fk_idx'));
self::assertTrue($foreignTable->hasIndex('renamed_index_fk_idx'));
@@ -781,37 +806,41 @@ public function testRenameIndexUsedInForeignKeyConstraint()
*/
public function testGetColumnComment()
{
- if ( ! $this->_conn->getDatabasePlatform()->supportsInlineColumnComments() &&
- ! $this->_conn->getDatabasePlatform()->supportsCommentOnStatement() &&
- $this->_conn->getDatabasePlatform()->getName() != 'mssql') {
+ if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() &&
+ ! $this->connection->getDatabasePlatform()->supportsCommentOnStatement() &&
+ $this->connection->getDatabasePlatform()->getName() !== 'mssql') {
$this->markTestSkipped('Database does not support column comments.');
}
$table = new Table('column_comment_test');
- $table->addColumn('id', 'integer', array('comment' => 'This is a comment'));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('id', 'integer', ['comment' => 'This is a comment']);
+ $table->setPrimaryKey(['id']);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $columns = $this->_sm->listTableColumns("column_comment_test");
+ $columns = $this->schemaManager->listTableColumns('column_comment_test');
self::assertEquals(1, count($columns));
self::assertEquals('This is a comment', $columns['id']->getComment());
- $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('column_comment_test');
- $tableDiff->fromTable = $table;
- $tableDiff->changedColumns['id'] = new \Doctrine\DBAL\Schema\ColumnDiff(
- 'id', new \Doctrine\DBAL\Schema\Column(
- 'id', \Doctrine\DBAL\Types\Type::getType('integer')
+ $tableDiff = new TableDiff('column_comment_test');
+ $tableDiff->fromTable = $table;
+ $tableDiff->changedColumns['id'] = new ColumnDiff(
+ 'id',
+ new Column(
+ 'id',
+ Type::getType('integer')
),
- array('comment'),
- new \Doctrine\DBAL\Schema\Column(
- 'id', \Doctrine\DBAL\Types\Type::getType('integer'), array('comment' => 'This is a comment')
+ ['comment'],
+ new Column(
+ 'id',
+ Type::getType('integer'),
+ ['comment' => 'This is a comment']
)
);
- $this->_sm->alterTable($tableDiff);
+ $this->schemaManager->alterTable($tableDiff);
- $columns = $this->_sm->listTableColumns("column_comment_test");
+ $columns = $this->schemaManager->listTableColumns('column_comment_test');
self::assertEquals(1, count($columns));
self::assertEmpty($columns['id']->getComment());
}
@@ -821,27 +850,27 @@ public function testGetColumnComment()
*/
public function testAutomaticallyAppendCommentOnMarkedColumns()
{
- if ( ! $this->_conn->getDatabasePlatform()->supportsInlineColumnComments() &&
- ! $this->_conn->getDatabasePlatform()->supportsCommentOnStatement() &&
- $this->_conn->getDatabasePlatform()->getName() != 'mssql') {
+ if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() &&
+ ! $this->connection->getDatabasePlatform()->supportsCommentOnStatement() &&
+ $this->connection->getDatabasePlatform()->getName() !== 'mssql') {
$this->markTestSkipped('Database does not support column comments.');
}
$table = new Table('column_comment_test2');
- $table->addColumn('id', 'integer', array('comment' => 'This is a comment'));
- $table->addColumn('obj', 'object', array('comment' => 'This is a comment'));
- $table->addColumn('arr', 'array', array('comment' => 'This is a comment'));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('id', 'integer', ['comment' => 'This is a comment']);
+ $table->addColumn('obj', 'object', ['comment' => 'This is a comment']);
+ $table->addColumn('arr', 'array', ['comment' => 'This is a comment']);
+ $table->setPrimaryKey(['id']);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $columns = $this->_sm->listTableColumns("column_comment_test2");
+ $columns = $this->schemaManager->listTableColumns('column_comment_test2');
self::assertEquals(3, count($columns));
self::assertEquals('This is a comment', $columns['id']->getComment());
- self::assertEquals('This is a comment', $columns['obj']->getComment(), "The Doctrine2 Typehint should be stripped from comment.");
- self::assertInstanceOf('Doctrine\DBAL\Types\ObjectType', $columns['obj']->getType(), "The Doctrine2 should be detected from comment hint.");
- self::assertEquals('This is a comment', $columns['arr']->getComment(), "The Doctrine2 Typehint should be stripped from comment.");
- self::assertInstanceOf('Doctrine\DBAL\Types\ArrayType', $columns['arr']->getType(), "The Doctrine2 should be detected from comment hint.");
+ self::assertEquals('This is a comment', $columns['obj']->getComment(), 'The Doctrine2 Typehint should be stripped from comment.');
+ self::assertInstanceOf(ObjectType::class, $columns['obj']->getType(), 'The Doctrine2 should be detected from comment hint.');
+ self::assertEquals('This is a comment', $columns['arr']->getComment(), 'The Doctrine2 Typehint should be stripped from comment.');
+ self::assertInstanceOf(ArrayType::class, $columns['arr']->getType(), 'The Doctrine2 should be detected from comment hint.');
}
/**
@@ -849,24 +878,24 @@ public function testAutomaticallyAppendCommentOnMarkedColumns()
*/
public function testCommentHintOnDateIntervalTypeColumn()
{
- if ( ! $this->_conn->getDatabasePlatform()->supportsInlineColumnComments() &&
- ! $this->_conn->getDatabasePlatform()->supportsCommentOnStatement() &&
- $this->_conn->getDatabasePlatform()->getName() != 'mssql') {
+ if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() &&
+ ! $this->connection->getDatabasePlatform()->supportsCommentOnStatement() &&
+ $this->connection->getDatabasePlatform()->getName() !== 'mssql') {
$this->markTestSkipped('Database does not support column comments.');
}
$table = new Table('column_dateinterval_comment');
- $table->addColumn('id', 'integer', array('comment' => 'This is a comment'));
- $table->addColumn('date_interval', 'dateinterval', array('comment' => 'This is a comment'));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('id', 'integer', ['comment' => 'This is a comment']);
+ $table->addColumn('date_interval', 'dateinterval', ['comment' => 'This is a comment']);
+ $table->setPrimaryKey(['id']);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $columns = $this->_sm->listTableColumns("column_dateinterval_comment");
+ $columns = $this->schemaManager->listTableColumns('column_dateinterval_comment');
self::assertEquals(2, count($columns));
self::assertEquals('This is a comment', $columns['id']->getComment());
- self::assertEquals('This is a comment', $columns['date_interval']->getComment(), "The Doctrine2 Typehint should be stripped from comment.");
- self::assertInstanceOf('Doctrine\DBAL\Types\DateIntervalType', $columns['date_interval']->getType(), "The Doctrine2 should be detected from comment hint.");
+ self::assertEquals('This is a comment', $columns['date_interval']->getComment(), 'The Doctrine2 Typehint should be stripped from comment.');
+ self::assertInstanceOf(DateIntervalType::class, $columns['date_interval']->getType(), 'The Doctrine2 should be detected from comment hint.');
}
/**
@@ -877,35 +906,35 @@ public function testChangeColumnsTypeWithDefaultValue()
$tableName = 'column_def_change_type';
$table = new Table($tableName);
- $table->addColumn('col_int', 'smallint', array('default' => 666));
- $table->addColumn('col_string', 'string', array('default' => 'foo'));
+ $table->addColumn('col_int', 'smallint', ['default' => 666]);
+ $table->addColumn('col_string', 'string', ['default' => 'foo']);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $tableDiff = new TableDiff($tableName);
- $tableDiff->fromTable = $table;
+ $tableDiff = new TableDiff($tableName);
+ $tableDiff->fromTable = $table;
$tableDiff->changedColumns['col_int'] = new ColumnDiff(
'col_int',
- new Column('col_int', Type::getType('integer'), array('default' => 666)),
- array('type'),
- new Column('col_int', Type::getType('smallint'), array('default' => 666))
+ new Column('col_int', Type::getType('integer'), ['default' => 666]),
+ ['type'],
+ new Column('col_int', Type::getType('smallint'), ['default' => 666])
);
$tableDiff->changedColumns['col_string'] = new ColumnDiff(
'col_string',
- new Column('col_string', Type::getType('string'), array('default' => 'foo', 'fixed' => true)),
- array('fixed'),
- new Column('col_string', Type::getType('string'), array('default' => 'foo'))
+ new Column('col_string', Type::getType('string'), ['default' => 'foo', 'fixed' => true]),
+ ['fixed'],
+ new Column('col_string', Type::getType('string'), ['default' => 'foo'])
);
- $this->_sm->alterTable($tableDiff);
+ $this->schemaManager->alterTable($tableDiff);
- $columns = $this->_sm->listTableColumns($tableName);
+ $columns = $this->schemaManager->listTableColumns($tableName);
- self::assertInstanceOf('Doctrine\DBAL\Types\IntegerType', $columns['col_int']->getType());
+ self::assertInstanceOf(IntegerType::class, $columns['col_int']->getType());
self::assertEquals(666, $columns['col_int']->getDefault());
- self::assertInstanceOf('Doctrine\DBAL\Types\StringType', $columns['col_string']->getType());
+ self::assertInstanceOf(StringType::class, $columns['col_string']->getType());
self::assertEquals('foo', $columns['col_string']->getDefault());
}
@@ -919,9 +948,9 @@ public function testListTableWithBlob()
$table->addColumn('binarydata', 'blob', []);
$table->setPrimaryKey(['id']);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $created = $this->_sm->listTableDetails('test_blob_table');
+ $created = $this->schemaManager->listTableDetails('test_blob_table');
self::assertTrue($created->hasColumn('id'));
self::assertTrue($created->hasColumn('binarydata'));
@@ -929,40 +958,41 @@ public function testListTableWithBlob()
}
/**
- * @param string $name
- * @param array $data
+ * @param string $name
+ * @param mixed[] $data
+ *
* @return Table
*/
- protected function createTestTable($name = 'test_table', $data = array())
+ protected function createTestTable($name = 'test_table', array $data = [])
{
$options = $data['options'] ?? [];
$table = $this->getTestTable($name, $options);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
return $table;
}
- protected function getTestTable($name, $options=array())
+ protected function getTestTable($name, $options = [])
{
- $table = new Table($name, array(), array(), array(), false, $options);
- $table->setSchemaConfig($this->_sm->createSchemaConfig());
- $table->addColumn('id', 'integer', array('notnull' => true));
- $table->setPrimaryKey(array('id'));
- $table->addColumn('test', 'string', array('length' => 255));
+ $table = new Table($name, [], [], [], false, $options);
+ $table->setSchemaConfig($this->schemaManager->createSchemaConfig());
+ $table->addColumn('id', 'integer', ['notnull' => true]);
+ $table->setPrimaryKey(['id']);
+ $table->addColumn('test', 'string', ['length' => 255]);
$table->addColumn('foreign_key_test', 'integer');
return $table;
}
protected function getTestCompositeTable($name)
{
- $table = new Table($name, array(), array(), array(), false, array());
- $table->setSchemaConfig($this->_sm->createSchemaConfig());
- $table->addColumn('id', 'integer', array('notnull' => true));
- $table->addColumn('other_id', 'integer', array('notnull' => true));
- $table->setPrimaryKey(array('id', 'other_id'));
- $table->addColumn('test', 'string', array('length' => 255));
+ $table = new Table($name, [], [], [], false, []);
+ $table->setSchemaConfig($this->schemaManager->createSchemaConfig());
+ $table->addColumn('id', 'integer', ['notnull' => true]);
+ $table->addColumn('other_id', 'integer', ['notnull' => true]);
+ $table->setPrimaryKey(['id', 'other_id']);
+ $table->addColumn('test', 'string', ['length' => 255]);
return $table;
}
@@ -970,36 +1000,41 @@ protected function assertHasTable($tables, $tableName)
{
$foundTable = false;
foreach ($tables as $table) {
- self::assertInstanceOf('Doctrine\DBAL\Schema\Table', $table, 'No Table instance was found in tables array.');
- if (strtolower($table->getName()) == 'list_tables_test_new_name') {
- $foundTable = true;
+ self::assertInstanceOf(Table::class, $table, 'No Table instance was found in tables array.');
+ if (strtolower($table->getName()) !== 'list_tables_test_new_name') {
+ continue;
}
+
+ $foundTable = true;
}
- self::assertTrue($foundTable, "Could not find new table");
+ self::assertTrue($foundTable, 'Could not find new table');
}
public function testListForeignKeysComposite()
{
- if(!$this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) {
+ if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$this->markTestSkipped('Does not support foreign key constraints.');
}
- $this->_sm->createTable($this->getTestTable('test_create_fk3'));
- $this->_sm->createTable($this->getTestCompositeTable('test_create_fk4'));
+ $this->schemaManager->createTable($this->getTestTable('test_create_fk3'));
+ $this->schemaManager->createTable($this->getTestCompositeTable('test_create_fk4'));
- $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
- array('id', 'foreign_key_test'), 'test_create_fk4', array('id', 'other_id'), 'foreign_key_test_fk2'
+ $foreignKey = new ForeignKeyConstraint(
+ ['id', 'foreign_key_test'],
+ 'test_create_fk4',
+ ['id', 'other_id'],
+ 'foreign_key_test_fk2'
);
- $this->_sm->createForeignKey($foreignKey, 'test_create_fk3');
+ $this->schemaManager->createForeignKey($foreignKey, 'test_create_fk3');
- $fkeys = $this->_sm->listTableForeignKeys('test_create_fk3');
+ $fkeys = $this->schemaManager->listTableForeignKeys('test_create_fk3');
self::assertEquals(1, count($fkeys), "Table 'test_create_fk3' has to have one foreign key.");
- self::assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]);
- self::assertEquals(array('id', 'foreign_key_test'), array_map('strtolower', $fkeys[0]->getLocalColumns()));
- self::assertEquals(array('id', 'other_id'), array_map('strtolower', $fkeys[0]->getForeignColumns()));
+ self::assertInstanceOf(ForeignKeyConstraint::class, $fkeys[0]);
+ self::assertEquals(['id', 'foreign_key_test'], array_map('strtolower', $fkeys[0]->getLocalColumns()));
+ self::assertEquals(['id', 'other_id'], array_map('strtolower', $fkeys[0]->getForeignColumns()));
}
/**
@@ -1007,20 +1042,20 @@ public function testListForeignKeysComposite()
*/
public function testColumnDefaultLifecycle()
{
- $table = new Table("col_def_lifecycle");
- $table->addColumn('id', 'integer', array('autoincrement' => true));
- $table->addColumn('column1', 'string', array('default' => null));
- $table->addColumn('column2', 'string', array('default' => false));
- $table->addColumn('column3', 'string', array('default' => true));
- $table->addColumn('column4', 'string', array('default' => 0));
- $table->addColumn('column5', 'string', array('default' => ''));
- $table->addColumn('column6', 'string', array('default' => 'def'));
- $table->addColumn('column7', 'integer', array('default' => 0));
- $table->setPrimaryKey(array('id'));
+ $table = new Table('col_def_lifecycle');
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
+ $table->addColumn('column1', 'string', ['default' => null]);
+ $table->addColumn('column2', 'string', ['default' => false]);
+ $table->addColumn('column3', 'string', ['default' => true]);
+ $table->addColumn('column4', 'string', ['default' => 0]);
+ $table->addColumn('column5', 'string', ['default' => '']);
+ $table->addColumn('column6', 'string', ['default' => 'def']);
+ $table->addColumn('column7', 'integer', ['default' => 0]);
+ $table->setPrimaryKey(['id']);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns('col_def_lifecycle');
+ $columns = $this->schemaManager->listTableColumns('col_def_lifecycle');
self::assertNull($columns['id']->getDefault());
self::assertNull($columns['column1']->getDefault());
@@ -1033,19 +1068,19 @@ public function testColumnDefaultLifecycle()
$diffTable = clone $table;
- $diffTable->changeColumn('column1', array('default' => false));
- $diffTable->changeColumn('column2', array('default' => null));
- $diffTable->changeColumn('column3', array('default' => false));
- $diffTable->changeColumn('column4', array('default' => null));
- $diffTable->changeColumn('column5', array('default' => false));
- $diffTable->changeColumn('column6', array('default' => 666));
- $diffTable->changeColumn('column7', array('default' => null));
+ $diffTable->changeColumn('column1', ['default' => false]);
+ $diffTable->changeColumn('column2', ['default' => null]);
+ $diffTable->changeColumn('column3', ['default' => false]);
+ $diffTable->changeColumn('column4', ['default' => null]);
+ $diffTable->changeColumn('column5', ['default' => false]);
+ $diffTable->changeColumn('column6', ['default' => 666]);
+ $diffTable->changeColumn('column7', ['default' => null]);
$comparator = new Comparator();
- $this->_sm->alterTable($comparator->diffTable($table, $diffTable));
+ $this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
- $columns = $this->_sm->listTableColumns('col_def_lifecycle');
+ $columns = $this->schemaManager->listTableColumns('col_def_lifecycle');
self::assertSame('', $columns['column1']->getDefault());
self::assertNull($columns['column2']->getDefault());
@@ -1062,96 +1097,96 @@ public function testListTableWithBinary()
$table = new Table($tableName);
$table->addColumn('id', 'integer');
- $table->addColumn('column_varbinary', 'binary', array());
- $table->addColumn('column_binary', 'binary', array('fixed' => true));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('column_varbinary', 'binary', []);
+ $table->addColumn('column_binary', 'binary', ['fixed' => true]);
+ $table->setPrimaryKey(['id']);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $table = $this->_sm->listTableDetails($tableName);
+ $table = $this->schemaManager->listTableDetails($tableName);
- self::assertInstanceOf('Doctrine\DBAL\Types\BinaryType', $table->getColumn('column_varbinary')->getType());
+ self::assertInstanceOf(BinaryType::class, $table->getColumn('column_varbinary')->getType());
self::assertFalse($table->getColumn('column_varbinary')->getFixed());
- self::assertInstanceOf('Doctrine\DBAL\Types\BinaryType', $table->getColumn('column_binary')->getType());
+ self::assertInstanceOf(BinaryType::class, $table->getColumn('column_binary')->getType());
self::assertTrue($table->getColumn('column_binary')->getFixed());
}
public function testListTableDetailsWithFullQualifiedTableName()
{
- if ( ! $this->_sm->getDatabasePlatform()->supportsSchemas()) {
+ if (! $this->schemaManager->getDatabasePlatform()->supportsSchemas()) {
$this->markTestSkipped('Test only works on platforms that support schemas.');
}
- $defaultSchemaName = $this->_sm->getDatabasePlatform()->getDefaultSchemaName();
+ $defaultSchemaName = $this->schemaManager->getDatabasePlatform()->getDefaultSchemaName();
$primaryTableName = 'primary_table';
$foreignTableName = 'foreign_table';
$table = new Table($foreignTableName);
- $table->addColumn('id', 'integer', array('autoincrement' => true));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
+ $table->setPrimaryKey(['id']);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
$table = new Table($primaryTableName);
- $table->addColumn('id', 'integer', array('autoincrement' => true));
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('foo', 'integer');
$table->addColumn('bar', 'string');
- $table->addForeignKeyConstraint($foreignTableName, array('foo'), array('id'));
- $table->addIndex(array('bar'));
- $table->setPrimaryKey(array('id'));
+ $table->addForeignKeyConstraint($foreignTableName, ['foo'], ['id']);
+ $table->addIndex(['bar']);
+ $table->setPrimaryKey(['id']);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
self::assertEquals(
- $this->_sm->listTableColumns($primaryTableName),
- $this->_sm->listTableColumns($defaultSchemaName . '.' . $primaryTableName)
+ $this->schemaManager->listTableColumns($primaryTableName),
+ $this->schemaManager->listTableColumns($defaultSchemaName . '.' . $primaryTableName)
);
self::assertEquals(
- $this->_sm->listTableIndexes($primaryTableName),
- $this->_sm->listTableIndexes($defaultSchemaName . '.' . $primaryTableName)
+ $this->schemaManager->listTableIndexes($primaryTableName),
+ $this->schemaManager->listTableIndexes($defaultSchemaName . '.' . $primaryTableName)
);
self::assertEquals(
- $this->_sm->listTableForeignKeys($primaryTableName),
- $this->_sm->listTableForeignKeys($defaultSchemaName . '.' . $primaryTableName)
+ $this->schemaManager->listTableForeignKeys($primaryTableName),
+ $this->schemaManager->listTableForeignKeys($defaultSchemaName . '.' . $primaryTableName)
);
}
public function testCommentStringsAreQuoted()
{
- if ( ! $this->_conn->getDatabasePlatform()->supportsInlineColumnComments() &&
- ! $this->_conn->getDatabasePlatform()->supportsCommentOnStatement() &&
- $this->_conn->getDatabasePlatform()->getName() != 'mssql') {
+ if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() &&
+ ! $this->connection->getDatabasePlatform()->supportsCommentOnStatement() &&
+ $this->connection->getDatabasePlatform()->getName() !== 'mssql') {
$this->markTestSkipped('Database does not support column comments.');
}
$table = new Table('my_table');
- $table->addColumn('id', 'integer', array('comment' => "It's a comment with a quote"));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('id', 'integer', ['comment' => "It's a comment with a quote"]);
+ $table->setPrimaryKey(['id']);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $columns = $this->_sm->listTableColumns("my_table");
+ $columns = $this->schemaManager->listTableColumns('my_table');
self::assertEquals("It's a comment with a quote", $columns['id']->getComment());
}
public function testCommentNotDuplicated()
{
- if ( ! $this->_conn->getDatabasePlatform()->supportsInlineColumnComments()) {
+ if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments()) {
$this->markTestSkipped('Database does not support column comments.');
}
- $options = array(
+ $options = [
'type' => Type::getType('integer'),
'default' => 0,
'notnull' => true,
'comment' => 'expected+column+comment',
- );
- $columnDefinition = substr($this->_conn->getDatabasePlatform()->getColumnDeclarationSQL('id', $options), strlen('id') + 1);
+ ];
+ $columnDefinition = substr($this->connection->getDatabasePlatform()->getColumnDeclarationSQL('id', $options), strlen('id') + 1);
$table = new Table('my_table');
- $table->addColumn('id', 'integer', array('columnDefinition' => $columnDefinition, 'comment' => 'unexpected_column_comment'));
- $sql = $this->_conn->getDatabasePlatform()->getCreateTableSQL($table);
+ $table->addColumn('id', 'integer', ['columnDefinition' => $columnDefinition, 'comment' => 'unexpected_column_comment']);
+ $sql = $this->connection->getDatabasePlatform()->getCreateTableSQL($table);
self::assertContains('expected+column+comment', $sql[0]);
self::assertNotContains('unexpected_column_comment', $sql[0]);
@@ -1159,45 +1194,44 @@ public function testCommentNotDuplicated()
/**
* @group DBAL-1009
- *
* @dataProvider getAlterColumnComment
*/
public function testAlterColumnComment($comment1, $expectedComment1, $comment2, $expectedComment2)
{
- if ( ! $this->_conn->getDatabasePlatform()->supportsInlineColumnComments() &&
- ! $this->_conn->getDatabasePlatform()->supportsCommentOnStatement() &&
- $this->_conn->getDatabasePlatform()->getName() != 'mssql') {
+ if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() &&
+ ! $this->connection->getDatabasePlatform()->supportsCommentOnStatement() &&
+ $this->connection->getDatabasePlatform()->getName() !== 'mssql') {
$this->markTestSkipped('Database does not support column comments.');
}
$offlineTable = new Table('alter_column_comment_test');
- $offlineTable->addColumn('comment1', 'integer', array('comment' => $comment1));
- $offlineTable->addColumn('comment2', 'integer', array('comment' => $comment2));
+ $offlineTable->addColumn('comment1', 'integer', ['comment' => $comment1]);
+ $offlineTable->addColumn('comment2', 'integer', ['comment' => $comment2]);
$offlineTable->addColumn('no_comment1', 'integer');
$offlineTable->addColumn('no_comment2', 'integer');
- $this->_sm->dropAndCreateTable($offlineTable);
+ $this->schemaManager->dropAndCreateTable($offlineTable);
- $onlineTable = $this->_sm->listTableDetails("alter_column_comment_test");
+ $onlineTable = $this->schemaManager->listTableDetails('alter_column_comment_test');
self::assertSame($expectedComment1, $onlineTable->getColumn('comment1')->getComment());
self::assertSame($expectedComment2, $onlineTable->getColumn('comment2')->getComment());
self::assertNull($onlineTable->getColumn('no_comment1')->getComment());
self::assertNull($onlineTable->getColumn('no_comment2')->getComment());
- $onlineTable->changeColumn('comment1', array('comment' => $comment2));
- $onlineTable->changeColumn('comment2', array('comment' => $comment1));
- $onlineTable->changeColumn('no_comment1', array('comment' => $comment1));
- $onlineTable->changeColumn('no_comment2', array('comment' => $comment2));
+ $onlineTable->changeColumn('comment1', ['comment' => $comment2]);
+ $onlineTable->changeColumn('comment2', ['comment' => $comment1]);
+ $onlineTable->changeColumn('no_comment1', ['comment' => $comment1]);
+ $onlineTable->changeColumn('no_comment2', ['comment' => $comment2]);
$comparator = new Comparator();
$tableDiff = $comparator->diffTable($offlineTable, $onlineTable);
- self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
+ self::assertInstanceOf(TableDiff::class, $tableDiff);
- $this->_sm->alterTable($tableDiff);
+ $this->schemaManager->alterTable($tableDiff);
- $onlineTable = $this->_sm->listTableDetails("alter_column_comment_test");
+ $onlineTable = $this->schemaManager->listTableDetails('alter_column_comment_test');
self::assertSame($expectedComment2, $onlineTable->getColumn('comment1')->getComment());
self::assertSame($expectedComment1, $onlineTable->getColumn('comment2')->getComment());
@@ -1207,20 +1241,20 @@ public function testAlterColumnComment($comment1, $expectedComment1, $comment2,
public function getAlterColumnComment()
{
- return array(
- array(null, null, ' ', ' '),
- array(null, null, '0', '0'),
- array(null, null, 'foo', 'foo'),
+ return [
+ [null, null, ' ', ' '],
+ [null, null, '0', '0'],
+ [null, null, 'foo', 'foo'],
- array('', null, ' ', ' '),
- array('', null, '0', '0'),
- array('', null, 'foo', 'foo'),
+ ['', null, ' ', ' '],
+ ['', null, '0', '0'],
+ ['', null, 'foo', 'foo'],
- array(' ', ' ', '0', '0'),
- array(' ', ' ', 'foo', 'foo'),
+ [' ', ' ', '0', '0'],
+ [' ', ' ', 'foo', 'foo'],
- array('0', '0', 'foo', 'foo'),
- );
+ ['0', '0', 'foo', 'foo'],
+ ];
}
/**
@@ -1228,25 +1262,25 @@ public function getAlterColumnComment()
*/
public function testDoesNotListIndexesImplicitlyCreatedByForeignKeys()
{
- if (! $this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
+ if (! $this->schemaManager->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$this->markTestSkipped('This test is only supported on platforms that have foreign keys.');
}
$primaryTable = new Table('test_list_index_impl_primary');
$primaryTable->addColumn('id', 'integer');
- $primaryTable->setPrimaryKey(array('id'));
+ $primaryTable->setPrimaryKey(['id']);
$foreignTable = new Table('test_list_index_impl_foreign');
$foreignTable->addColumn('fk1', 'integer');
$foreignTable->addColumn('fk2', 'integer');
- $foreignTable->addIndex(array('fk1'), 'explicit_fk1_idx');
- $foreignTable->addForeignKeyConstraint('test_list_index_impl_primary', array('fk1'), array('id'));
- $foreignTable->addForeignKeyConstraint('test_list_index_impl_primary', array('fk2'), array('id'));
+ $foreignTable->addIndex(['fk1'], 'explicit_fk1_idx');
+ $foreignTable->addForeignKeyConstraint('test_list_index_impl_primary', ['fk1'], ['id']);
+ $foreignTable->addForeignKeyConstraint('test_list_index_impl_primary', ['fk2'], ['id']);
- $this->_sm->dropAndCreateTable($primaryTable);
- $this->_sm->dropAndCreateTable($foreignTable);
+ $this->schemaManager->dropAndCreateTable($primaryTable);
+ $this->schemaManager->dropAndCreateTable($foreignTable);
- $indexes = $this->_sm->listTableIndexes('test_list_index_impl_foreign');
+ $indexes = $this->schemaManager->listTableIndexes('test_list_index_impl_foreign');
self::assertCount(2, $indexes);
self::assertArrayHasKey('explicit_fk1_idx', $indexes);
@@ -1258,9 +1292,11 @@ public function testDoesNotListIndexesImplicitlyCreatedByForeignKeys()
*/
public function removeJsonArrayTable() : void
{
- if ($this->_sm->tablesExist(['json_array_test'])) {
- $this->_sm->dropTable('json_array_test');
+ if (! $this->schemaManager->tablesExist(['json_array_test'])) {
+ return;
}
+
+ $this->schemaManager->dropTable('json_array_test');
}
/**
@@ -1272,10 +1308,10 @@ public function testComparatorShouldReturnFalseWhenLegacyJsonArrayColumnHasComme
$table = new Table('json_array_test');
$table->addColumn('parameters', 'json_array');
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
$comparator = new Comparator();
- $tableDiff = $comparator->diffTable($this->_sm->listTableDetails('json_array_test'), $table);
+ $tableDiff = $comparator->diffTable($this->schemaManager->listTableDetails('json_array_test'), $table);
self::assertFalse($tableDiff);
}
@@ -1286,20 +1322,20 @@ public function testComparatorShouldReturnFalseWhenLegacyJsonArrayColumnHasComme
*/
public function testComparatorShouldModifyOnlyTheCommentWhenUpdatingFromJsonArrayTypeOnLegacyPlatforms() : void
{
- if ($this->_sm->getDatabasePlatform()->hasNativeJsonType()) {
+ if ($this->schemaManager->getDatabasePlatform()->hasNativeJsonType()) {
$this->markTestSkipped('This test is only supported on platforms that do not have native JSON type.');
}
$table = new Table('json_array_test');
$table->addColumn('parameters', 'json_array');
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
$table = new Table('json_array_test');
$table->addColumn('parameters', 'json');
$comparator = new Comparator();
- $tableDiff = $comparator->diffTable($this->_sm->listTableDetails('json_array_test'), $table);
+ $tableDiff = $comparator->diffTable($this->schemaManager->listTableDetails('json_array_test'), $table);
self::assertInstanceOf(TableDiff::class, $tableDiff);
@@ -1314,17 +1350,17 @@ public function testComparatorShouldModifyOnlyTheCommentWhenUpdatingFromJsonArra
*/
public function testComparatorShouldAddCommentToLegacyJsonArrayTypeThatDoesNotHaveIt() : void
{
- if ( ! $this->_sm->getDatabasePlatform()->hasNativeJsonType()) {
+ if (! $this->schemaManager->getDatabasePlatform()->hasNativeJsonType()) {
$this->markTestSkipped('This test is only supported on platforms that have native JSON type.');
}
- $this->_conn->executeQuery('CREATE TABLE json_array_test (parameters JSON NOT NULL)');
+ $this->connection->executeQuery('CREATE TABLE json_array_test (parameters JSON NOT NULL)');
$table = new Table('json_array_test');
$table->addColumn('parameters', 'json_array');
$comparator = new Comparator();
- $tableDiff = $comparator->diffTable($this->_sm->listTableDetails('json_array_test'), $table);
+ $tableDiff = $comparator->diffTable($this->schemaManager->listTableDetails('json_array_test'), $table);
self::assertInstanceOf(TableDiff::class, $tableDiff);
self::assertSame(['comment'], $tableDiff->changedColumns['parameters']->changedProperties);
@@ -1336,17 +1372,17 @@ public function testComparatorShouldAddCommentToLegacyJsonArrayTypeThatDoesNotHa
*/
public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayType() : void
{
- if ( ! $this->_sm->getDatabasePlatform()->hasNativeJsonType()) {
+ if (! $this->schemaManager->getDatabasePlatform()->hasNativeJsonType()) {
$this->markTestSkipped('This test is only supported on platforms that have native JSON type.');
}
- $this->_conn->executeQuery('CREATE TABLE json_array_test (parameters JSON DEFAULT NULL)');
+ $this->connection->executeQuery('CREATE TABLE json_array_test (parameters JSON DEFAULT NULL)');
$table = new Table('json_array_test');
$table->addColumn('parameters', 'json_array');
$comparator = new Comparator();
- $tableDiff = $comparator->diffTable($this->_sm->listTableDetails('json_array_test'), $table);
+ $tableDiff = $comparator->diffTable($this->schemaManager->listTableDetails('json_array_test'), $table);
self::assertInstanceOf(TableDiff::class, $tableDiff);
self::assertSame(['notnull', 'comment'], $tableDiff->changedColumns['parameters']->changedProperties);
@@ -1358,17 +1394,17 @@ public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayType
*/
public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayTypeEvenWhenPlatformHasJsonSupport() : void
{
- if ( ! $this->_sm->getDatabasePlatform()->hasNativeJsonType()) {
+ if (! $this->schemaManager->getDatabasePlatform()->hasNativeJsonType()) {
$this->markTestSkipped('This test is only supported on platforms that have native JSON type.');
}
- $this->_conn->executeQuery('CREATE TABLE json_array_test (parameters JSON DEFAULT NULL)');
+ $this->connection->executeQuery('CREATE TABLE json_array_test (parameters JSON DEFAULT NULL)');
$table = new Table('json_array_test');
$table->addColumn('parameters', 'json_array');
$comparator = new Comparator();
- $tableDiff = $comparator->diffTable($this->_sm->listTableDetails('json_array_test'), $table);
+ $tableDiff = $comparator->diffTable($this->schemaManager->listTableDetails('json_array_test'), $table);
self::assertInstanceOf(TableDiff::class, $tableDiff);
self::assertSame(['notnull', 'comment'], $tableDiff->changedColumns['parameters']->changedProperties);
@@ -1380,33 +1416,35 @@ public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayType
*/
public function testComparatorShouldNotAddCommentToJsonTypeSinceItIsTheDefaultNow() : void
{
- if ( ! $this->_sm->getDatabasePlatform()->hasNativeJsonType()) {
+ if (! $this->schemaManager->getDatabasePlatform()->hasNativeJsonType()) {
$this->markTestSkipped('This test is only supported on platforms that have native JSON type.');
}
- $this->_conn->executeQuery('CREATE TABLE json_test (parameters JSON NOT NULL)');
+ $this->connection->executeQuery('CREATE TABLE json_test (parameters JSON NOT NULL)');
$table = new Table('json_test');
$table->addColumn('parameters', 'json');
$comparator = new Comparator();
- $tableDiff = $comparator->diffTable($this->_sm->listTableDetails('json_test'), $table);
+ $tableDiff = $comparator->diffTable($this->schemaManager->listTableDetails('json_test'), $table);
self::assertFalse($tableDiff);
}
/**
* @dataProvider commentsProvider
- *
* @group 2596
*/
public function testExtractDoctrineTypeFromComment(string $comment, string $expected, string $currentType) : void
{
- $result = $this->_sm->extractDoctrineTypeFromComment($comment, $currentType);
+ $result = $this->schemaManager->extractDoctrineTypeFromComment($comment, $currentType);
self::assertSame($expected, $result);
}
+ /**
+ * @return string[][]
+ */
public function commentsProvider() : array
{
$currentType = 'current type';
@@ -1423,7 +1461,7 @@ public function commentsProvider() : array
public function testCreateAndListSequences() : void
{
- if ( ! $this->_sm->getDatabasePlatform()->supportsSequences()) {
+ if (! $this->schemaManager->getDatabasePlatform()->supportsSequences()) {
self::markTestSkipped('This test is only supported on platforms that support sequences.');
}
@@ -1436,12 +1474,12 @@ public function testCreateAndListSequences() : void
$sequence1 = new Sequence($sequence1Name, $sequence1AllocationSize, $sequence1InitialValue);
$sequence2 = new Sequence($sequence2Name, $sequence2AllocationSize, $sequence2InitialValue);
- $this->_sm->createSequence($sequence1);
- $this->_sm->createSequence($sequence2);
+ $this->schemaManager->createSequence($sequence1);
+ $this->schemaManager->createSequence($sequence2);
/** @var Sequence[] $actualSequences */
$actualSequences = [];
- foreach ($this->_sm->listSequences() as $sequence) {
+ foreach ($this->schemaManager->listSequences() as $sequence) {
$actualSequences[$sequence->getName()] = $sequence;
}
@@ -1462,7 +1500,7 @@ public function testCreateAndListSequences() : void
*/
public function testComparisonWithAutoDetectedSequenceDefinition() : void
{
- if (! $this->_sm->getDatabasePlatform()->supportsSequences()) {
+ if (! $this->schemaManager->getDatabasePlatform()->supportsSequences()) {
self::markTestSkipped('This test is only supported on platforms that support sequences.');
}
@@ -1471,12 +1509,12 @@ public function testComparisonWithAutoDetectedSequenceDefinition() : void
$sequenceInitialValue = 10;
$sequence = new Sequence($sequenceName, $sequenceAllocationSize, $sequenceInitialValue);
- $this->_sm->dropAndCreateSequence($sequence);
+ $this->schemaManager->dropAndCreateSequence($sequence);
$createdSequence = array_values(
array_filter(
- $this->_sm->listSequences(),
- function (Sequence $sequence) use ($sequenceName) : bool {
+ $this->schemaManager->listSequences(),
+ static function (Sequence $sequence) use ($sequenceName) : bool {
return strcasecmp($sequence->getName(), $sequenceName) === 0;
}
)
@@ -1499,19 +1537,19 @@ public function testPrimaryKeyAutoIncrement()
$table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('text', 'string');
$table->setPrimaryKey(['id']);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $this->_conn->insert('test_pk_auto_increment', ['text' => '1']);
+ $this->connection->insert('test_pk_auto_increment', ['text' => '1']);
- $query = $this->_conn->query('SELECT id FROM test_pk_auto_increment WHERE text = \'1\'');
+ $query = $this->connection->query('SELECT id FROM test_pk_auto_increment WHERE text = \'1\'');
$query->execute();
$lastUsedIdBeforeDelete = (int) $query->fetchColumn();
- $this->_conn->query('DELETE FROM test_pk_auto_increment');
+ $this->connection->query('DELETE FROM test_pk_auto_increment');
- $this->_conn->insert('test_pk_auto_increment', ['text' => '2']);
+ $this->connection->insert('test_pk_auto_increment', ['text' => '2']);
- $query = $this->_conn->query('SELECT id FROM test_pk_auto_increment WHERE text = \'2\'');
+ $query = $this->connection->query('SELECT id FROM test_pk_auto_increment WHERE text = \'2\'');
$query->execute();
$lastUsedIdAfterDelete = (int) $query->fetchColumn();
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php
index 14efbff3cce..659e6d8dff2 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php
@@ -2,8 +2,12 @@
namespace Doctrine\Tests\DBAL\Functional\Schema;
+use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Schema;
+use Doctrine\DBAL\Schema\Table;
+use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\Type;
+use SQLite3;
use function array_map;
use function dirname;
use function extension_loaded;
@@ -18,16 +22,16 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
*/
public function testListDatabases()
{
- $this->_sm->listDatabases();
+ $this->schemaManager->listDatabases();
}
public function testCreateAndDropDatabase()
{
- $path = dirname(__FILE__).'/test_create_and_drop_sqlite_database.sqlite';
+ $path = dirname(__FILE__) . '/test_create_and_drop_sqlite_database.sqlite';
- $this->_sm->createDatabase($path);
+ $this->schemaManager->createDatabase($path);
self::assertFileExists($path);
- $this->_sm->dropDatabase($path);
+ $this->schemaManager->dropDatabase($path);
self::assertFileNotExists($path);
}
@@ -36,21 +40,21 @@ public function testCreateAndDropDatabase()
*/
public function testDropsDatabaseWithActiveConnections()
{
- $this->_sm->dropAndCreateDatabase('test_drop_database');
+ $this->schemaManager->dropAndCreateDatabase('test_drop_database');
self::assertFileExists('test_drop_database');
- $params = $this->_conn->getParams();
+ $params = $this->connection->getParams();
$params['dbname'] = 'test_drop_database';
- $user = $params['user'] ?? null;
+ $user = $params['user'] ?? null;
$password = $params['password'] ?? null;
- $connection = $this->_conn->getDriver()->connect($params, $user, $password);
+ $connection = $this->connection->getDriver()->connect($params, $user, $password);
- self::assertInstanceOf('Doctrine\DBAL\Driver\Connection', $connection);
+ self::assertInstanceOf(Connection::class, $connection);
- $this->_sm->dropDatabase('test_drop_database');
+ $this->schemaManager->dropDatabase('test_drop_database');
self::assertFileNotExists('test_drop_database');
@@ -60,9 +64,9 @@ public function testDropsDatabaseWithActiveConnections()
public function testRenameTable()
{
$this->createTestTable('oldname');
- $this->_sm->renameTable('oldname', 'newname');
+ $this->schemaManager->renameTable('oldname', 'newname');
- $tables = $this->_sm->listTableNames();
+ $tables = $this->schemaManager->listTableNames();
self::assertContains('newname', $tables);
self::assertNotContains('oldname', $tables);
}
@@ -77,7 +81,7 @@ public function createListTableColumns()
public function testListForeignKeysFromExistingDatabase()
{
- $this->_conn->exec(<<connection->exec(<< 'SET NULL', 'onDelete' => 'NO ACTION', 'deferrable' => false, 'deferred' => false)),
- new Schema\ForeignKeyConstraint(array('parent'), 'user', array('id'), '1',
- array('onUpdate' => 'NO ACTION', 'onDelete' => 'CASCADE', 'deferrable' => false, 'deferred' => false)),
- new Schema\ForeignKeyConstraint(array('page'), 'page', array('key'), 'FK_1',
- array('onUpdate' => 'NO ACTION', 'onDelete' => 'NO ACTION', 'deferrable' => true, 'deferred' => true)),
- );
-
- self::assertEquals($expected, $this->_sm->listTableForeignKeys('user'));
+ $expected = [
+ new Schema\ForeignKeyConstraint(
+ ['log'],
+ 'log',
+ [null],
+ 'FK_3',
+ ['onUpdate' => 'SET NULL', 'onDelete' => 'NO ACTION', 'deferrable' => false, 'deferred' => false]
+ ),
+ new Schema\ForeignKeyConstraint(
+ ['parent'],
+ 'user',
+ ['id'],
+ '1',
+ ['onUpdate' => 'NO ACTION', 'onDelete' => 'CASCADE', 'deferrable' => false, 'deferred' => false]
+ ),
+ new Schema\ForeignKeyConstraint(
+ ['page'],
+ 'page',
+ ['key'],
+ 'FK_1',
+ ['onUpdate' => 'NO ACTION', 'onDelete' => 'NO ACTION', 'deferrable' => true, 'deferred' => true]
+ ),
+ ];
+
+ self::assertEquals($expected, $this->schemaManager->listTableForeignKeys('user'));
}
public function testColumnCollation()
@@ -107,9 +126,9 @@ public function testColumnCollation()
$table->addColumn('text', 'text');
$table->addColumn('foo', 'text')->setPlatformOption('collation', 'BINARY');
$table->addColumn('bar', 'text')->setPlatformOption('collation', 'NOCASE');
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $columns = $this->_sm->listTableColumns('test_collation');
+ $columns = $this->schemaManager->listTableColumns('test_collation');
self::assertArrayNotHasKey('collation', $columns['id']->getPlatformOptions());
self::assertEquals('BINARY', $columns['text']->getPlatformOption('collation'));
@@ -121,34 +140,34 @@ public function testListTableWithBinary()
{
$tableName = 'test_binary_table';
- $table = new \Doctrine\DBAL\Schema\Table($tableName);
+ $table = new Table($tableName);
$table->addColumn('id', 'integer');
- $table->addColumn('column_varbinary', 'binary', array());
- $table->addColumn('column_binary', 'binary', array('fixed' => true));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('column_varbinary', 'binary', []);
+ $table->addColumn('column_binary', 'binary', ['fixed' => true]);
+ $table->setPrimaryKey(['id']);
- $this->_sm->createTable($table);
+ $this->schemaManager->createTable($table);
- $table = $this->_sm->listTableDetails($tableName);
+ $table = $this->schemaManager->listTableDetails($tableName);
- self::assertInstanceOf('Doctrine\DBAL\Types\BlobType', $table->getColumn('column_varbinary')->getType());
+ self::assertInstanceOf(BlobType::class, $table->getColumn('column_varbinary')->getType());
self::assertFalse($table->getColumn('column_varbinary')->getFixed());
- self::assertInstanceOf('Doctrine\DBAL\Types\BlobType', $table->getColumn('column_binary')->getType());
+ self::assertInstanceOf(BlobType::class, $table->getColumn('column_binary')->getType());
self::assertFalse($table->getColumn('column_binary')->getFixed());
}
public function testNonDefaultPKOrder()
{
- if ( ! extension_loaded('sqlite3')) {
+ if (! extension_loaded('sqlite3')) {
$this->markTestSkipped('This test requires the SQLite3 extension.');
}
- $version = \SQLite3::version();
- if(version_compare($version['versionString'], '3.7.16', '<')) {
+ $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->_conn->exec(<<connection->exec(<<_sm->listTableIndexes('non_default_pk_order');
+ $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(array('other_id', 'id'), array_map('strtolower', $tableIndexes['primary']->getColumns()));
+ self::assertEquals(['other_id', 'id'], array_map('strtolower', $tableIndexes['primary']->getColumns()));
}
/**
@@ -177,9 +196,9 @@ public function testListTableColumnsWithWhitespacesInTypeDeclarations()
)
SQL;
- $this->_conn->exec($sql);
+ $this->connection->exec($sql);
- $columns = $this->_sm->listTableColumns('dbal_1779');
+ $columns = $this->schemaManager->listTableColumns('dbal_1779');
self::assertCount(2, $columns);
@@ -201,36 +220,36 @@ public function testDiffListIntegerAutoincrementTableColumns($integerType, $unsi
{
$tableName = 'test_int_autoincrement_table';
- $offlineTable = new \Doctrine\DBAL\Schema\Table($tableName);
- $offlineTable->addColumn('id', $integerType, array('autoincrement' => true, 'unsigned' => $unsigned));
- $offlineTable->setPrimaryKey(array('id'));
+ $offlineTable = new Table($tableName);
+ $offlineTable->addColumn('id', $integerType, ['autoincrement' => true, 'unsigned' => $unsigned]);
+ $offlineTable->setPrimaryKey(['id']);
- $this->_sm->dropAndCreateTable($offlineTable);
+ $this->schemaManager->dropAndCreateTable($offlineTable);
- $onlineTable = $this->_sm->listTableDetails($tableName);
- $comparator = new Schema\Comparator();
- $diff = $comparator->diffTable($offlineTable, $onlineTable);
+ $onlineTable = $this->schemaManager->listTableDetails($tableName);
+ $comparator = new Schema\Comparator();
+ $diff = $comparator->diffTable($offlineTable, $onlineTable);
if ($expectedComparatorDiff) {
- self::assertEmpty($this->_sm->getDatabasePlatform()->getAlterTableSQL($diff));
+ self::assertEmpty($this->schemaManager->getDatabasePlatform()->getAlterTableSQL($diff));
} else {
self::assertFalse($diff);
}
}
/**
- * @return array
+ * @return mixed[][]
*/
public function getDiffListIntegerAutoincrementTableColumnsData()
{
- return array(
- array('smallint', false, true),
- array('smallint', true, true),
- array('integer', false, false),
- array('integer', true, true),
- array('bigint', false, true),
- array('bigint', true, true),
- );
+ return [
+ ['smallint', false, true],
+ ['smallint', true, true],
+ ['integer', false, false],
+ ['integer', true, true],
+ ['bigint', false, true],
+ ['bigint', true, true],
+ ];
}
/**
@@ -242,15 +261,15 @@ public function testPrimaryKeyNoAutoIncrement()
$table->addColumn('id', 'integer');
$table->addColumn('text', 'text');
$table->setPrimaryKey(['id']);
- $this->_sm->dropAndCreateTable($table);
+ $this->schemaManager->dropAndCreateTable($table);
- $this->_conn->insert('test_pk_auto_increment', ['text' => '1']);
+ $this->connection->insert('test_pk_auto_increment', ['text' => '1']);
- $this->_conn->query('DELETE FROM test_pk_auto_increment');
+ $this->connection->query('DELETE FROM test_pk_auto_increment');
- $this->_conn->insert('test_pk_auto_increment', ['text' => '2']);
+ $this->connection->insert('test_pk_auto_increment', ['text' => '2']);
- $query = $this->_conn->query('SELECT id FROM test_pk_auto_increment WHERE text = "2"');
+ $query = $this->connection->query('SELECT id FROM test_pk_auto_increment WHERE text = "2"');
$query->execute();
$lastUsedIdAfterDelete = (int) $query->fetchColumn();
diff --git a/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php
index 480cec4c53c..7aa374b461b 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php
@@ -7,10 +7,11 @@
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
+use Doctrine\Tests\DbalFunctionalTestCase;
use function base64_decode;
use function stream_get_contents;
-class StatementTest extends \Doctrine\Tests\DbalFunctionalTestCase
+class StatementTest extends DbalFunctionalTestCase
{
protected function setUp()
{
@@ -18,16 +19,16 @@ protected function setUp()
$table = new Table('stmt_test');
$table->addColumn('id', 'integer');
- $table->addColumn('name', 'text', array('notnull' => false));
- $this->_conn->getSchemaManager()->dropAndCreateTable($table);
+ $table->addColumn('name', 'text', ['notnull' => false]);
+ $this->connection->getSchemaManager()->dropAndCreateTable($table);
}
public function testStatementIsReusableAfterClosingCursor()
{
- $this->_conn->insert('stmt_test', array('id' => 1));
- $this->_conn->insert('stmt_test', array('id' => 2));
+ $this->connection->insert('stmt_test', ['id' => 1]);
+ $this->connection->insert('stmt_test', ['id' => 2]);
- $stmt = $this->_conn->prepare('SELECT id FROM stmt_test ORDER BY id');
+ $stmt = $this->connection->prepare('SELECT id FROM stmt_test ORDER BY id');
$stmt->execute();
@@ -45,35 +46,35 @@ public function testStatementIsReusableAfterClosingCursor()
public function testReuseStatementWithLongerResults()
{
- $sm = $this->_conn->getSchemaManager();
+ $sm = $this->connection->getSchemaManager();
$table = new Table('stmt_longer_results');
$table->addColumn('param', 'string');
$table->addColumn('val', 'text');
$sm->createTable($table);
- $row1 = array(
+ $row1 = [
'param' => 'param1',
'val' => 'X',
- );
- $this->_conn->insert('stmt_longer_results', $row1);
+ ];
+ $this->connection->insert('stmt_longer_results', $row1);
- $stmt = $this->_conn->prepare('SELECT param, val FROM stmt_longer_results ORDER BY param');
+ $stmt = $this->connection->prepare('SELECT param, val FROM stmt_longer_results ORDER BY param');
$stmt->execute();
- self::assertArraySubset(array(
- array('param1', 'X'),
- ), $stmt->fetchAll(FetchMode::NUMERIC));
+ self::assertArraySubset([
+ ['param1', 'X'],
+ ], $stmt->fetchAll(FetchMode::NUMERIC));
- $row2 = array(
+ $row2 = [
'param' => 'param2',
'val' => 'A bit longer value',
- );
- $this->_conn->insert('stmt_longer_results', $row2);
+ ];
+ $this->connection->insert('stmt_longer_results', $row2);
$stmt->execute();
- self::assertArraySubset(array(
- array('param1', 'X'),
- array('param2', 'A bit longer value'),
- ), $stmt->fetchAll(FetchMode::NUMERIC));
+ self::assertArraySubset([
+ ['param1', 'X'],
+ ['param2', 'A bit longer value'],
+ ], $stmt->fetchAll(FetchMode::NUMERIC));
}
public function testFetchLongBlob()
@@ -82,11 +83,9 @@ public function testFetchLongBlob()
// but is still not enough to store a LONGBLOB of the max possible size
$this->iniSet('memory_limit', '4G');
- $sm = $this->_conn->getSchemaManager();
+ $sm = $this->connection->getSchemaManager();
$table = new Table('stmt_long_blob');
- $table->addColumn('contents', 'blob', array(
- 'length' => 0xFFFFFFFF,
- ));
+ $table->addColumn('contents', 'blob', ['length' => 0xFFFFFFFF]);
$sm->createTable($table);
$contents = base64_decode(<<_conn->insert('stmt_long_blob', ['contents' => $contents], [ParameterType::LARGE_OBJECT]);
+ $this->connection->insert('stmt_long_blob', ['contents' => $contents], [ParameterType::LARGE_OBJECT]);
- $stmt = $this->_conn->prepare('SELECT contents FROM stmt_long_blob');
+ $stmt = $this->connection->prepare('SELECT contents FROM stmt_long_blob');
$stmt->execute();
$stream = Type::getType('blob')
->convertToPHPValue(
$stmt->fetchColumn(),
- $this->_conn->getDatabasePlatform()
+ $this->connection->getDatabasePlatform()
);
self::assertSame($contents, stream_get_contents($stream));
@@ -122,45 +121,45 @@ public function testFetchLongBlob()
public function testIncompletelyFetchedStatementDoesNotBlockConnection()
{
- $this->_conn->insert('stmt_test', array('id' => 1));
- $this->_conn->insert('stmt_test', array('id' => 2));
+ $this->connection->insert('stmt_test', ['id' => 1]);
+ $this->connection->insert('stmt_test', ['id' => 2]);
- $stmt1 = $this->_conn->prepare('SELECT id FROM stmt_test');
+ $stmt1 = $this->connection->prepare('SELECT id FROM stmt_test');
$stmt1->execute();
$stmt1->fetch();
$stmt1->execute();
// fetching only one record out of two
$stmt1->fetch();
- $stmt2 = $this->_conn->prepare('SELECT id FROM stmt_test WHERE id = ?');
- $stmt2->execute(array(1));
+ $stmt2 = $this->connection->prepare('SELECT id FROM stmt_test WHERE id = ?');
+ $stmt2->execute([1]);
self::assertEquals(1, $stmt2->fetchColumn());
}
public function testReuseStatementAfterClosingCursor()
{
- $this->_conn->insert('stmt_test', array('id' => 1));
- $this->_conn->insert('stmt_test', array('id' => 2));
+ $this->connection->insert('stmt_test', ['id' => 1]);
+ $this->connection->insert('stmt_test', ['id' => 2]);
- $stmt = $this->_conn->prepare('SELECT id FROM stmt_test WHERE id = ?');
+ $stmt = $this->connection->prepare('SELECT id FROM stmt_test WHERE id = ?');
- $stmt->execute(array(1));
+ $stmt->execute([1]);
$id = $stmt->fetchColumn();
self::assertEquals(1, $id);
$stmt->closeCursor();
- $stmt->execute(array(2));
+ $stmt->execute([2]);
$id = $stmt->fetchColumn();
self::assertEquals(2, $id);
}
public function testReuseStatementWithParameterBoundByReference()
{
- $this->_conn->insert('stmt_test', array('id' => 1));
- $this->_conn->insert('stmt_test', array('id' => 2));
+ $this->connection->insert('stmt_test', ['id' => 1]);
+ $this->connection->insert('stmt_test', ['id' => 2]);
- $stmt = $this->_conn->prepare('SELECT id FROM stmt_test WHERE id = ?');
+ $stmt = $this->connection->prepare('SELECT id FROM stmt_test WHERE id = ?');
$stmt->bindParam(1, $id);
$id = 1;
@@ -174,10 +173,10 @@ public function testReuseStatementWithParameterBoundByReference()
public function testReuseStatementWithReboundValue()
{
- $this->_conn->insert('stmt_test', array('id' => 1));
- $this->_conn->insert('stmt_test', array('id' => 2));
+ $this->connection->insert('stmt_test', ['id' => 1]);
+ $this->connection->insert('stmt_test', ['id' => 2]);
- $stmt = $this->_conn->prepare('SELECT id FROM stmt_test WHERE id = ?');
+ $stmt = $this->connection->prepare('SELECT id FROM stmt_test WHERE id = ?');
$stmt->bindValue(1, 1);
$stmt->execute();
@@ -190,10 +189,10 @@ public function testReuseStatementWithReboundValue()
public function testReuseStatementWithReboundParam()
{
- $this->_conn->insert('stmt_test', array('id' => 1));
- $this->_conn->insert('stmt_test', array('id' => 2));
+ $this->connection->insert('stmt_test', ['id' => 1]);
+ $this->connection->insert('stmt_test', ['id' => 2]);
- $stmt = $this->_conn->prepare('SELECT id FROM stmt_test WHERE id = ?');
+ $stmt = $this->connection->prepare('SELECT id FROM stmt_test WHERE id = ?');
$x = 1;
$stmt->bindParam(1, $x);
@@ -211,14 +210,14 @@ public function testReuseStatementWithReboundParam()
*/
public function testFetchFromNonExecutedStatement(callable $fetch, $expected)
{
- $stmt = $this->_conn->prepare('SELECT id FROM stmt_test');
+ $stmt = $this->connection->prepare('SELECT id FROM stmt_test');
self::assertSame($expected, $fetch($stmt));
}
public function testCloseCursorOnNonExecutedStatement()
{
- $stmt = $this->_conn->prepare('SELECT id FROM stmt_test');
+ $stmt = $this->connection->prepare('SELECT id FROM stmt_test');
self::assertTrue($stmt->closeCursor());
}
@@ -228,7 +227,7 @@ public function testCloseCursorOnNonExecutedStatement()
*/
public function testCloseCursorAfterCursorEnd()
{
- $stmt = $this->_conn->prepare('SELECT name FROM stmt_test');
+ $stmt = $this->connection->prepare('SELECT name FROM stmt_test');
$stmt->execute();
$stmt->fetch();
@@ -241,7 +240,7 @@ public function testCloseCursorAfterCursorEnd()
*/
public function testFetchFromNonExecutedStatementWithClosedCursor(callable $fetch, $expected)
{
- $stmt = $this->_conn->prepare('SELECT id FROM stmt_test');
+ $stmt = $this->connection->prepare('SELECT id FROM stmt_test');
$stmt->closeCursor();
self::assertSame($expected, $fetch($stmt));
@@ -252,9 +251,9 @@ public function testFetchFromNonExecutedStatementWithClosedCursor(callable $fetc
*/
public function testFetchFromExecutedStatementWithClosedCursor(callable $fetch, $expected)
{
- $this->_conn->insert('stmt_test', array('id' => 1));
+ $this->connection->insert('stmt_test', ['id' => 1]);
- $stmt = $this->_conn->prepare('SELECT id FROM stmt_test');
+ $stmt = $this->connection->prepare('SELECT id FROM stmt_test');
$stmt->execute();
$stmt->closeCursor();
@@ -263,33 +262,33 @@ public function testFetchFromExecutedStatementWithClosedCursor(callable $fetch,
public static function emptyFetchProvider()
{
- return array(
- 'fetch' => array(
- function (Statement $stmt) {
+ return [
+ 'fetch' => [
+ static function (Statement $stmt) {
return $stmt->fetch();
},
false,
- ),
- 'fetch-column' => array(
- function (Statement $stmt) {
+ ],
+ 'fetch-column' => [
+ static function (Statement $stmt) {
return $stmt->fetchColumn();
},
false,
- ),
- 'fetch-all' => array(
- function (Statement $stmt) {
+ ],
+ 'fetch-all' => [
+ static function (Statement $stmt) {
return $stmt->fetchAll();
},
- array(),
- ),
- );
+ [],
+ ],
+ ];
}
public function testFetchInColumnMode() : void
{
- $platform = $this->_conn->getDatabasePlatform();
+ $platform = $this->connection->getDatabasePlatform();
$query = $platform->getDummySelectSQL();
- $result = $this->_conn->executeQuery($query)->fetch(FetchMode::COLUMN);
+ $result = $this->connection->executeQuery($query)->fetch(FetchMode::COLUMN);
self::assertEquals(1, $result);
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php b/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php
index b8c63644a85..f62b992015c 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php
@@ -3,59 +3,60 @@
namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\DBAL\Id\TableGenerator;
+use Doctrine\DBAL\Id\TableGeneratorSchemaVisitor;
+use Doctrine\DBAL\Schema\Schema;
+use Doctrine\Tests\DbalFunctionalTestCase;
+use Throwable;
/**
* @group DDC-450
*/
-class TableGeneratorTest extends \Doctrine\Tests\DbalFunctionalTestCase
+class TableGeneratorTest extends DbalFunctionalTestCase
{
- /**
- * @var TableGenerator
- */
+ /** @var TableGenerator */
private $generator;
protected function setUp()
{
parent::setUp();
- $platform = $this->_conn->getDatabasePlatform();
- if ($platform->getName() == "sqlite") {
+ $platform = $this->connection->getDatabasePlatform();
+ if ($platform->getName() === 'sqlite') {
$this->markTestSkipped('TableGenerator does not work with SQLite');
}
try {
- $schema = new \Doctrine\DBAL\Schema\Schema();
- $visitor = new \Doctrine\DBAL\Id\TableGeneratorSchemaVisitor();
+ $schema = new Schema();
+ $visitor = new TableGeneratorSchemaVisitor();
$schema->visit($visitor);
foreach ($schema->toSql($platform) as $sql) {
- $this->_conn->exec($sql);
+ $this->connection->exec($sql);
}
-
- } catch(\Exception $e) {
+ } catch (Throwable $e) {
}
- $this->generator = new TableGenerator($this->_conn);
+ $this->generator = new TableGenerator($this->connection);
}
public function testNextVal()
{
- $id1 = $this->generator->nextValue("tbl1");
- $id2 = $this->generator->nextValue("tbl1");
- $id3 = $this->generator->nextValue("tbl2");
+ $id1 = $this->generator->nextValue('tbl1');
+ $id2 = $this->generator->nextValue('tbl1');
+ $id3 = $this->generator->nextValue('tbl2');
- self::assertGreaterThan(0, $id1, "First id has to be larger than 0");
- self::assertEquals($id1 + 1, $id2, "Second id is one larger than first one.");
- self::assertEquals($id1, $id3, "First ids from different tables are equal.");
+ self::assertGreaterThan(0, $id1, 'First id has to be larger than 0');
+ self::assertEquals($id1 + 1, $id2, 'Second id is one larger than first one.');
+ self::assertEquals($id1, $id3, 'First ids from different tables are equal.');
}
public function testNextValNotAffectedByOuterTransactions()
{
- $this->_conn->beginTransaction();
- $id1 = $this->generator->nextValue("tbl1");
- $this->_conn->rollBack();
- $id2 = $this->generator->nextValue("tbl1");
+ $this->connection->beginTransaction();
+ $id1 = $this->generator->nextValue('tbl1');
+ $this->connection->rollBack();
+ $id2 = $this->generator->nextValue('tbl1');
- self::assertGreaterThan(0, $id1, "First id has to be larger than 0");
- self::assertEquals($id1 + 1, $id2, "Second id is one larger than first one.");
+ self::assertGreaterThan(0, $id1, 'First id has to be larger than 0');
+ self::assertEquals($id1 + 1, $id2, 'Second id is one larger than first one.');
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php b/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php
index 3a1277267a9..87a776c7e06 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php
@@ -4,106 +4,109 @@
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
+use Doctrine\Tests\DbalFunctionalTestCase;
+use Throwable;
-class TemporaryTableTest extends \Doctrine\Tests\DbalFunctionalTestCase
+class TemporaryTableTest extends DbalFunctionalTestCase
{
protected function setUp()
{
parent::setUp();
try {
- $this->_conn->exec($this->_conn->getDatabasePlatform()->getDropTableSQL("nontemporary"));
- } catch(\Exception $e) {
-
+ $this->connection->exec($this->connection->getDatabasePlatform()->getDropTableSQL('nontemporary'));
+ } catch (Throwable $e) {
}
}
protected function tearDown()
{
- if ($this->_conn) {
+ if ($this->connection) {
try {
- $tempTable = $this->_conn->getDatabasePlatform()->getTemporaryTableName("my_temporary");
- $this->_conn->exec($this->_conn->getDatabasePlatform()->getDropTemporaryTableSQL($tempTable));
- } catch(\Exception $e) { }
+ $tempTable = $this->connection->getDatabasePlatform()->getTemporaryTableName('my_temporary');
+ $this->connection->exec($this->connection->getDatabasePlatform()->getDropTemporaryTableSQL($tempTable));
+ } catch (Throwable $e) {
+ }
}
parent::tearDown();
}
/**
- * @group DDC-1337
* @return void
+ *
+ * @group DDC-1337
*/
public function testDropTemporaryTableNotAutoCommitTransaction()
{
- if ($this->_conn->getDatabasePlatform()->getName() == 'sqlanywhere' ||
- $this->_conn->getDatabasePlatform()->getName() == 'oracle') {
- $this->markTestSkipped("Test does not work on Oracle and SQL Anywhere.");
+ if ($this->connection->getDatabasePlatform()->getName() === 'sqlanywhere' ||
+ $this->connection->getDatabasePlatform()->getName() === 'oracle') {
+ $this->markTestSkipped('Test does not work on Oracle and SQL Anywhere.');
}
- $platform = $this->_conn->getDatabasePlatform();
- $columnDefinitions = array("id" => array("type" => Type::getType("integer"), "notnull" => true));
- $tempTable = $platform->getTemporaryTableName("my_temporary");
+ $platform = $this->connection->getDatabasePlatform();
+ $columnDefinitions = ['id' => ['type' => Type::getType('integer'), 'notnull' => true]];
+ $tempTable = $platform->getTemporaryTableName('my_temporary');
$createTempTableSQL = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
. $platform->getColumnDeclarationListSQL($columnDefinitions) . ')';
- $this->_conn->executeUpdate($createTempTableSQL);
+ $this->connection->executeUpdate($createTempTableSQL);
- $table = new Table("nontemporary");
- $table->addColumn("id", "integer");
- $table->setPrimaryKey(array('id'));
+ $table = new Table('nontemporary');
+ $table->addColumn('id', 'integer');
+ $table->setPrimaryKey(['id']);
- $this->_conn->getSchemaManager()->createTable($table);
+ $this->connection->getSchemaManager()->createTable($table);
- $this->_conn->beginTransaction();
- $this->_conn->insert("nontemporary", array("id" => 1));
- $this->_conn->exec($platform->getDropTemporaryTableSQL($tempTable));
- $this->_conn->insert("nontemporary", array("id" => 2));
+ $this->connection->beginTransaction();
+ $this->connection->insert('nontemporary', ['id' => 1]);
+ $this->connection->exec($platform->getDropTemporaryTableSQL($tempTable));
+ $this->connection->insert('nontemporary', ['id' => 2]);
- $this->_conn->rollBack();
+ $this->connection->rollBack();
- $rows = $this->_conn->fetchAll('SELECT * FROM nontemporary');
- self::assertEquals(array(), $rows, "In an event of an error this result has one row, because of an implicit commit.");
+ $rows = $this->connection->fetchAll('SELECT * FROM nontemporary');
+ self::assertEquals([], $rows, 'In an event of an error this result has one row, because of an implicit commit.');
}
/**
- * @group DDC-1337
* @return void
+ *
+ * @group DDC-1337
*/
public function testCreateTemporaryTableNotAutoCommitTransaction()
{
- if ($this->_conn->getDatabasePlatform()->getName() == 'sqlanywhere' ||
- $this->_conn->getDatabasePlatform()->getName() == 'oracle') {
- $this->markTestSkipped("Test does not work on Oracle and SQL Anywhere.");
+ if ($this->connection->getDatabasePlatform()->getName() === 'sqlanywhere' ||
+ $this->connection->getDatabasePlatform()->getName() === 'oracle') {
+ $this->markTestSkipped('Test does not work on Oracle and SQL Anywhere.');
}
- $platform = $this->_conn->getDatabasePlatform();
- $columnDefinitions = array("id" => array("type" => Type::getType("integer"), "notnull" => true));
- $tempTable = $platform->getTemporaryTableName("my_temporary");
+ $platform = $this->connection->getDatabasePlatform();
+ $columnDefinitions = ['id' => ['type' => Type::getType('integer'), 'notnull' => true]];
+ $tempTable = $platform->getTemporaryTableName('my_temporary');
$createTempTableSQL = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
. $platform->getColumnDeclarationListSQL($columnDefinitions) . ')';
- $table = new Table("nontemporary");
- $table->addColumn("id", "integer");
- $table->setPrimaryKey(array('id'));
+ $table = new Table('nontemporary');
+ $table->addColumn('id', 'integer');
+ $table->setPrimaryKey(['id']);
- $this->_conn->getSchemaManager()->createTable($table);
+ $this->connection->getSchemaManager()->createTable($table);
- $this->_conn->beginTransaction();
- $this->_conn->insert("nontemporary", array("id" => 1));
+ $this->connection->beginTransaction();
+ $this->connection->insert('nontemporary', ['id' => 1]);
- $this->_conn->exec($createTempTableSQL);
- $this->_conn->insert("nontemporary", array("id" => 2));
+ $this->connection->exec($createTempTableSQL);
+ $this->connection->insert('nontemporary', ['id' => 2]);
- $this->_conn->rollBack();
+ $this->connection->rollBack();
try {
- $this->_conn->exec($platform->getDropTemporaryTableSQL($tempTable));
- } catch(\Exception $e) {
-
+ $this->connection->exec($platform->getDropTemporaryTableSQL($tempTable));
+ } catch (Throwable $e) {
}
- $rows = $this->_conn->fetchAll('SELECT * FROM nontemporary');
- self::assertEquals(array(), $rows, "In an event of an error this result has one row, because of an implicit commit.");
+ $rows = $this->connection->fetchAll('SELECT * FROM nontemporary');
+ self::assertEquals([], $rows, 'In an event of an error this result has one row, because of an implicit commit.');
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php
index 47b1e5eab4a..b18b6cbdaf5 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php
@@ -2,25 +2,28 @@
namespace Doctrine\Tests\DBAL\Functional\Ticket;
+use Doctrine\DBAL\Schema\Table;
+use Doctrine\Tests\DbalFunctionalTestCase;
+
/**
* @group DBAL-168
*/
-class DBAL168Test extends \Doctrine\Tests\DbalFunctionalTestCase
+class DBAL168Test extends DbalFunctionalTestCase
{
public function testDomainsTable()
{
- if ($this->_conn->getDatabasePlatform()->getName() != "postgresql") {
+ if ($this->connection->getDatabasePlatform()->getName() !== 'postgresql') {
$this->markTestSkipped('PostgreSQL only test');
}
- $table = new \Doctrine\DBAL\Schema\Table("domains");
+ $table = new Table('domains');
$table->addColumn('id', 'integer');
$table->addColumn('parent_id', 'integer');
- $table->setPrimaryKey(array('id'));
- $table->addForeignKeyConstraint('domains', array('parent_id'), array('id'));
+ $table->setPrimaryKey(['id']);
+ $table->addForeignKeyConstraint('domains', ['parent_id'], ['id']);
- $this->_conn->getSchemaManager()->createTable($table);
- $table = $this->_conn->getSchemaManager()->listTableDetails('domains');
+ $this->connection->getSchemaManager()->createTable($table);
+ $table = $this->connection->getSchemaManager()->listTableDetails('domains');
self::assertEquals('domains', $table->getName());
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php
index cbb7674f893..1adf993250f 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php
@@ -2,47 +2,50 @@
namespace Doctrine\Tests\DBAL\Functional\Ticket;
+use Doctrine\DBAL\Schema\Table;
+use Doctrine\Tests\DbalFunctionalTestCase;
+
/**
* @group DBAL-202
*/
-class DBAL202Test extends \Doctrine\Tests\DbalFunctionalTestCase
+class DBAL202Test extends DbalFunctionalTestCase
{
protected function setUp()
{
parent::setUp();
- if ($this->_conn->getDatabasePlatform()->getName() != 'oracle') {
+ if ($this->connection->getDatabasePlatform()->getName() !== 'oracle') {
$this->markTestSkipped('OCI8 only test');
}
- if ($this->_conn->getSchemaManager()->tablesExist('DBAL202')) {
- $this->_conn->exec('DELETE FROM DBAL202');
+ if ($this->connection->getSchemaManager()->tablesExist('DBAL202')) {
+ $this->connection->exec('DELETE FROM DBAL202');
} else {
- $table = new \Doctrine\DBAL\Schema\Table('DBAL202');
+ $table = new Table('DBAL202');
$table->addColumn('id', 'integer');
- $table->setPrimaryKey(array('id'));
+ $table->setPrimaryKey(['id']);
- $this->_conn->getSchemaManager()->createTable($table);
+ $this->connection->getSchemaManager()->createTable($table);
}
}
public function testStatementRollback()
{
- $stmt = $this->_conn->prepare('INSERT INTO DBAL202 VALUES (8)');
- $this->_conn->beginTransaction();
+ $stmt = $this->connection->prepare('INSERT INTO DBAL202 VALUES (8)');
+ $this->connection->beginTransaction();
$stmt->execute();
- $this->_conn->rollBack();
+ $this->connection->rollBack();
- self::assertEquals(0, $this->_conn->query('SELECT COUNT(1) FROM DBAL202')->fetchColumn());
+ self::assertEquals(0, $this->connection->query('SELECT COUNT(1) FROM DBAL202')->fetchColumn());
}
public function testStatementCommit()
{
- $stmt = $this->_conn->prepare('INSERT INTO DBAL202 VALUES (8)');
- $this->_conn->beginTransaction();
+ $stmt = $this->connection->prepare('INSERT INTO DBAL202 VALUES (8)');
+ $this->connection->beginTransaction();
$stmt->execute();
- $this->_conn->commit();
+ $this->connection->commit();
- self::assertEquals(1, $this->_conn->query('SELECT COUNT(1) FROM DBAL202')->fetchColumn());
+ self::assertEquals(1, $this->connection->query('SELECT COUNT(1) FROM DBAL202')->fetchColumn());
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php
index 4db10e1173f..af41670690a 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php
@@ -1,29 +1,33 @@
_conn->getDatabasePlatform()->getName();
- if (!in_array($platform, array('mysql', 'sqlite'))) {
- $this->markTestSkipped('Currently restricted to MySQL and SQLite.');
+ $platform = $this->connection->getDatabasePlatform()->getName();
+ if (in_array($platform, ['mysql', 'sqlite'])) {
+ return;
}
+
+ $this->markTestSkipped('Currently restricted to MySQL and SQLite.');
}
public function testGuidShouldMatchPattern()
{
- $guid = $this->_conn->query($this->getSelectGuidSql())->fetchColumn();
+ $guid = $this->connection->query($this->getSelectGuidSql())->fetchColumn();
$pattern = '/[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[8-9A-B][0-9A-F]{3}\-[0-9A-F]{12}/i';
- self::assertEquals(1, preg_match($pattern, $guid), "GUID does not match pattern");
+ self::assertEquals(1, preg_match($pattern, $guid), 'GUID does not match pattern');
}
/**
@@ -32,13 +36,13 @@ public function testGuidShouldMatchPattern()
*/
public function testGuidShouldBeRandom()
{
- $statement = $this->_conn->prepare($this->getSelectGuidSql());
- $guids = array();
+ $statement = $this->connection->prepare($this->getSelectGuidSql());
+ $guids = [];
for ($i = 0; $i < 99; $i++) {
$statement->execute();
$guid = $statement->fetchColumn();
- self::assertNotContains($guid, $guids, "Duplicate GUID detected");
+ self::assertNotContains($guid, $guids, 'Duplicate GUID detected');
$guids[] = $guid;
}
@@ -47,6 +51,6 @@ public function testGuidShouldBeRandom()
private function getSelectGuidSql()
{
- return "SELECT " . $this->_conn->getDatabasePlatform()->getGuidExpression();
+ return 'SELECT ' . $this->connection->getDatabasePlatform()->getGuidExpression();
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL461Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL461Test.php
index 1f40837daa7..a9dbdb1e109 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL461Test.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL461Test.php
@@ -2,25 +2,29 @@
namespace Doctrine\Tests\DBAL\Functional\Ticket;
+use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\SQLServerSchemaManager;
use Doctrine\DBAL\Types\DecimalType;
+use PHPUnit\Framework\TestCase;
+use ReflectionMethod;
/**
* @group DBAL-461
*/
-class DBAL461Test extends \PHPUnit\Framework\TestCase
+class DBAL461Test extends TestCase
{
public function testIssue()
{
- $conn = $this->createMock('Doctrine\DBAL\Connection');
- $platform = $this->getMockForAbstractClass('Doctrine\DBAL\Platforms\AbstractPlatform');
+ $conn = $this->createMock(Connection::class);
+ $platform = $this->getMockForAbstractClass(AbstractPlatform::class);
$platform->registerDoctrineTypeMapping('numeric', 'decimal');
$schemaManager = new SQLServerSchemaManager($conn, $platform);
- $reflectionMethod = new \ReflectionMethod($schemaManager, '_getPortableTableColumnDefinition');
+ $reflectionMethod = new ReflectionMethod($schemaManager, '_getPortableTableColumnDefinition');
$reflectionMethod->setAccessible(true);
- $column = $reflectionMethod->invoke($schemaManager, array(
+ $column = $reflectionMethod->invoke($schemaManager, [
'type' => 'numeric(18,0)',
'length' => null,
'default' => null,
@@ -30,7 +34,7 @@ public function testIssue()
'autoincrement' => false,
'collation' => 'foo',
'comment' => null,
- ));
+ ]);
$this->assertInstanceOf(DecimalType::class, $column->getType());
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php
index 4780e6f5c7d..fa98ecb3eca 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php
@@ -4,33 +4,36 @@
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Table;
+use Doctrine\Tests\DbalFunctionalTestCase;
/**
* @group DBAL-510
*/
-class DBAL510Test extends \Doctrine\Tests\DbalFunctionalTestCase
+class DBAL510Test extends DbalFunctionalTestCase
{
protected function setUp()
{
parent::setUp();
- if ($this->_conn->getDatabasePlatform()->getName() !== "postgresql") {
- $this->markTestSkipped('PostgreSQL Only test');
+ if ($this->connection->getDatabasePlatform()->getName() === 'postgresql') {
+ return;
}
+
+ $this->markTestSkipped('PostgreSQL Only test');
}
public function testSearchPathSchemaChanges()
{
- $table = new Table("dbal510tbl");
+ $table = new Table('dbal510tbl');
$table->addColumn('id', 'integer');
- $table->setPrimaryKey(array('id'));
+ $table->setPrimaryKey(['id']);
- $this->_conn->getSchemaManager()->createTable($table);
+ $this->connection->getSchemaManager()->createTable($table);
- $onlineTable = $this->_conn->getSchemaManager()->listTableDetails('dbal510tbl');
+ $onlineTable = $this->connection->getSchemaManager()->listTableDetails('dbal510tbl');
$comparator = new Comparator();
- $diff = $comparator->diffTable($onlineTable, $table);
+ $diff = $comparator->diffTable($onlineTable, $table);
self::assertFalse($diff);
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
index 70210133b1f..827a9124277 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
@@ -4,32 +4,31 @@
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\ParameterType;
+use Doctrine\Tests\DbalFunctionalTestCase;
use PDO;
use function in_array;
/**
* @group DBAL-630
*/
-class DBAL630Test extends \Doctrine\Tests\DbalFunctionalTestCase
+class DBAL630Test extends DbalFunctionalTestCase
{
- /**
- * @var bool
- */
+ /** @var bool */
private $running = false;
protected function setUp()
{
parent::setUp();
- $platform = $this->_conn->getDatabasePlatform()->getName();
+ $platform = $this->connection->getDatabasePlatform()->getName();
- if (!in_array($platform, array('postgresql'))) {
+ if (! in_array($platform, ['postgresql'])) {
$this->markTestSkipped('Currently restricted to PostgreSQL');
}
try {
- $this->_conn->exec('CREATE TABLE dbal630 (id SERIAL, bool_col BOOLEAN NOT NULL);');
- $this->_conn->exec('CREATE TABLE dbal630_allow_nulls (id SERIAL, bool_col BOOLEAN);');
+ $this->connection->exec('CREATE TABLE dbal630 (id SERIAL, bool_col BOOLEAN NOT NULL);');
+ $this->connection->exec('CREATE TABLE dbal630_allow_nulls (id SERIAL, bool_col BOOLEAN);');
} catch (DBALException $e) {
}
$this->running = true;
@@ -38,7 +37,7 @@ protected function setUp()
protected function tearDown()
{
if ($this->running) {
- $this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
+ $this->connection->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
parent::tearDown();
@@ -46,45 +45,45 @@ protected function tearDown()
public function testBooleanConversionSqlLiteral()
{
- $this->_conn->executeUpdate('INSERT INTO dbal630 (bool_col) VALUES(false)');
- $id = $this->_conn->lastInsertId('dbal630_id_seq');
+ $this->connection->executeUpdate('INSERT INTO dbal630 (bool_col) VALUES(false)');
+ $id = $this->connection->lastInsertId('dbal630_id_seq');
self::assertNotEmpty($id);
- $row = $this->_conn->fetchAssoc('SELECT bool_col FROM dbal630 WHERE id = ?', array($id));
+ $row = $this->connection->fetchAssoc('SELECT bool_col FROM dbal630 WHERE id = ?', [$id]);
self::assertFalse($row['bool_col']);
}
public function testBooleanConversionBoolParamRealPrepares()
{
- $this->_conn->executeUpdate(
+ $this->connection->executeUpdate(
'INSERT INTO dbal630 (bool_col) VALUES(?)',
['false'],
[ParameterType::BOOLEAN]
);
- $id = $this->_conn->lastInsertId('dbal630_id_seq');
+ $id = $this->connection->lastInsertId('dbal630_id_seq');
self::assertNotEmpty($id);
- $row = $this->_conn->fetchAssoc('SELECT bool_col FROM dbal630 WHERE id = ?', array($id));
+ $row = $this->connection->fetchAssoc('SELECT bool_col FROM dbal630 WHERE id = ?', [$id]);
self::assertFalse($row['bool_col']);
}
public function testBooleanConversionBoolParamEmulatedPrepares()
{
- $this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
+ $this->connection->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
- $platform = $this->_conn->getDatabasePlatform();
+ $platform = $this->connection->getDatabasePlatform();
- $stmt = $this->_conn->prepare('INSERT INTO dbal630 (bool_col) VALUES(?)');
+ $stmt = $this->connection->prepare('INSERT INTO dbal630 (bool_col) VALUES(?)');
$stmt->bindValue(1, $platform->convertBooleansToDatabaseValue('false'), ParameterType::BOOLEAN);
$stmt->execute();
- $id = $this->_conn->lastInsertId('dbal630_id_seq');
+ $id = $this->connection->lastInsertId('dbal630_id_seq');
self::assertNotEmpty($id);
- $row = $this->_conn->fetchAssoc('SELECT bool_col FROM dbal630 WHERE id = ?', array($id));
+ $row = $this->connection->fetchAssoc('SELECT bool_col FROM dbal630 WHERE id = ?', [$id]);
self::assertFalse($row['bool_col']);
}
@@ -96,19 +95,19 @@ public function testBooleanConversionNullParamEmulatedPrepares(
$statementValue,
$databaseConvertedValue
) {
- $this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
+ $this->connection->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
- $platform = $this->_conn->getDatabasePlatform();
+ $platform = $this->connection->getDatabasePlatform();
- $stmt = $this->_conn->prepare('INSERT INTO dbal630_allow_nulls (bool_col) VALUES(?)');
+ $stmt = $this->connection->prepare('INSERT INTO dbal630_allow_nulls (bool_col) VALUES(?)');
$stmt->bindValue(1, $platform->convertBooleansToDatabaseValue($statementValue));
$stmt->execute();
- $id = $this->_conn->lastInsertId('dbal630_allow_nulls_id_seq');
+ $id = $this->connection->lastInsertId('dbal630_allow_nulls_id_seq');
self::assertNotEmpty($id);
- $row = $this->_conn->fetchAssoc('SELECT bool_col FROM dbal630_allow_nulls WHERE id = ?', array($id));
+ $row = $this->connection->fetchAssoc('SELECT bool_col FROM dbal630_allow_nulls WHERE id = ?', [$id]);
self::assertSame($databaseConvertedValue, $row['bool_col']);
}
@@ -120,11 +119,11 @@ public function testBooleanConversionNullParamEmulatedPreparesWithBooleanTypeInB
$statementValue,
$databaseConvertedValue
) {
- $this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
+ $this->connection->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
- $platform = $this->_conn->getDatabasePlatform();
+ $platform = $this->connection->getDatabasePlatform();
- $stmt = $this->_conn->prepare('INSERT INTO dbal630_allow_nulls (bool_col) VALUES(?)');
+ $stmt = $this->connection->prepare('INSERT INTO dbal630_allow_nulls (bool_col) VALUES(?)');
$stmt->bindValue(
1,
$platform->convertBooleansToDatabaseValue($statementValue),
@@ -132,40 +131,42 @@ public function testBooleanConversionNullParamEmulatedPreparesWithBooleanTypeInB
);
$stmt->execute();
- $id = $this->_conn->lastInsertId('dbal630_allow_nulls_id_seq');
+ $id = $this->connection->lastInsertId('dbal630_allow_nulls_id_seq');
self::assertNotEmpty($id);
- $row = $this->_conn->fetchAssoc('SELECT bool_col FROM dbal630_allow_nulls WHERE id = ?', array($id));
+ $row = $this->connection->fetchAssoc('SELECT bool_col FROM dbal630_allow_nulls WHERE id = ?', [$id]);
self::assertSame($databaseConvertedValue, $row['bool_col']);
}
/**
* Boolean conversion mapping provider
- * @return array
+ *
+ * @return mixed[][]
*/
public function booleanTypeConversionUsingBooleanTypeProvider()
{
- return array(
+ return [
// statement value, database converted value result
- array(true, true),
- array(false, false),
- array(null, false)
- );
+ [true, true],
+ [false, false],
+ [null, false],
+ ];
}
/**
* Boolean conversion mapping provider
- * @return array
+ *
+ * @return mixed[][]
*/
public function booleanTypeConversionWithoutPdoTypeProvider()
{
- return array(
+ return [
// statement value, database converted value result
- array(true, true),
- array(false, false),
- array(null, null)
- );
+ [true, true],
+ [false, false],
+ [null, null],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php
index 5368cdc9192..ee0bce44e08 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php
@@ -1,27 +1,31 @@
_conn->getDatabasePlatform()->getName();
+ $platform = $this->connection->getDatabasePlatform()->getName();
- if (!in_array($platform, array('sqlite'))) {
- $this->markTestSkipped('Related to SQLite only');
+ if (in_array($platform, ['sqlite'])) {
+ return;
}
+
+ $this->markTestSkipped('Related to SQLite only');
}
public function testUnsignedIntegerDetection()
{
- $this->_conn->exec(<<connection->exec(<<_conn->getSchemaManager();
+ $schemaManager = $this->connection->getSchemaManager();
$fetchedTable = $schemaManager->listTableDetails('dbal752_unsigneds');
diff --git a/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php b/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php
index 83c6e4dec55..333e7364088 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php
@@ -2,102 +2,110 @@
namespace Doctrine\Tests\DBAL\Functional;
+use DateTime;
+use Doctrine\DBAL\Schema\AbstractSchemaManager;
+use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
+use Doctrine\Tests\DbalFunctionalTestCase;
+use stdClass;
+use Throwable;
use function str_repeat;
-class TypeConversionTest extends \Doctrine\Tests\DbalFunctionalTestCase
+class TypeConversionTest extends DbalFunctionalTestCase
{
- /**
- * @var int
- */
+ /** @var int */
static private $typeCounter = 0;
protected function setUp()
{
parent::setUp();
- /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
- $sm = $this->_conn->getSchemaManager();
-
- $table = new \Doctrine\DBAL\Schema\Table("type_conversion");
- $table->addColumn('id', 'integer', array('notnull' => false));
- $table->addColumn('test_string', 'string', array('notnull' => false));
- $table->addColumn('test_boolean', 'boolean', array('notnull' => false));
- $table->addColumn('test_bigint', 'bigint', array('notnull' => false));
- $table->addColumn('test_smallint', 'bigint', array('notnull' => false));
- $table->addColumn('test_datetime', 'datetime', array('notnull' => false));
- $table->addColumn('test_datetimetz', 'datetimetz', array('notnull' => false));
- $table->addColumn('test_date', 'date', array('notnull' => false));
- $table->addColumn('test_time', 'time', array('notnull' => false));
- $table->addColumn('test_text', 'text', array('notnull' => false));
- $table->addColumn('test_array', 'array', array('notnull' => false));
- $table->addColumn('test_json_array', 'json_array', array('notnull' => false));
- $table->addColumn('test_object', 'object', array('notnull' => false));
- $table->addColumn('test_float', 'float', array('notnull' => false));
- $table->addColumn('test_decimal', 'decimal', array('notnull' => false, 'scale' => 2, 'precision' => 10));
- $table->setPrimaryKey(array('id'));
+ /** @var AbstractSchemaManager $sm */
+ $sm = $this->connection->getSchemaManager();
+
+ $table = new Table('type_conversion');
+ $table->addColumn('id', 'integer', ['notnull' => false]);
+ $table->addColumn('test_string', 'string', ['notnull' => false]);
+ $table->addColumn('test_boolean', 'boolean', ['notnull' => false]);
+ $table->addColumn('test_bigint', 'bigint', ['notnull' => false]);
+ $table->addColumn('test_smallint', 'bigint', ['notnull' => false]);
+ $table->addColumn('test_datetime', 'datetime', ['notnull' => false]);
+ $table->addColumn('test_datetimetz', 'datetimetz', ['notnull' => false]);
+ $table->addColumn('test_date', 'date', ['notnull' => false]);
+ $table->addColumn('test_time', 'time', ['notnull' => false]);
+ $table->addColumn('test_text', 'text', ['notnull' => false]);
+ $table->addColumn('test_array', 'array', ['notnull' => false]);
+ $table->addColumn('test_json_array', 'json_array', ['notnull' => false]);
+ $table->addColumn('test_object', 'object', ['notnull' => false]);
+ $table->addColumn('test_float', 'float', ['notnull' => false]);
+ $table->addColumn('test_decimal', 'decimal', ['notnull' => false, 'scale' => 2, 'precision' => 10]);
+ $table->setPrimaryKey(['id']);
try {
- $this->_conn->getSchemaManager()->createTable($table);
- } catch(\Exception $e) {
-
+ $this->connection->getSchemaManager()->createTable($table);
+ } catch (Throwable $e) {
}
}
public static function dataIdempotentDataConversion()
{
- $obj = new \stdClass();
- $obj->foo = "bar";
- $obj->bar = "baz";
-
- return array(
- array('string', 'ABCDEFGaaaBBB', 'string'),
- array('boolean', true, 'bool'),
- array('boolean', false, 'bool'),
- array('bigint', 12345678, 'string'),
- array('smallint', 123, 'int'),
- array('datetime', new \DateTime('2010-04-05 10:10:10'), 'DateTime'),
- array('datetimetz', new \DateTime('2010-04-05 10:10:10'), 'DateTime'),
- array('date', new \DateTime('2010-04-05'), 'DateTime'),
- array('time', new \DateTime('1970-01-01 10:10:10'), 'DateTime'),
- array('text', str_repeat('foo ', 1000), 'string'),
- array('array', array('foo' => 'bar'), 'array'),
- array('json_array', array('foo' => 'bar'), 'array'),
- array('object', $obj, 'object'),
- array('float', 1.5, 'float'),
- array('decimal', 1.55, 'string'),
- );
+ $obj = new stdClass();
+ $obj->foo = 'bar';
+ $obj->bar = 'baz';
+
+ return [
+ ['string', 'ABCDEFGaaaBBB', 'string'],
+ ['boolean', true, 'bool'],
+ ['boolean', false, 'bool'],
+ ['bigint', 12345678, 'string'],
+ ['smallint', 123, 'int'],
+ ['datetime', new DateTime('2010-04-05 10:10:10'), 'DateTime'],
+ ['datetimetz', new DateTime('2010-04-05 10:10:10'), 'DateTime'],
+ ['date', new DateTime('2010-04-05'), 'DateTime'],
+ ['time', new DateTime('1970-01-01 10:10:10'), 'DateTime'],
+ ['text', str_repeat('foo ', 1000), 'string'],
+ ['array', ['foo' => 'bar'], 'array'],
+ ['json_array', ['foo' => 'bar'], 'array'],
+ ['object', $obj, 'object'],
+ ['float', 1.5, 'float'],
+ ['decimal', 1.55, 'string'],
+ ];
}
/**
- * @dataProvider dataIdempotentDataConversion
* @param string $type
* @param mixed $originalValue
* @param string $expectedPhpType
+ *
+ * @dataProvider dataIdempotentDataConversion
*/
public function testIdempotentDataConversion($type, $originalValue, $expectedPhpType)
{
- $columnName = "test_" . $type;
- $typeInstance = Type::getType($type);
- $insertionValue = $typeInstance->convertToDatabaseValue($originalValue, $this->_conn->getDatabasePlatform());
+ $columnName = 'test_' . $type;
+ $typeInstance = Type::getType($type);
+ $insertionValue = $typeInstance->convertToDatabaseValue($originalValue, $this->connection->getDatabasePlatform());
- $this->_conn->insert('type_conversion', array('id' => ++self::$typeCounter, $columnName => $insertionValue));
+ $this->connection->insert('type_conversion', ['id' => ++self::$typeCounter, $columnName => $insertionValue]);
- $sql = "SELECT " . $columnName . " FROM type_conversion WHERE id = " . self::$typeCounter;
- $actualDbValue = $typeInstance->convertToPHPValue($this->_conn->fetchColumn($sql), $this->_conn->getDatabasePlatform());
+ $sql = 'SELECT ' . $columnName . ' FROM type_conversion WHERE id = ' . self::$typeCounter;
+ $actualDbValue = $typeInstance->convertToPHPValue($this->connection->fetchColumn($sql), $this->connection->getDatabasePlatform());
- if ($originalValue instanceof \DateTime) {
- self::assertInstanceOf($expectedPhpType, $actualDbValue, "The expected type from the conversion to and back from the database should be " . $expectedPhpType);
+ if ($originalValue instanceof DateTime) {
+ self::assertInstanceOf($expectedPhpType, $actualDbValue, 'The expected type from the conversion to and back from the database should be ' . $expectedPhpType);
} else {
- self::assertInternalType($expectedPhpType, $actualDbValue, "The expected type from the conversion to and back from the database should be " . $expectedPhpType);
+ self::assertInternalType($expectedPhpType, $actualDbValue, 'The expected type from the conversion to and back from the database should be ' . $expectedPhpType);
+ }
+
+ if ($type === 'datetimetz') {
+ return;
}
- if ($type !== "datetimetz") {
- self::assertEquals($originalValue, $actualDbValue, "Conversion between values should produce the same out as in value, but doesnt!");
+ self::assertEquals($originalValue, $actualDbValue, 'Conversion between values should produce the same out as in value, but doesnt!');
- if ($originalValue instanceof \DateTime) {
- self::assertEquals($originalValue->getTimezone()->getName(), $actualDbValue->getTimezone()->getName(), "Timezones should be the same.");
- }
+ if (! ($originalValue instanceof DateTime)) {
+ return;
}
+
+ self::assertEquals($originalValue->getTimezone()->getName(), $actualDbValue->getTimezone()->getName(), 'Timezones should be the same.');
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php b/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php
index f4e6ff1a84d..d17d5250072 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php
@@ -27,7 +27,7 @@ protected function setUp()
$table->addColumn('val', 'binary', ['length' => 64]);
$table->setPrimaryKey(['id']);
- $sm = $this->_conn->getSchemaManager();
+ $sm = $this->connection->getSchemaManager();
$sm->dropAndCreateTable($table);
}
@@ -40,7 +40,7 @@ public function testInsertAndSelect()
$value2 = random_bytes(64);
/** @see https://bugs.php.net/bug.php?id=76322 */
- if ($this->_conn->getDriver() instanceof DB2Driver) {
+ if ($this->connection->getDriver() instanceof DB2Driver) {
$value1 = str_replace("\x00", "\xFF", $value1);
$value2 = str_replace("\x00", "\xFF", $value2);
}
@@ -54,7 +54,7 @@ public function testInsertAndSelect()
private function insert(string $id, string $value) : void
{
- $result = $this->_conn->insert('binary_table', [
+ $result = $this->connection->insert('binary_table', [
'id' => $id,
'val' => $value,
], [
@@ -67,7 +67,7 @@ private function insert(string $id, string $value) : void
private function select(string $id)
{
- $value = $this->_conn->fetchColumn(
+ $value = $this->connection->fetchColumn(
'SELECT val FROM binary_table WHERE id = ?',
[$id],
0,
diff --git a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php
index 8ce8e373e83..039fed14f8e 100644
--- a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php
+++ b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php
@@ -2,30 +2,35 @@
namespace Doctrine\Tests\DBAL\Functional;
+use DateTime;
use Doctrine\DBAL\ParameterType;
+use Doctrine\DBAL\Schema\AbstractSchemaManager;
+use Doctrine\DBAL\Schema\Sequence;
+use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
+use Doctrine\Tests\DbalFunctionalTestCase;
+use Throwable;
use function array_filter;
use function strtolower;
-class WriteTest extends \Doctrine\Tests\DbalFunctionalTestCase
+class WriteTest extends DbalFunctionalTestCase
{
protected function setUp()
{
parent::setUp();
try {
- /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
- $table = new \Doctrine\DBAL\Schema\Table("write_table");
- $table->addColumn('id', 'integer', array('autoincrement' => true));
+ /** @var AbstractSchemaManager $sm */
+ $table = new Table('write_table');
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('test_int', 'integer');
- $table->addColumn('test_string', 'string', array('notnull' => false));
- $table->setPrimaryKey(array('id'));
-
- $this->_conn->getSchemaManager()->createTable($table);
- } catch(\Exception $e) {
+ $table->addColumn('test_string', 'string', ['notnull' => false]);
+ $table->setPrimaryKey(['id']);
+ $this->connection->getSchemaManager()->createTable($table);
+ } catch (Throwable $e) {
}
- $this->_conn->executeUpdate('DELETE FROM write_table');
+ $this->connection->executeUpdate('DELETE FROM write_table');
}
/**
@@ -33,40 +38,40 @@ protected function setUp()
*/
public function testExecuteUpdateFirstTypeIsNull()
{
- $sql = "INSERT INTO write_table (test_string, test_int) VALUES (?, ?)";
- $this->_conn->executeUpdate($sql, ['text', 1111], [null, ParameterType::INTEGER]);
+ $sql = 'INSERT INTO write_table (test_string, test_int) VALUES (?, ?)';
+ $this->connection->executeUpdate($sql, ['text', 1111], [null, ParameterType::INTEGER]);
- $sql = "SELECT * FROM write_table WHERE test_string = ? AND test_int = ?";
- self::assertTrue((bool) $this->_conn->fetchColumn($sql, ['text', 1111]));
+ $sql = 'SELECT * FROM write_table WHERE test_string = ? AND test_int = ?';
+ self::assertTrue((bool) $this->connection->fetchColumn($sql, ['text', 1111]));
}
public function testExecuteUpdate()
{
- $sql = "INSERT INTO write_table (test_int) VALUES ( " . $this->_conn->quote(1) . ")";
- $affected = $this->_conn->executeUpdate($sql);
+ $sql = 'INSERT INTO write_table (test_int) VALUES ( ' . $this->connection->quote(1) . ')';
+ $affected = $this->connection->executeUpdate($sql);
- self::assertEquals(1, $affected, "executeUpdate() should return the number of affected rows!");
+ self::assertEquals(1, $affected, 'executeUpdate() should return the number of affected rows!');
}
public function testExecuteUpdateWithTypes()
{
- $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)";
- $affected = $this->_conn->executeUpdate(
+ $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
+ $affected = $this->connection->executeUpdate(
$sql,
[1, 'foo'],
[ParameterType::INTEGER, ParameterType::STRING]
);
- self::assertEquals(1, $affected, "executeUpdate() should return the number of affected rows!");
+ self::assertEquals(1, $affected, 'executeUpdate() should return the number of affected rows!');
}
public function testPrepareRowCountReturnsAffectedRows()
{
- $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)";
- $stmt = $this->_conn->prepare($sql);
+ $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
+ $stmt = $this->connection->prepare($sql);
$stmt->bindValue(1, 1);
- $stmt->bindValue(2, "foo");
+ $stmt->bindValue(2, 'foo');
$stmt->execute();
self::assertEquals(1, $stmt->rowCount());
@@ -74,8 +79,8 @@ public function testPrepareRowCountReturnsAffectedRows()
public function testPrepareWithPdoTypes()
{
- $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)";
- $stmt = $this->_conn->prepare($sql);
+ $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
+ $stmt = $this->connection->prepare($sql);
$stmt->bindValue(1, 1, ParameterType::INTEGER);
$stmt->bindValue(2, 'foo', ParameterType::STRING);
@@ -86,11 +91,11 @@ public function testPrepareWithPdoTypes()
public function testPrepareWithDbalTypes()
{
- $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)";
- $stmt = $this->_conn->prepare($sql);
+ $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
+ $stmt = $this->connection->prepare($sql);
$stmt->bindValue(1, 1, Type::getType('integer'));
- $stmt->bindValue(2, "foo", Type::getType('string'));
+ $stmt->bindValue(2, 'foo', Type::getType('string'));
$stmt->execute();
self::assertEquals(1, $stmt->rowCount());
@@ -98,11 +103,11 @@ public function testPrepareWithDbalTypes()
public function testPrepareWithDbalTypeNames()
{
- $sql = "INSERT INTO write_table (test_int, test_string) VALUES (?, ?)";
- $stmt = $this->_conn->prepare($sql);
+ $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
+ $stmt = $this->connection->prepare($sql);
$stmt->bindValue(1, 1, 'integer');
- $stmt->bindValue(2, "foo", 'string');
+ $stmt->bindValue(2, 'foo', 'string');
$stmt->execute();
self::assertEquals(1, $stmt->rowCount());
@@ -110,8 +115,8 @@ public function testPrepareWithDbalTypeNames()
public function insertRows()
{
- self::assertEquals(1, $this->_conn->insert('write_table', array('test_int' => 1, 'test_string' => 'foo')));
- self::assertEquals(1, $this->_conn->insert('write_table', array('test_int' => 2, 'test_string' => 'bar')));
+ self::assertEquals(1, $this->connection->insert('write_table', ['test_int' => 1, 'test_string' => 'foo']));
+ self::assertEquals(1, $this->connection->insert('write_table', ['test_int' => 2, 'test_string' => 'bar']));
}
public function testInsert()
@@ -123,56 +128,56 @@ public function testDelete()
{
$this->insertRows();
- self::assertEquals(1, $this->_conn->delete('write_table', array('test_int' => 2)));
- self::assertCount(1, $this->_conn->fetchAll('SELECT * FROM write_table'));
+ self::assertEquals(1, $this->connection->delete('write_table', ['test_int' => 2]));
+ self::assertCount(1, $this->connection->fetchAll('SELECT * FROM write_table'));
- self::assertEquals(1, $this->_conn->delete('write_table', array('test_int' => 1)));
- self::assertCount(0, $this->_conn->fetchAll('SELECT * FROM write_table'));
+ self::assertEquals(1, $this->connection->delete('write_table', ['test_int' => 1]));
+ self::assertCount(0, $this->connection->fetchAll('SELECT * FROM write_table'));
}
public function testUpdate()
{
$this->insertRows();
- self::assertEquals(1, $this->_conn->update('write_table', array('test_string' => 'bar'), array('test_string' => 'foo')));
- self::assertEquals(2, $this->_conn->update('write_table', array('test_string' => 'baz'), array('test_string' => 'bar')));
- self::assertEquals(0, $this->_conn->update('write_table', array('test_string' => 'baz'), array('test_string' => 'bar')));
+ self::assertEquals(1, $this->connection->update('write_table', ['test_string' => 'bar'], ['test_string' => 'foo']));
+ self::assertEquals(2, $this->connection->update('write_table', ['test_string' => 'baz'], ['test_string' => 'bar']));
+ self::assertEquals(0, $this->connection->update('write_table', ['test_string' => 'baz'], ['test_string' => 'bar']));
}
public function testLastInsertId()
{
- if ( ! $this->_conn->getDatabasePlatform()->prefersIdentityColumns()) {
+ if (! $this->connection->getDatabasePlatform()->prefersIdentityColumns()) {
$this->markTestSkipped('Test only works on platforms with identity columns.');
}
- self::assertEquals(1, $this->_conn->insert('write_table', array('test_int' => 2, 'test_string' => 'bar')));
- $num = $this->_conn->lastInsertId();
+ self::assertEquals(1, $this->connection->insert('write_table', ['test_int' => 2, 'test_string' => 'bar']));
+ $num = $this->connection->lastInsertId();
- self::assertNotNull($num, "LastInsertId() should not be null.");
- self::assertGreaterThan(0, $num, "LastInsertId() should be non-negative number.");
+ self::assertNotNull($num, 'LastInsertId() should not be null.');
+ self::assertGreaterThan(0, $num, 'LastInsertId() should be non-negative number.');
}
public function testLastInsertIdSequence()
{
- if ( ! $this->_conn->getDatabasePlatform()->supportsSequences()) {
+ if (! $this->connection->getDatabasePlatform()->supportsSequences()) {
$this->markTestSkipped('Test only works on platforms with sequences.');
}
- $sequence = new \Doctrine\DBAL\Schema\Sequence('write_table_id_seq');
+ $sequence = new Sequence('write_table_id_seq');
try {
- $this->_conn->getSchemaManager()->createSequence($sequence);
- } catch(\Exception $e) {
+ $this->connection->getSchemaManager()->createSequence($sequence);
+ } catch (Throwable $e) {
}
- $sequences = $this->_conn->getSchemaManager()->listSequences();
- self::assertCount(1, array_filter($sequences, function($sequence) {
+ $sequences = $this->connection->getSchemaManager()->listSequences();
+ self::assertCount(1, array_filter($sequences, static function ($sequence) {
return strtolower($sequence->getName()) === 'write_table_id_seq';
}));
- $stmt = $this->_conn->query($this->_conn->getDatabasePlatform()->getSequenceNextValSQL('write_table_id_seq'));
+ $stmt = $this->connection->query($this->connection->getDatabasePlatform()->getSequenceNextValSQL('write_table_id_seq'));
$nextSequenceVal = $stmt->fetchColumn();
- $lastInsertId = $this->_conn->lastInsertId('write_table_id_seq');
+ $lastInsertId = $this->connection->lastInsertId('write_table_id_seq');
self::assertGreaterThan(0, $lastInsertId);
self::assertEquals($nextSequenceVal, $lastInsertId);
@@ -180,12 +185,11 @@ public function testLastInsertIdSequence()
public function testLastInsertIdNoSequenceGiven()
{
- if ( ! $this->_conn->getDatabasePlatform()->supportsSequences() || $this->_conn->getDatabasePlatform()->supportsIdentityColumns()) {
+ if (! $this->connection->getDatabasePlatform()->supportsSequences() || $this->connection->getDatabasePlatform()->supportsIdentityColumns()) {
$this->markTestSkipped("Test only works consistently on platforms that support sequences and don't support identity columns.");
}
- self::assertFalse($this->_conn->lastInsertId( null ));
-
+ self::assertFalse($this->connection->lastInsertId(null));
}
/**
@@ -193,17 +197,17 @@ public function testLastInsertIdNoSequenceGiven()
*/
public function testInsertWithKeyValueTypes()
{
- $testString = new \DateTime('2013-04-14 10:10:10');
+ $testString = new DateTime('2013-04-14 10:10:10');
- $this->_conn->insert(
+ $this->connection->insert(
'write_table',
- array('test_int' => '30', 'test_string' => $testString),
- array('test_string' => 'datetime', 'test_int' => 'integer')
+ ['test_int' => '30', 'test_string' => $testString],
+ ['test_string' => 'datetime', 'test_int' => 'integer']
);
- $data = $this->_conn->fetchColumn('SELECT test_string FROM write_table WHERE test_int = 30');
+ $data = $this->connection->fetchColumn('SELECT test_string FROM write_table WHERE test_int = 30');
- self::assertEquals($testString->format($this->_conn->getDatabasePlatform()->getDateTimeFormatString()), $data);
+ self::assertEquals($testString->format($this->connection->getDatabasePlatform()->getDateTimeFormatString()), $data);
}
/**
@@ -211,26 +215,26 @@ public function testInsertWithKeyValueTypes()
*/
public function testUpdateWithKeyValueTypes()
{
- $testString = new \DateTime('2013-04-14 10:10:10');
+ $testString = new DateTime('2013-04-14 10:10:10');
- $this->_conn->insert(
+ $this->connection->insert(
'write_table',
- array('test_int' => '30', 'test_string' => $testString),
- array('test_string' => 'datetime', 'test_int' => 'integer')
+ ['test_int' => '30', 'test_string' => $testString],
+ ['test_string' => 'datetime', 'test_int' => 'integer']
);
- $testString = new \DateTime('2013-04-15 10:10:10');
+ $testString = new DateTime('2013-04-15 10:10:10');
- $this->_conn->update(
+ $this->connection->update(
'write_table',
- array('test_string' => $testString),
- array('test_int' => '30'),
- array('test_string' => 'datetime', 'test_int' => 'integer')
+ ['test_string' => $testString],
+ ['test_int' => '30'],
+ ['test_string' => 'datetime', 'test_int' => 'integer']
);
- $data = $this->_conn->fetchColumn('SELECT test_string FROM write_table WHERE test_int = 30');
+ $data = $this->connection->fetchColumn('SELECT test_string FROM write_table WHERE test_int = 30');
- self::assertEquals($testString->format($this->_conn->getDatabasePlatform()->getDateTimeFormatString()), $data);
+ self::assertEquals($testString->format($this->connection->getDatabasePlatform()->getDateTimeFormatString()), $data);
}
/**
@@ -238,40 +242,41 @@ public function testUpdateWithKeyValueTypes()
*/
public function testDeleteWithKeyValueTypes()
{
- $val = new \DateTime('2013-04-14 10:10:10');
- $this->_conn->insert(
+ $val = new DateTime('2013-04-14 10:10:10');
+ $this->connection->insert(
'write_table',
- array('test_int' => '30', 'test_string' => $val),
- array('test_string' => 'datetime', 'test_int' => 'integer')
+ ['test_int' => '30', 'test_string' => $val],
+ ['test_string' => 'datetime', 'test_int' => 'integer']
);
- $this->_conn->delete('write_table', array('test_int' => 30, 'test_string' => $val), array('test_string' => 'datetime', 'test_int' => 'integer'));
+ $this->connection->delete('write_table', ['test_int' => 30, 'test_string' => $val], ['test_string' => 'datetime', 'test_int' => 'integer']);
- $data = $this->_conn->fetchColumn('SELECT test_string FROM write_table WHERE test_int = 30');
+ $data = $this->connection->fetchColumn('SELECT test_string FROM write_table WHERE test_int = 30');
self::assertFalse($data);
}
public function testEmptyIdentityInsert()
{
- $platform = $this->_conn->getDatabasePlatform();
+ $platform = $this->connection->getDatabasePlatform();
- if ( ! ($platform->supportsIdentityColumns() || $platform->usesSequenceEmulatedIdentityColumns()) ) {
+ if (! ($platform->supportsIdentityColumns() || $platform->usesSequenceEmulatedIdentityColumns())) {
$this->markTestSkipped(
'Test only works on platforms with identity columns or sequence emulated identity columns.'
);
}
- $table = new \Doctrine\DBAL\Schema\Table('test_empty_identity');
- $table->addColumn('id', 'integer', array('autoincrement' => true));
- $table->setPrimaryKey(array('id'));
+ $table = new Table('test_empty_identity');
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
+ $table->setPrimaryKey(['id']);
try {
- $this->_conn->getSchemaManager()->dropTable($table->getQuotedName($platform));
- } catch(\Exception $e) { }
+ $this->connection->getSchemaManager()->dropTable($table->getQuotedName($platform));
+ } catch (Throwable $e) {
+ }
foreach ($platform->getCreateTableSQL($table) as $sql) {
- $this->_conn->exec($sql);
+ $this->connection->exec($sql);
}
$seqName = $platform->usesSequenceEmulatedIdentityColumns()
@@ -280,16 +285,15 @@ public function testEmptyIdentityInsert()
$sql = $platform->getEmptyIdentityInsertSQL('test_empty_identity', 'id');
- $this->_conn->exec($sql);
+ $this->connection->exec($sql);
- $firstId = $this->_conn->lastInsertId($seqName);
+ $firstId = $this->connection->lastInsertId($seqName);
- $this->_conn->exec($sql);
+ $this->connection->exec($sql);
- $secondId = $this->_conn->lastInsertId($seqName);
+ $secondId = $this->connection->lastInsertId($seqName);
self::assertGreaterThan($firstId, $secondId);
-
}
/**
@@ -297,38 +301,38 @@ public function testEmptyIdentityInsert()
*/
public function testUpdateWhereIsNull()
{
- $this->_conn->insert(
+ $this->connection->insert(
'write_table',
['test_int' => '30', 'test_string' => null],
['test_string' => 'string', 'test_int' => 'integer']
);
- $data = $this->_conn->fetchAll('SELECT * FROM write_table WHERE test_int = 30');
+ $data = $this->connection->fetchAll('SELECT * FROM write_table WHERE test_int = 30');
self::assertCount(1, $data);
- $this->_conn->update('write_table', ['test_int' => 10], ['test_string' => null], ['test_string' => 'string', 'test_int' => 'integer']);
+ $this->connection->update('write_table', ['test_int' => 10], ['test_string' => null], ['test_string' => 'string', 'test_int' => 'integer']);
- $data = $this->_conn->fetchAll('SELECT * FROM write_table WHERE test_int = 30');
+ $data = $this->connection->fetchAll('SELECT * FROM write_table WHERE test_int = 30');
self::assertCount(0, $data);
}
public function testDeleteWhereIsNull()
{
- $this->_conn->insert(
+ $this->connection->insert(
'write_table',
['test_int' => '30', 'test_string' => null],
['test_string' => 'string', 'test_int' => 'integer']
);
- $data = $this->_conn->fetchAll('SELECT * FROM write_table WHERE test_int = 30');
+ $data = $this->connection->fetchAll('SELECT * FROM write_table WHERE test_int = 30');
self::assertCount(1, $data);
- $this->_conn->delete('write_table', ['test_string' => null], ['test_string' => 'string']);
+ $this->connection->delete('write_table', ['test_string' => null], ['test_string' => 'string']);
- $data = $this->_conn->fetchAll('SELECT * FROM write_table WHERE test_int = 30');
+ $data = $this->connection->fetchAll('SELECT * FROM write_table WHERE test_int = 30');
self::assertCount(0, $data);
}
diff --git a/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php b/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php
index 8d9595f1ec5..914351c75dc 100644
--- a/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php
+++ b/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php
@@ -3,8 +3,9 @@
namespace Doctrine\Tests\DBAL\Logging;
use Doctrine\DBAL\Logging\DebugStack;
+use Doctrine\Tests\DbalTestCase;
-class DebugStackTest extends \Doctrine\Tests\DbalTestCase
+class DebugStackTest extends DbalTestCase
{
/** @var DebugStack */
private $logger;
@@ -23,14 +24,14 @@ public function testLoggedQuery()
{
$this->logger->startQuery('SELECT column FROM table');
self::assertEquals(
- array(
- 1 => array(
+ [
+ 1 => [
'sql' => 'SELECT column FROM table',
'params' => null,
'types' => null,
'executionMS' => 0,
- ),
- ),
+ ],
+ ],
$this->logger->queries
);
@@ -42,9 +43,9 @@ public function testLoggedQueryDisabled()
{
$this->logger->enabled = false;
$this->logger->startQuery('SELECT column FROM table');
- self::assertEquals(array(), $this->logger->queries);
+ self::assertEquals([], $this->logger->queries);
$this->logger->stopQuery();
- self::assertEquals(array(), $this->logger->queries);
+ self::assertEquals([], $this->logger->queries);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php b/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php
index 3f8f0477cc2..6a3f3d8e376 100644
--- a/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php
+++ b/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php
@@ -8,25 +8,59 @@
class MockPlatform extends AbstractPlatform
{
/**
- * Gets the SQL Snippet used to declare a BLOB column type.
+ * {@inheritDoc}
*/
public function getBlobTypeDeclarationSQL(array $field)
{
throw DBALException::notSupported(__METHOD__);
}
- public function getBooleanTypeDeclarationSQL(array $columnDef) {}
- public function getIntegerTypeDeclarationSQL(array $columnDef) {}
- public function getBigIntTypeDeclarationSQL(array $columnDef) {}
- public function getSmallIntTypeDeclarationSQL(array $columnDef) {}
- public function _getCommonIntegerTypeDeclarationSQL(array $columnDef) {}
+ /**
+ * {@inheritDoc}
+ */
+ public function getBooleanTypeDeclarationSQL(array $columnDef)
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getIntegerTypeDeclarationSQL(array $columnDef)
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getBigIntTypeDeclarationSQL(array $columnDef)
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getSmallIntTypeDeclarationSQL(array $columnDef)
+ {
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public function getVarcharTypeDeclarationSQL(array $field)
{
- return "DUMMYVARCHAR()";
+ return 'DUMMYVARCHAR()';
}
- /** @override */
+ /**
+ * {@inheritDoc}
+ */
public function getClobTypeDeclarationSQL(array $field)
{
return 'DUMMYCLOB';
@@ -57,10 +91,10 @@ public function getName()
{
return 'mock';
}
- protected function initializeDoctrineTypeMappings() {
+ protected function initializeDoctrineTypeMappings()
+ {
}
protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed)
{
-
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php b/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php
index 42c549aa399..c4efa1b8377 100644
--- a/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php
+++ b/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php
@@ -2,26 +2,28 @@
namespace Doctrine\Tests\DBAL\Performance;
+use DateTime;
+use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalPerformanceTestCase;
/**
* Class TypeConversionPerformanceTest
- * @package Doctrine\Tests\DBAL\Performance
- * @author Bill Schaller
+ *
* @group performance
*/
class TypeConversionPerformanceTest extends DbalPerformanceTestCase
{
/**
- * @throws \Doctrine\DBAL\DBALException
+ * @throws DBALException
+ *
* @dataProvider itemCountProvider
*/
public function testDateTimeTypeConversionPerformance($count)
{
- $value = new \DateTime;
- $type = Type::getType("datetime");
- $platform = $this->_conn->getDatabasePlatform();
+ $value = new DateTime();
+ $type = Type::getType('datetime');
+ $platform = $this->connection->getDatabasePlatform();
$this->startTiming();
for ($i = 0; $i < $count; $i++) {
$type->convertToDatabaseValue($value, $platform);
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
index b8fcfb35ede..63148215f22 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
@@ -15,16 +15,16 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
{
public function testModifyLimitQueryWitoutLimit()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT n FROM Foo', null , 10);
- self::assertEquals('SELECT n FROM Foo LIMIT 18446744073709551615 OFFSET 10',$sql);
+ $sql = $this->platform->modifyLimitQuery('SELECT n FROM Foo', null, 10);
+ self::assertEquals('SELECT n FROM Foo LIMIT 18446744073709551615 OFFSET 10', $sql);
}
public function testGenerateMixedCaseTableCreate()
{
- $table = new Table("Foo");
- $table->addColumn("Bar", "integer");
+ $table = new Table('Foo');
+ $table->addColumn('Bar', 'integer');
- $sql = $this->_platform->getCreateTableSQL($table);
+ $sql = $this->platform->getCreateTableSQL($table);
self::assertEquals('CREATE TABLE Foo (Bar INT NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB', array_shift($sql));
}
@@ -35,104 +35,102 @@ public function getGenerateTableSql()
public function getGenerateTableWithMultiColumnUniqueIndexSql()
{
- return array(
- 'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA (foo, bar)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
- );
+ return ['CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA (foo, bar)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'];
}
public function getGenerateAlterTableSql()
{
- return array(
- "ALTER TABLE mytable RENAME TO userlist, ADD quota INT DEFAULT NULL, DROP foo, CHANGE bar baz VARCHAR(255) DEFAULT 'def' NOT NULL, CHANGE bloo bloo TINYINT(1) DEFAULT '0' NOT NULL"
- );
+ return ["ALTER TABLE mytable RENAME TO userlist, ADD quota INT DEFAULT NULL, DROP foo, CHANGE bar baz VARCHAR(255) DEFAULT 'def' NOT NULL, CHANGE bloo bloo TINYINT(1) DEFAULT '0' NOT NULL"];
}
public function testGeneratesSqlSnippets()
{
- self::assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct');
- self::assertEquals('`', $this->_platform->getIdentifierQuoteCharacter(), 'Quote character is not correct');
- self::assertEquals('CONCAT(column1, column2, column3)', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation function is not correct');
+ self::assertEquals('RLIKE', $this->platform->getRegexpExpression(), 'Regular expression operator is not correct');
+ self::assertEquals('`', $this->platform->getIdentifierQuoteCharacter(), 'Quote character is not correct');
+ self::assertEquals('CONCAT(column1, column2, column3)', $this->platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation function is not correct');
}
public function testGeneratesTransactionsCommands()
{
self::assertEquals(
'SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_UNCOMMITTED),
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_UNCOMMITTED),
''
);
self::assertEquals(
'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_COMMITTED)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_COMMITTED)
);
self::assertEquals(
'SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::REPEATABLE_READ)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::REPEATABLE_READ)
);
self::assertEquals(
'SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::SERIALIZABLE)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::SERIALIZABLE)
);
}
public function testGeneratesDDLSnippets()
{
- self::assertEquals('SHOW DATABASES', $this->_platform->getListDatabasesSQL());
- self::assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar'));
- self::assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSQL('foobar'));
- self::assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));
+ self::assertEquals('SHOW DATABASES', $this->platform->getListDatabasesSQL());
+ self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar'));
+ self::assertEquals('DROP DATABASE foobar', $this->platform->getDropDatabaseSQL('foobar'));
+ self::assertEquals('DROP TABLE foobar', $this->platform->getDropTableSQL('foobar'));
}
public function testGeneratesTypeDeclarationForIntegers()
{
self::assertEquals(
'INT',
- $this->_platform->getIntegerTypeDeclarationSQL(array())
+ $this->platform->getIntegerTypeDeclarationSQL([])
);
self::assertEquals(
'INT AUTO_INCREMENT',
- $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)
- ));
+ $this->platform->getIntegerTypeDeclarationSQL(['autoincrement' => true])
+ );
self::assertEquals(
'INT AUTO_INCREMENT',
- $this->_platform->getIntegerTypeDeclarationSQL(
- array('autoincrement' => true, 'primary' => true)
- ));
+ $this->platform->getIntegerTypeDeclarationSQL(
+ ['autoincrement' => true, 'primary' => true]
+ )
+ );
}
public function testGeneratesTypeDeclarationForStrings()
{
self::assertEquals(
'CHAR(10)',
- $this->_platform->getVarcharTypeDeclarationSQL(
- array('length' => 10, 'fixed' => true)
- ));
+ $this->platform->getVarcharTypeDeclarationSQL(
+ ['length' => 10, 'fixed' => true]
+ )
+ );
self::assertEquals(
'VARCHAR(50)',
- $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
+ $this->platform->getVarcharTypeDeclarationSQL(['length' => 50]),
'Variable string declaration is not correct'
);
self::assertEquals(
'VARCHAR(255)',
- $this->_platform->getVarcharTypeDeclarationSQL(array()),
+ $this->platform->getVarcharTypeDeclarationSQL([]),
'Long string declaration is not correct'
);
}
public function testPrefersIdentityColumns()
{
- self::assertTrue($this->_platform->prefersIdentityColumns());
+ self::assertTrue($this->platform->prefersIdentityColumns());
}
public function testSupportsIdentityColumns()
{
- self::assertTrue($this->_platform->supportsIdentityColumns());
+ self::assertTrue($this->platform->supportsIdentityColumns());
}
public function testDoesSupportSavePoints()
{
- self::assertTrue($this->_platform->supportsSavepoints());
+ self::assertTrue($this->platform->supportsSavepoints());
}
public function getGenerateIndexSql()
@@ -155,36 +153,36 @@ public function getGenerateForeignKeySql()
*/
public function testUniquePrimaryKey()
{
- $keyTable = new Table("foo");
- $keyTable->addColumn("bar", "integer");
- $keyTable->addColumn("baz", "string");
- $keyTable->setPrimaryKey(array("bar"));
- $keyTable->addUniqueIndex(array("baz"));
+ $keyTable = new Table('foo');
+ $keyTable->addColumn('bar', 'integer');
+ $keyTable->addColumn('baz', 'string');
+ $keyTable->setPrimaryKey(['bar']);
+ $keyTable->addUniqueIndex(['baz']);
- $oldTable = new Table("foo");
- $oldTable->addColumn("bar", "integer");
- $oldTable->addColumn("baz", "string");
+ $oldTable = new Table('foo');
+ $oldTable->addColumn('bar', 'integer');
+ $oldTable->addColumn('baz', 'string');
- $c = new \Doctrine\DBAL\Schema\Comparator;
+ $c = new Comparator();
$diff = $c->diffTable($oldTable, $keyTable);
- $sql = $this->_platform->getAlterTableSQL($diff);
+ $sql = $this->platform->getAlterTableSQL($diff);
- self::assertEquals(array(
- "ALTER TABLE foo ADD PRIMARY KEY (bar)",
- "CREATE UNIQUE INDEX UNIQ_8C73652178240498 ON foo (baz)",
- ), $sql);
+ self::assertEquals([
+ 'ALTER TABLE foo ADD PRIMARY KEY (bar)',
+ 'CREATE UNIQUE INDEX UNIQ_8C73652178240498 ON foo (baz)',
+ ], $sql);
}
public function testModifyLimitQuery()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
self::assertEquals('SELECT * FROM user LIMIT 10', $sql);
}
public function testModifyLimitQueryWithEmptyOffset()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10);
self::assertEquals('SELECT * FROM user LIMIT 10', $sql);
}
@@ -193,24 +191,24 @@ public function testModifyLimitQueryWithEmptyOffset()
*/
public function testGetDateTimeTypeDeclarationSql()
{
- self::assertEquals("DATETIME", $this->_platform->getDateTimeTypeDeclarationSQL(array('version' => false)));
- self::assertEquals("TIMESTAMP", $this->_platform->getDateTimeTypeDeclarationSQL(array('version' => true)));
- self::assertEquals("DATETIME", $this->_platform->getDateTimeTypeDeclarationSQL(array()));
+ self::assertEquals('DATETIME', $this->platform->getDateTimeTypeDeclarationSQL(['version' => false]));
+ self::assertEquals('TIMESTAMP', $this->platform->getDateTimeTypeDeclarationSQL(['version' => true]));
+ self::assertEquals('DATETIME', $this->platform->getDateTimeTypeDeclarationSQL([]));
}
public function getCreateTableColumnCommentsSQL()
{
- return array("CREATE TABLE test (id INT NOT NULL COMMENT 'This is a comment', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
+ return ["CREATE TABLE test (id INT NOT NULL COMMENT 'This is a comment', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB"];
}
public function getAlterTableColumnCommentsSQL()
{
- return array("ALTER TABLE mytable ADD quota INT NOT NULL COMMENT 'A comment', CHANGE foo foo VARCHAR(255) NOT NULL, CHANGE bar baz VARCHAR(255) NOT NULL COMMENT 'B comment'");
+ return ["ALTER TABLE mytable ADD quota INT NOT NULL COMMENT 'A comment', CHANGE foo foo VARCHAR(255) NOT NULL, CHANGE bar baz VARCHAR(255) NOT NULL COMMENT 'B comment'"];
}
public function getCreateTableColumnTypeCommentsSQL()
{
- return array("CREATE TABLE test (id INT NOT NULL, data LONGTEXT NOT NULL COMMENT '(DC2Type:array)', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
+ return ["CREATE TABLE test (id INT NOT NULL, data LONGTEXT NOT NULL COMMENT '(DC2Type:array)', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB"];
}
/**
@@ -218,47 +216,41 @@ public function getCreateTableColumnTypeCommentsSQL()
*/
public function testChangeIndexWithForeignKeys()
{
- $index = new Index("idx", array("col"), false);
- $unique = new Index("uniq", array("col"), true);
+ $index = new Index('idx', ['col'], false);
+ $unique = new Index('uniq', ['col'], true);
- $diff = new TableDiff("test", array(), array(), array(), array($unique), array(), array($index));
- $sql = $this->_platform->getAlterTableSQL($diff);
- self::assertEquals(array("ALTER TABLE test DROP INDEX idx, ADD UNIQUE INDEX uniq (col)"), $sql);
+ $diff = new TableDiff('test', [], [], [], [$unique], [], [$index]);
+ $sql = $this->platform->getAlterTableSQL($diff);
+ self::assertEquals(['ALTER TABLE test DROP INDEX idx, ADD UNIQUE INDEX uniq (col)'], $sql);
- $diff = new TableDiff("test", array(), array(), array(), array($index), array(), array($unique));
- $sql = $this->_platform->getAlterTableSQL($diff);
- self::assertEquals(array("ALTER TABLE test DROP INDEX uniq, ADD INDEX idx (col)"), $sql);
+ $diff = new TableDiff('test', [], [], [], [$index], [], [$unique]);
+ $sql = $this->platform->getAlterTableSQL($diff);
+ self::assertEquals(['ALTER TABLE test DROP INDEX uniq, ADD INDEX idx (col)'], $sql);
}
protected function getQuotedColumnInPrimaryKeySQL()
{
- return array(
- 'CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, PRIMARY KEY(`create`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
- );
+ return ['CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, PRIMARY KEY(`create`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'];
}
protected function getQuotedColumnInIndexSQL()
{
- return array(
- 'CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, INDEX IDX_22660D028FD6E0FB (`create`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
- );
+ return ['CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, INDEX IDX_22660D028FD6E0FB (`create`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'];
}
protected function getQuotedNameInIndexSQL()
{
- return array(
- 'CREATE TABLE test (column1 VARCHAR(255) NOT NULL, INDEX `key` (column1)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
- );
+ return ['CREATE TABLE test (column1 VARCHAR(255) NOT NULL, INDEX `key` (column1)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'];
}
protected function getQuotedColumnInForeignKeySQL()
{
- return array(
+ return [
'CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, `bar` VARCHAR(255) NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
'ALTER TABLE `quoted` ADD CONSTRAINT FK_WITH_RESERVED_KEYWORD FOREIGN KEY (`create`, foo, `bar`) REFERENCES `foreign` (`create`, bar, `foo-bar`)',
'ALTER TABLE `quoted` ADD CONSTRAINT FK_WITH_NON_RESERVED_KEYWORD FOREIGN KEY (`create`, foo, `bar`) REFERENCES foo (`create`, bar, `foo-bar`)',
'ALTER TABLE `quoted` ADD CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY (`create`, foo, `bar`) REFERENCES `foo-bar` (`create`, bar, `foo-bar`)',
- );
+ ];
}
public function testCreateTableWithFulltextIndex()
@@ -266,13 +258,13 @@ public function testCreateTableWithFulltextIndex()
$table = new Table('fulltext_table');
$table->addOption('engine', 'MyISAM');
$table->addColumn('text', 'text');
- $table->addIndex(array('text'), 'fulltext_text');
+ $table->addIndex(['text'], 'fulltext_text');
$index = $table->getIndex('fulltext_text');
$index->addFlag('fulltext');
- $sql = $this->_platform->getCreateTableSQL($table);
- self::assertEquals(array('CREATE TABLE fulltext_table (text LONGTEXT NOT NULL, FULLTEXT INDEX fulltext_text (text)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = MyISAM'), $sql);
+ $sql = $this->platform->getCreateTableSQL($table);
+ self::assertEquals(['CREATE TABLE fulltext_table (text LONGTEXT NOT NULL, FULLTEXT INDEX fulltext_text (text)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = MyISAM'], $sql);
}
public function testCreateTableWithSpatialIndex()
@@ -280,37 +272,37 @@ public function testCreateTableWithSpatialIndex()
$table = new Table('spatial_table');
$table->addOption('engine', 'MyISAM');
$table->addColumn('point', 'text'); // This should be a point type
- $table->addIndex(array('point'), 'spatial_text');
+ $table->addIndex(['point'], 'spatial_text');
$index = $table->getIndex('spatial_text');
$index->addFlag('spatial');
- $sql = $this->_platform->getCreateTableSQL($table);
- self::assertEquals(array('CREATE TABLE spatial_table (point LONGTEXT NOT NULL, SPATIAL INDEX spatial_text (point)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = MyISAM'), $sql);
+ $sql = $this->platform->getCreateTableSQL($table);
+ self::assertEquals(['CREATE TABLE spatial_table (point LONGTEXT NOT NULL, SPATIAL INDEX spatial_text (point)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = MyISAM'], $sql);
}
public function testClobTypeDeclarationSQL()
{
- self::assertEquals('TINYTEXT', $this->_platform->getClobTypeDeclarationSQL(array('length' => 1)));
- self::assertEquals('TINYTEXT', $this->_platform->getClobTypeDeclarationSQL(array('length' => 255)));
- self::assertEquals('TEXT', $this->_platform->getClobTypeDeclarationSQL(array('length' => 256)));
- self::assertEquals('TEXT', $this->_platform->getClobTypeDeclarationSQL(array('length' => 65535)));
- self::assertEquals('MEDIUMTEXT', $this->_platform->getClobTypeDeclarationSQL(array('length' => 65536)));
- self::assertEquals('MEDIUMTEXT', $this->_platform->getClobTypeDeclarationSQL(array('length' => 16777215)));
- self::assertEquals('LONGTEXT', $this->_platform->getClobTypeDeclarationSQL(array('length' => 16777216)));
- self::assertEquals('LONGTEXT', $this->_platform->getClobTypeDeclarationSQL(array()));
+ self::assertEquals('TINYTEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 1]));
+ self::assertEquals('TINYTEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 255]));
+ self::assertEquals('TEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 256]));
+ self::assertEquals('TEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 65535]));
+ self::assertEquals('MEDIUMTEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 65536]));
+ self::assertEquals('MEDIUMTEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 16777215]));
+ self::assertEquals('LONGTEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 16777216]));
+ self::assertEquals('LONGTEXT', $this->platform->getClobTypeDeclarationSQL([]));
}
public function testBlobTypeDeclarationSQL()
{
- self::assertEquals('TINYBLOB', $this->_platform->getBlobTypeDeclarationSQL(array('length' => 1)));
- self::assertEquals('TINYBLOB', $this->_platform->getBlobTypeDeclarationSQL(array('length' => 255)));
- self::assertEquals('BLOB', $this->_platform->getBlobTypeDeclarationSQL(array('length' => 256)));
- self::assertEquals('BLOB', $this->_platform->getBlobTypeDeclarationSQL(array('length' => 65535)));
- self::assertEquals('MEDIUMBLOB', $this->_platform->getBlobTypeDeclarationSQL(array('length' => 65536)));
- self::assertEquals('MEDIUMBLOB', $this->_platform->getBlobTypeDeclarationSQL(array('length' => 16777215)));
- self::assertEquals('LONGBLOB', $this->_platform->getBlobTypeDeclarationSQL(array('length' => 16777216)));
- self::assertEquals('LONGBLOB', $this->_platform->getBlobTypeDeclarationSQL(array()));
+ self::assertEquals('TINYBLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 1]));
+ self::assertEquals('TINYBLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 255]));
+ self::assertEquals('BLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 256]));
+ self::assertEquals('BLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 65535]));
+ self::assertEquals('MEDIUMBLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 65536]));
+ self::assertEquals('MEDIUMBLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 16777215]));
+ self::assertEquals('LONGBLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 16777216]));
+ self::assertEquals('LONGBLOB', $this->platform->getBlobTypeDeclarationSQL([]));
}
/**
@@ -321,17 +313,17 @@ public function testAlterTableAddPrimaryKey()
$table = new Table('alter_table_add_pk');
$table->addColumn('id', 'integer');
$table->addColumn('foo', 'integer');
- $table->addIndex(array('id'), 'idx_id');
+ $table->addIndex(['id'], 'idx_id');
$comparator = new Comparator();
$diffTable = clone $table;
$diffTable->dropIndex('idx_id');
- $diffTable->setPrimaryKey(array('id'));
+ $diffTable->setPrimaryKey(['id']);
self::assertEquals(
- array('DROP INDEX idx_id ON alter_table_add_pk', 'ALTER TABLE alter_table_add_pk ADD PRIMARY KEY (id)'),
- $this->_platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
+ ['DROP INDEX idx_id ON alter_table_add_pk', 'ALTER TABLE alter_table_add_pk ADD PRIMARY KEY (id)'],
+ $this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
);
}
@@ -340,24 +332,24 @@ public function testAlterTableAddPrimaryKey()
*/
public function testAlterPrimaryKeyWithAutoincrementColumn()
{
- $table = new Table("alter_primary_key");
- $table->addColumn('id', 'integer', array('autoincrement' => true));
+ $table = new Table('alter_primary_key');
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('foo', 'integer');
- $table->setPrimaryKey(array('id'));
+ $table->setPrimaryKey(['id']);
$comparator = new Comparator();
- $diffTable = clone $table;
+ $diffTable = clone $table;
$diffTable->dropPrimaryKey();
- $diffTable->setPrimaryKey(array('foo'));
+ $diffTable->setPrimaryKey(['foo']);
self::assertEquals(
- array(
+ [
'ALTER TABLE alter_primary_key MODIFY id INT NOT NULL',
'ALTER TABLE alter_primary_key DROP PRIMARY KEY',
- 'ALTER TABLE alter_primary_key ADD PRIMARY KEY (foo)'
- ),
- $this->_platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
+ 'ALTER TABLE alter_primary_key ADD PRIMARY KEY (foo)',
+ ],
+ $this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
);
}
@@ -366,23 +358,23 @@ public function testAlterPrimaryKeyWithAutoincrementColumn()
*/
public function testDropPrimaryKeyWithAutoincrementColumn()
{
- $table = new Table("drop_primary_key");
- $table->addColumn('id', 'integer', array('autoincrement' => true));
+ $table = new Table('drop_primary_key');
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('foo', 'integer');
$table->addColumn('bar', 'integer');
- $table->setPrimaryKey(array('id', 'foo'));
+ $table->setPrimaryKey(['id', 'foo']);
$comparator = new Comparator();
- $diffTable = clone $table;
+ $diffTable = clone $table;
$diffTable->dropPrimaryKey();
self::assertEquals(
- array(
+ [
'ALTER TABLE drop_primary_key MODIFY id INT NOT NULL',
- 'ALTER TABLE drop_primary_key DROP PRIMARY KEY'
- ),
- $this->_platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
+ 'ALTER TABLE drop_primary_key DROP PRIMARY KEY',
+ ],
+ $this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
);
}
@@ -391,25 +383,25 @@ public function testDropPrimaryKeyWithAutoincrementColumn()
*/
public function testDropNonAutoincrementColumnFromCompositePrimaryKeyWithAutoincrementColumn()
{
- $table = new Table("tbl");
- $table->addColumn('id', 'integer', array('autoincrement' => true));
+ $table = new Table('tbl');
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('foo', 'integer');
$table->addColumn('bar', 'integer');
- $table->setPrimaryKey(array('id', 'foo'));
+ $table->setPrimaryKey(['id', 'foo']);
$comparator = new Comparator();
- $diffTable = clone $table;
+ $diffTable = clone $table;
$diffTable->dropPrimaryKey();
- $diffTable->setPrimaryKey(array('id'));
+ $diffTable->setPrimaryKey(['id']);
self::assertSame(
- array(
+ [
'ALTER TABLE tbl MODIFY id INT NOT NULL',
'ALTER TABLE tbl DROP PRIMARY KEY',
'ALTER TABLE tbl ADD PRIMARY KEY (id)',
- ),
- $this->_platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
+ ],
+ $this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
);
}
@@ -418,25 +410,25 @@ public function testDropNonAutoincrementColumnFromCompositePrimaryKeyWithAutoinc
*/
public function testAddNonAutoincrementColumnToPrimaryKeyWithAutoincrementColumn()
{
- $table = new Table("tbl");
- $table->addColumn('id', 'integer', array('autoincrement' => true));
+ $table = new Table('tbl');
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('foo', 'integer');
$table->addColumn('bar', 'integer');
- $table->setPrimaryKey(array('id'));
+ $table->setPrimaryKey(['id']);
$comparator = new Comparator();
- $diffTable = clone $table;
+ $diffTable = clone $table;
$diffTable->dropPrimaryKey();
- $diffTable->setPrimaryKey(array('id', 'foo'));
+ $diffTable->setPrimaryKey(['id', 'foo']);
self::assertSame(
- array(
+ [
'ALTER TABLE tbl MODIFY id INT NOT NULL',
'ALTER TABLE tbl DROP PRIMARY KEY',
'ALTER TABLE tbl ADD PRIMARY KEY (id, foo)',
- ),
- $this->_platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
+ ],
+ $this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
);
}
@@ -445,68 +437,66 @@ public function testAddNonAutoincrementColumnToPrimaryKeyWithAutoincrementColumn
*/
public function testAddAutoIncrementPrimaryKey()
{
- $keyTable = new Table("foo");
- $keyTable->addColumn("id", "integer", array('autoincrement' => true));
- $keyTable->addColumn("baz", "string");
- $keyTable->setPrimaryKey(array("id"));
+ $keyTable = new Table('foo');
+ $keyTable->addColumn('id', 'integer', ['autoincrement' => true]);
+ $keyTable->addColumn('baz', 'string');
+ $keyTable->setPrimaryKey(['id']);
- $oldTable = new Table("foo");
- $oldTable->addColumn("baz", "string");
+ $oldTable = new Table('foo');
+ $oldTable->addColumn('baz', 'string');
- $c = new \Doctrine\DBAL\Schema\Comparator;
+ $c = new Comparator();
$diff = $c->diffTable($oldTable, $keyTable);
- $sql = $this->_platform->getAlterTableSQL($diff);
+ $sql = $this->platform->getAlterTableSQL($diff);
- self::assertEquals(array(
- "ALTER TABLE foo ADD id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)",
- ), $sql);
+ self::assertEquals(['ALTER TABLE foo ADD id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)'], $sql);
}
public function testNamedPrimaryKey()
{
- $diff = new TableDiff('mytable');
- $diff->changedIndexes['foo_index'] = new Index('foo_index', array('foo'), true, true);
+ $diff = new TableDiff('mytable');
+ $diff->changedIndexes['foo_index'] = new Index('foo_index', ['foo'], true, true);
- $sql = $this->_platform->getAlterTableSQL($diff);
+ $sql = $this->platform->getAlterTableSQL($diff);
- self::assertEquals(array(
- "ALTER TABLE mytable DROP PRIMARY KEY",
- "ALTER TABLE mytable ADD PRIMARY KEY (foo)",
- ), $sql);
+ self::assertEquals([
+ 'ALTER TABLE mytable DROP PRIMARY KEY',
+ 'ALTER TABLE mytable ADD PRIMARY KEY (foo)',
+ ], $sql);
}
public function testAlterPrimaryKeyWithNewColumn()
{
- $table = new Table("yolo");
+ $table = new Table('yolo');
$table->addColumn('pkc1', 'integer');
$table->addColumn('col_a', 'integer');
- $table->setPrimaryKey(array('pkc1'));
+ $table->setPrimaryKey(['pkc1']);
$comparator = new Comparator();
- $diffTable = clone $table;
+ $diffTable = clone $table;
$diffTable->addColumn('pkc2', 'integer');
$diffTable->dropPrimaryKey();
- $diffTable->setPrimaryKey(array('pkc1', 'pkc2'));
+ $diffTable->setPrimaryKey(['pkc1', 'pkc2']);
self::assertSame(
- array(
+ [
'ALTER TABLE yolo DROP PRIMARY KEY',
'ALTER TABLE yolo ADD pkc2 INT NOT NULL',
'ALTER TABLE yolo ADD PRIMARY KEY (pkc1, pkc2)',
- ),
- $this->_platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
+ ],
+ $this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
);
}
public function testInitializesDoctrineTypeMappings()
{
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('binary'));
- self::assertSame('binary', $this->_platform->getDoctrineTypeMapping('binary'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('binary'));
+ self::assertSame('binary', $this->platform->getDoctrineTypeMapping('binary'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('varbinary'));
- self::assertSame('binary', $this->_platform->getDoctrineTypeMapping('varbinary'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('varbinary'));
+ self::assertSame('binary', $this->platform->getDoctrineTypeMapping('varbinary'));
}
protected function getBinaryMaxLength()
@@ -516,13 +506,13 @@ protected function getBinaryMaxLength()
public function testReturnsBinaryTypeDeclarationSQL()
{
- self::assertSame('VARBINARY(255)', $this->_platform->getBinaryTypeDeclarationSQL(array()));
- self::assertSame('VARBINARY(255)', $this->_platform->getBinaryTypeDeclarationSQL(array('length' => 0)));
- self::assertSame('VARBINARY(65535)', $this->_platform->getBinaryTypeDeclarationSQL(array('length' => 65535)));
+ self::assertSame('VARBINARY(255)', $this->platform->getBinaryTypeDeclarationSQL([]));
+ self::assertSame('VARBINARY(255)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0]));
+ self::assertSame('VARBINARY(65535)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 65535]));
- self::assertSame('BINARY(255)', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true)));
- self::assertSame('BINARY(255)', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true, 'length' => 0)));
- self::assertSame('BINARY(65535)', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true, 'length' => 65535)));
+ self::assertSame('BINARY(255)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true]));
+ self::assertSame('BINARY(255)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 0]));
+ self::assertSame('BINARY(65535)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 65535]));
}
/**
@@ -533,27 +523,27 @@ public function testReturnsBinaryTypeDeclarationSQL()
*/
public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL()
{
- self::assertSame('MEDIUMBLOB', $this->_platform->getBinaryTypeDeclarationSQL(['length' => 65536]));
- self::assertSame('MEDIUMBLOB', $this->_platform->getBinaryTypeDeclarationSQL(['length' => 16777215]));
- self::assertSame('LONGBLOB', $this->_platform->getBinaryTypeDeclarationSQL(['length' => 16777216]));
+ self::assertSame('MEDIUMBLOB', $this->platform->getBinaryTypeDeclarationSQL(['length' => 65536]));
+ self::assertSame('MEDIUMBLOB', $this->platform->getBinaryTypeDeclarationSQL(['length' => 16777215]));
+ self::assertSame('LONGBLOB', $this->platform->getBinaryTypeDeclarationSQL(['length' => 16777216]));
- self::assertSame('MEDIUMBLOB', $this->_platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 65536]));
- self::assertSame('MEDIUMBLOB', $this->_platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 16777215]));
- self::assertSame('LONGBLOB', $this->_platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 16777216]));
+ self::assertSame('MEDIUMBLOB', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 65536]));
+ self::assertSame('MEDIUMBLOB', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 16777215]));
+ self::assertSame('LONGBLOB', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 16777216]));
}
public function testDoesNotPropagateForeignKeyCreationForNonSupportingEngines()
{
- $table = new Table("foreign_table");
+ $table = new Table('foreign_table');
$table->addColumn('id', 'integer');
$table->addColumn('fk_id', 'integer');
- $table->addForeignKeyConstraint('foreign_table', array('fk_id'), array('id'));
- $table->setPrimaryKey(array('id'));
+ $table->addForeignKeyConstraint('foreign_table', ['fk_id'], ['id']);
+ $table->setPrimaryKey(['id']);
$table->addOption('engine', 'MyISAM');
self::assertSame(
- array('CREATE TABLE foreign_table (id INT NOT NULL, fk_id INT NOT NULL, INDEX IDX_5690FFE2A57719D0 (fk_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = MyISAM'),
- $this->_platform->getCreateTableSQL(
+ ['CREATE TABLE foreign_table (id INT NOT NULL, fk_id INT NOT NULL, INDEX IDX_5690FFE2A57719D0 (fk_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = MyISAM'],
+ $this->platform->getCreateTableSQL(
$table,
AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS
)
@@ -563,11 +553,11 @@ public function testDoesNotPropagateForeignKeyCreationForNonSupportingEngines()
$table->addOption('engine', 'InnoDB');
self::assertSame(
- array(
+ [
'CREATE TABLE foreign_table (id INT NOT NULL, fk_id INT NOT NULL, INDEX IDX_5690FFE2A57719D0 (fk_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
- 'ALTER TABLE foreign_table ADD CONSTRAINT FK_5690FFE2A57719D0 FOREIGN KEY (fk_id) REFERENCES foreign_table (id)'
- ),
- $this->_platform->getCreateTableSQL(
+ 'ALTER TABLE foreign_table ADD CONSTRAINT FK_5690FFE2A57719D0 FOREIGN KEY (fk_id) REFERENCES foreign_table (id)',
+ ],
+ $this->platform->getCreateTableSQL(
$table,
AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS
)
@@ -576,41 +566,41 @@ public function testDoesNotPropagateForeignKeyCreationForNonSupportingEngines()
public function testDoesNotPropagateForeignKeyAlterationForNonSupportingEngines()
{
- $table = new Table("foreign_table");
+ $table = new Table('foreign_table');
$table->addColumn('id', 'integer');
$table->addColumn('fk_id', 'integer');
- $table->addForeignKeyConstraint('foreign_table', array('fk_id'), array('id'));
- $table->setPrimaryKey(array('id'));
+ $table->addForeignKeyConstraint('foreign_table', ['fk_id'], ['id']);
+ $table->setPrimaryKey(['id']);
$table->addOption('engine', 'MyISAM');
- $addedForeignKeys = array(new ForeignKeyConstraint(array('fk_id'), 'foo', array('id'), 'fk_add'));
- $changedForeignKeys = array(new ForeignKeyConstraint(array('fk_id'), 'bar', array('id'), 'fk_change'));
- $removedForeignKeys = array(new ForeignKeyConstraint(array('fk_id'), 'baz', array('id'), 'fk_remove'));
+ $addedForeignKeys = [new ForeignKeyConstraint(['fk_id'], 'foo', ['id'], 'fk_add')];
+ $changedForeignKeys = [new ForeignKeyConstraint(['fk_id'], 'bar', ['id'], 'fk_change')];
+ $removedForeignKeys = [new ForeignKeyConstraint(['fk_id'], 'baz', ['id'], 'fk_remove')];
- $tableDiff = new TableDiff('foreign_table');
- $tableDiff->fromTable = $table;
- $tableDiff->addedForeignKeys = $addedForeignKeys;
+ $tableDiff = new TableDiff('foreign_table');
+ $tableDiff->fromTable = $table;
+ $tableDiff->addedForeignKeys = $addedForeignKeys;
$tableDiff->changedForeignKeys = $changedForeignKeys;
$tableDiff->removedForeignKeys = $removedForeignKeys;
- self::assertEmpty($this->_platform->getAlterTableSQL($tableDiff));
+ self::assertEmpty($this->platform->getAlterTableSQL($tableDiff));
$table->addOption('engine', 'InnoDB');
- $tableDiff = new TableDiff('foreign_table');
- $tableDiff->fromTable = $table;
- $tableDiff->addedForeignKeys = $addedForeignKeys;
+ $tableDiff = new TableDiff('foreign_table');
+ $tableDiff->fromTable = $table;
+ $tableDiff->addedForeignKeys = $addedForeignKeys;
$tableDiff->changedForeignKeys = $changedForeignKeys;
$tableDiff->removedForeignKeys = $removedForeignKeys;
self::assertSame(
- array(
+ [
'ALTER TABLE foreign_table DROP FOREIGN KEY fk_remove',
'ALTER TABLE foreign_table DROP FOREIGN KEY fk_change',
'ALTER TABLE foreign_table ADD CONSTRAINT fk_add FOREIGN KEY (fk_id) REFERENCES foo (id)',
'ALTER TABLE foreign_table ADD CONSTRAINT fk_change FOREIGN KEY (fk_id) REFERENCES bar (id)',
- ),
- $this->_platform->getAlterTableSQL($tableDiff)
+ ],
+ $this->platform->getAlterTableSQL($tableDiff)
);
}
@@ -619,10 +609,10 @@ public function testDoesNotPropagateForeignKeyAlterationForNonSupportingEngines(
*/
protected function getAlterTableRenameIndexSQL()
{
- return array(
+ return [
'DROP INDEX idx_foo ON mytable',
'CREATE INDEX idx_bar ON mytable (id)',
- );
+ ];
}
/**
@@ -630,12 +620,12 @@ protected function getAlterTableRenameIndexSQL()
*/
protected function getQuotedAlterTableRenameIndexSQL()
{
- return array(
+ return [
'DROP INDEX `create` ON `table`',
'CREATE INDEX `select` ON `table` (id)',
'DROP INDEX `foo` ON `table`',
'CREATE INDEX `bar` ON `table` (id)',
- );
+ ];
}
/**
@@ -643,10 +633,10 @@ protected function getQuotedAlterTableRenameIndexSQL()
*/
protected function getAlterTableRenameIndexInSchemaSQL()
{
- return array(
+ return [
'DROP INDEX idx_foo ON myschema.mytable',
'CREATE INDEX idx_bar ON myschema.mytable (id)',
- );
+ ];
}
/**
@@ -654,12 +644,12 @@ protected function getAlterTableRenameIndexInSchemaSQL()
*/
protected function getQuotedAlterTableRenameIndexInSchemaSQL()
{
- return array(
+ return [
'DROP INDEX `create` ON `schema`.`table`',
'CREATE INDEX `select` ON `schema`.`table` (id)',
'DROP INDEX `foo` ON `schema`.`table`',
'CREATE INDEX `bar` ON `schema`.`table` (id)',
- );
+ ];
}
protected function getQuotesDropForeignKeySQL()
@@ -674,26 +664,26 @@ protected function getQuotesDropConstraintSQL()
public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes()
{
- $table = new Table("text_blob_default_value");
- $table->addColumn('def_text', 'text', array('default' => 'def'));
- $table->addColumn('def_text_null', 'text', array('notnull' => false, 'default' => 'def'));
- $table->addColumn('def_blob', 'blob', array('default' => 'def'));
- $table->addColumn('def_blob_null', 'blob', array('notnull' => false, 'default' => 'def'));
+ $table = new Table('text_blob_default_value');
+ $table->addColumn('def_text', 'text', ['default' => 'def']);
+ $table->addColumn('def_text_null', 'text', ['notnull' => false, 'default' => 'def']);
+ $table->addColumn('def_blob', 'blob', ['default' => 'def']);
+ $table->addColumn('def_blob_null', 'blob', ['notnull' => false, 'default' => 'def']);
self::assertSame(
- array('CREATE TABLE text_blob_default_value (def_text LONGTEXT NOT NULL, def_text_null LONGTEXT DEFAULT NULL, def_blob LONGBLOB NOT NULL, def_blob_null LONGBLOB DEFAULT NULL) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'),
- $this->_platform->getCreateTableSQL($table)
+ ['CREATE TABLE text_blob_default_value (def_text LONGTEXT NOT NULL, def_text_null LONGTEXT DEFAULT NULL, def_blob LONGBLOB NOT NULL, def_blob_null LONGBLOB DEFAULT NULL) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'],
+ $this->platform->getCreateTableSQL($table)
);
$diffTable = clone $table;
- $diffTable->changeColumn('def_text', array('default' => null));
- $diffTable->changeColumn('def_text_null', array('default' => null));
- $diffTable->changeColumn('def_blob', array('default' => null));
- $diffTable->changeColumn('def_blob_null', array('default' => null));
+ $diffTable->changeColumn('def_text', ['default' => null]);
+ $diffTable->changeColumn('def_text_null', ['default' => null]);
+ $diffTable->changeColumn('def_blob', ['default' => null]);
+ $diffTable->changeColumn('def_blob_null', ['default' => null]);
$comparator = new Comparator();
- self::assertEmpty($this->_platform->getAlterTableSQL($comparator->diffTable($table, $diffTable)));
+ self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable)));
}
/**
@@ -701,8 +691,7 @@ public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes()
*/
protected function getQuotedAlterTableRenameColumnSQL()
{
- return array(
- "ALTER TABLE mytable " .
+ return ['ALTER TABLE mytable ' .
"CHANGE unquoted1 unquoted INT NOT NULL COMMENT 'Unquoted 1', " .
"CHANGE unquoted2 `where` INT NOT NULL COMMENT 'Unquoted 2', " .
"CHANGE unquoted3 `foo` INT NOT NULL COMMENT 'Unquoted 3', " .
@@ -711,8 +700,8 @@ protected function getQuotedAlterTableRenameColumnSQL()
"CHANGE `select` `bar` INT NOT NULL COMMENT 'Reserved keyword 3', " .
"CHANGE quoted1 quoted INT NOT NULL COMMENT 'Quoted 1', " .
"CHANGE quoted2 `and` INT NOT NULL COMMENT 'Quoted 2', " .
- "CHANGE quoted3 `baz` INT NOT NULL COMMENT 'Quoted 3'"
- );
+ "CHANGE quoted3 `baz` INT NOT NULL COMMENT 'Quoted 3'",
+ ];
}
/**
@@ -720,15 +709,14 @@ protected function getQuotedAlterTableRenameColumnSQL()
*/
protected function getQuotedAlterTableChangeColumnLengthSQL()
{
- return array(
- "ALTER TABLE mytable " .
+ return ['ALTER TABLE mytable ' .
"CHANGE unquoted1 unquoted1 VARCHAR(255) NOT NULL COMMENT 'Unquoted 1', " .
"CHANGE unquoted2 unquoted2 VARCHAR(255) NOT NULL COMMENT 'Unquoted 2', " .
"CHANGE unquoted3 unquoted3 VARCHAR(255) NOT NULL COMMENT 'Unquoted 3', " .
"CHANGE `create` `create` VARCHAR(255) NOT NULL COMMENT 'Reserved keyword 1', " .
"CHANGE `table` `table` VARCHAR(255) NOT NULL COMMENT 'Reserved keyword 2', " .
- "CHANGE `select` `select` VARCHAR(255) NOT NULL COMMENT 'Reserved keyword 3'"
- );
+ "CHANGE `select` `select` VARCHAR(255) NOT NULL COMMENT 'Reserved keyword 3'",
+ ];
}
/**
@@ -736,7 +724,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL()
*/
public function testReturnsGuidTypeDeclarationSQL()
{
- self::assertSame('CHAR(36)', $this->_platform->getGuidTypeDeclarationSQL(array()));
+ self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([]));
}
/**
@@ -744,9 +732,7 @@ public function testReturnsGuidTypeDeclarationSQL()
*/
public function getAlterTableRenameColumnSQL()
{
- return array(
- "ALTER TABLE foo CHANGE bar baz INT DEFAULT 666 NOT NULL COMMENT 'rename test'",
- );
+ return ["ALTER TABLE foo CHANGE bar baz INT DEFAULT 666 NOT NULL COMMENT 'rename test'"];
}
/**
@@ -754,14 +740,14 @@ public function getAlterTableRenameColumnSQL()
*/
protected function getQuotesTableIdentifiersInAlterTableSQL()
{
- return array(
+ return [
'ALTER TABLE `foo` DROP FOREIGN KEY fk1',
'ALTER TABLE `foo` DROP FOREIGN KEY fk2',
'ALTER TABLE `foo` RENAME TO `table`, ADD bloo INT NOT NULL, DROP baz, CHANGE bar bar INT DEFAULT NULL, ' .
'CHANGE id war INT NOT NULL',
'ALTER TABLE `table` ADD CONSTRAINT fk_add FOREIGN KEY (fk3) REFERENCES fk_table (id)',
'ALTER TABLE `table` ADD CONSTRAINT fk2 FOREIGN KEY (fk2) REFERENCES fk_table2 (id)',
- );
+ ];
}
/**
@@ -769,11 +755,11 @@ protected function getQuotesTableIdentifiersInAlterTableSQL()
*/
protected function getCommentOnColumnSQL()
{
- return array(
+ return [
"COMMENT ON COLUMN foo.bar IS 'comment'",
"COMMENT ON COLUMN `Foo`.`BAR` IS 'comment'",
"COMMENT ON COLUMN `select`.`from` IS 'comment'",
- );
+ ];
}
/**
@@ -805,9 +791,7 @@ protected function getQuotesReservedKeywordInTruncateTableSQL()
*/
protected function getAlterStringToFixedStringSQL()
{
- return array(
- 'ALTER TABLE mytable CHANGE name name CHAR(2) NOT NULL',
- );
+ return ['ALTER TABLE mytable CHANGE name name CHAR(2) NOT NULL'];
}
/**
@@ -815,12 +799,12 @@ protected function getAlterStringToFixedStringSQL()
*/
protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
{
- return array(
+ return [
'ALTER TABLE mytable DROP FOREIGN KEY fk_foo',
'DROP INDEX idx_foo ON mytable',
'CREATE INDEX idx_foo_renamed ON mytable (foo)',
'ALTER TABLE mytable ADD CONSTRAINT fk_foo FOREIGN KEY (foo) REFERENCES foreign_table (id)',
- );
+ ];
}
/**
@@ -828,14 +812,14 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
*/
public function getGeneratesDecimalTypeDeclarationSQL()
{
- return array(
- array(array(), 'NUMERIC(10, 0)'),
- array(array('unsigned' => true), 'NUMERIC(10, 0) UNSIGNED'),
- array(array('unsigned' => false), 'NUMERIC(10, 0)'),
- array(array('precision' => 5), 'NUMERIC(5, 0)'),
- array(array('scale' => 5), 'NUMERIC(10, 5)'),
- array(array('precision' => 8, 'scale' => 2), 'NUMERIC(8, 2)'),
- );
+ return [
+ [[], 'NUMERIC(10, 0)'],
+ [['unsigned' => true], 'NUMERIC(10, 0) UNSIGNED'],
+ [['unsigned' => false], 'NUMERIC(10, 0)'],
+ [['precision' => 5], 'NUMERIC(5, 0)'],
+ [['scale' => 5], 'NUMERIC(10, 5)'],
+ [['precision' => 8, 'scale' => 2], 'NUMERIC(8, 2)'],
+ ];
}
/**
@@ -843,14 +827,14 @@ public function getGeneratesDecimalTypeDeclarationSQL()
*/
public function getGeneratesFloatDeclarationSQL()
{
- return array(
- array(array(), 'DOUBLE PRECISION'),
- array(array('unsigned' => true), 'DOUBLE PRECISION UNSIGNED'),
- array(array('unsigned' => false), 'DOUBLE PRECISION'),
- array(array('precision' => 5), 'DOUBLE PRECISION'),
- array(array('scale' => 5), 'DOUBLE PRECISION'),
- array(array('precision' => 8, 'scale' => 2), 'DOUBLE PRECISION'),
- );
+ return [
+ [[], 'DOUBLE PRECISION'],
+ [['unsigned' => true], 'DOUBLE PRECISION UNSIGNED'],
+ [['unsigned' => false], 'DOUBLE PRECISION'],
+ [['precision' => 5], 'DOUBLE PRECISION'],
+ [['scale' => 5], 'DOUBLE PRECISION'],
+ [['precision' => 8, 'scale' => 2], 'DOUBLE PRECISION'],
+ ];
}
/**
@@ -858,7 +842,7 @@ public function getGeneratesFloatDeclarationSQL()
*/
public function testQuotesTableNameInListTableIndexesSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableIndexesSQL("Foo'Bar\\", 'foo_db'), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableIndexesSQL("Foo'Bar\\", 'foo_db'), '', true);
}
/**
@@ -866,7 +850,7 @@ public function testQuotesTableNameInListTableIndexesSQL()
*/
public function testQuotesDatabaseNameInListTableIndexesSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableIndexesSQL('foo_table', "Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableIndexesSQL('foo_table', "Foo'Bar\\"), '', true);
}
/**
@@ -874,7 +858,7 @@ public function testQuotesDatabaseNameInListTableIndexesSQL()
*/
public function testQuotesDatabaseNameInListViewsSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListViewsSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListViewsSQL("Foo'Bar\\"), '', true);
}
/**
@@ -882,7 +866,7 @@ public function testQuotesDatabaseNameInListViewsSQL()
*/
public function testQuotesTableNameInListTableForeignKeysSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
}
/**
@@ -890,7 +874,7 @@ public function testQuotesTableNameInListTableForeignKeysSQL()
*/
public function testQuotesDatabaseNameInListTableForeignKeysSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableForeignKeysSQL('foo_table', "Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableForeignKeysSQL('foo_table', "Foo'Bar\\"), '', true);
}
/**
@@ -898,7 +882,7 @@ public function testQuotesDatabaseNameInListTableForeignKeysSQL()
*/
public function testQuotesTableNameInListTableColumnsSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableColumnsSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableColumnsSQL("Foo'Bar\\"), '', true);
}
/**
@@ -906,16 +890,16 @@ public function testQuotesTableNameInListTableColumnsSQL()
*/
public function testQuotesDatabaseNameInListTableColumnsSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableColumnsSQL('foo_table', "Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableColumnsSQL('foo_table', "Foo'Bar\\"), '', true);
}
public function testListTableForeignKeysSQLEvaluatesDatabase()
{
- $sql = $this->_platform->getListTableForeignKeysSQL('foo');
+ $sql = $this->platform->getListTableForeignKeysSQL('foo');
self::assertContains('DATABASE()', $sql);
- $sql = $this->_platform->getListTableForeignKeysSQL('foo', 'bar');
+ $sql = $this->platform->getListTableForeignKeysSQL('foo', 'bar');
self::assertContains('bar', $sql);
self::assertNotContains('DATABASE()', $sql);
@@ -923,14 +907,14 @@ public function testListTableForeignKeysSQLEvaluatesDatabase()
public function testSupportsColumnCollation() : void
{
- self::assertTrue($this->_platform->supportsColumnCollation());
+ self::assertTrue($this->platform->supportsColumnCollation());
}
public function testColumnCollationDeclarationSQL() : void
{
self::assertSame(
'COLLATE ascii_general_ci',
- $this->_platform->getColumnCollationDeclarationSQL('ascii_general_ci')
+ $this->platform->getColumnCollationDeclarationSQL('ascii_general_ci')
);
}
@@ -942,7 +926,7 @@ public function testGetCreateTableSQLWithColumnCollation() : void
self::assertSame(
['CREATE TABLE foo (no_collation VARCHAR(255) NOT NULL, column_collation VARCHAR(255) NOT NULL COLLATE ascii_general_ci) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'],
- $this->_platform->getCreateTableSQL($table),
+ $this->platform->getCreateTableSQL($table),
'Column "no_collation" will use the default collation from the table/database and "column_collation" overwrites the collation on this column'
);
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
index a0b0ea33741..8fee20fede2 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
@@ -3,8 +3,10 @@
namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\Common\EventManager;
+use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Platforms\Keywords\KeywordList;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Comparator;
@@ -13,24 +15,23 @@
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\Type;
+use Doctrine\Tests\DbalTestCase;
use Doctrine\Tests\Types\CommentedType;
use function get_class;
use function implode;
use function sprintf;
use function str_repeat;
-abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
+abstract class AbstractPlatformTestCase extends DbalTestCase
{
- /**
- * @var \Doctrine\DBAL\Platforms\AbstractPlatform
- */
- protected $_platform;
+ /** @var AbstractPlatform */
+ protected $platform;
abstract public function createPlatform();
protected function setUp()
{
- $this->_platform = $this->createPlatform();
+ $this->platform = $this->createPlatform();
}
/**
@@ -38,14 +39,14 @@ protected function setUp()
*/
public function testQuoteIdentifier()
{
- if ($this->_platform->getName() == "mssql") {
+ if ($this->platform->getName() === 'mssql') {
$this->markTestSkipped('Not working this way on mssql.');
}
- $c = $this->_platform->getIdentifierQuoteCharacter();
- self::assertEquals($c."test".$c, $this->_platform->quoteIdentifier("test"));
- self::assertEquals($c."test".$c.".".$c."test".$c, $this->_platform->quoteIdentifier("test.test"));
- self::assertEquals(str_repeat($c, 4), $this->_platform->quoteIdentifier($c));
+ $c = $this->platform->getIdentifierQuoteCharacter();
+ self::assertEquals($c . 'test' . $c, $this->platform->quoteIdentifier('test'));
+ self::assertEquals($c . 'test' . $c . '.' . $c . 'test' . $c, $this->platform->quoteIdentifier('test.test'));
+ self::assertEquals(str_repeat($c, 4), $this->platform->quoteIdentifier($c));
}
/**
@@ -53,63 +54,62 @@ public function testQuoteIdentifier()
*/
public function testQuoteSingleIdentifier()
{
- if ($this->_platform->getName() == "mssql") {
+ if ($this->platform->getName() === 'mssql') {
$this->markTestSkipped('Not working this way on mssql.');
}
- $c = $this->_platform->getIdentifierQuoteCharacter();
- self::assertEquals($c."test".$c, $this->_platform->quoteSingleIdentifier("test"));
- self::assertEquals($c."test.test".$c, $this->_platform->quoteSingleIdentifier("test.test"));
- self::assertEquals(str_repeat($c, 4), $this->_platform->quoteSingleIdentifier($c));
+ $c = $this->platform->getIdentifierQuoteCharacter();
+ self::assertEquals($c . 'test' . $c, $this->platform->quoteSingleIdentifier('test'));
+ self::assertEquals($c . 'test.test' . $c, $this->platform->quoteSingleIdentifier('test.test'));
+ self::assertEquals(str_repeat($c, 4), $this->platform->quoteSingleIdentifier($c));
}
/**
* @group DBAL-1029
- *
* @dataProvider getReturnsForeignKeyReferentialActionSQL
*/
public function testReturnsForeignKeyReferentialActionSQL($action, $expectedSQL)
{
- self::assertSame($expectedSQL, $this->_platform->getForeignKeyReferentialActionSQL($action));
+ self::assertSame($expectedSQL, $this->platform->getForeignKeyReferentialActionSQL($action));
}
/**
- * @return array
+ * @return string[][]
*/
public function getReturnsForeignKeyReferentialActionSQL()
{
- return array(
- array('CASCADE', 'CASCADE'),
- array('SET NULL', 'SET NULL'),
- array('NO ACTION', 'NO ACTION'),
- array('RESTRICT', 'RESTRICT'),
- array('SET DEFAULT', 'SET DEFAULT'),
- array('CaScAdE', 'CASCADE'),
- );
+ return [
+ ['CASCADE', 'CASCADE'],
+ ['SET NULL', 'SET NULL'],
+ ['NO ACTION', 'NO ACTION'],
+ ['RESTRICT', 'RESTRICT'],
+ ['SET DEFAULT', 'SET DEFAULT'],
+ ['CaScAdE', 'CASCADE'],
+ ];
}
public function testGetInvalidForeignKeyReferentialActionSQL()
{
$this->expectException('InvalidArgumentException');
- $this->_platform->getForeignKeyReferentialActionSQL('unknown');
+ $this->platform->getForeignKeyReferentialActionSQL('unknown');
}
public function testGetUnknownDoctrineMappingType()
{
- $this->expectException('Doctrine\DBAL\DBALException');
- $this->_platform->getDoctrineTypeMapping('foobar');
+ $this->expectException(DBALException::class);
+ $this->platform->getDoctrineTypeMapping('foobar');
}
public function testRegisterDoctrineMappingType()
{
- $this->_platform->registerDoctrineTypeMapping('foo', 'integer');
- self::assertEquals('integer', $this->_platform->getDoctrineTypeMapping('foo'));
+ $this->platform->registerDoctrineTypeMapping('foo', 'integer');
+ self::assertEquals('integer', $this->platform->getDoctrineTypeMapping('foo'));
}
public function testRegisterUnknownDoctrineMappingType()
{
- $this->expectException('Doctrine\DBAL\DBALException');
- $this->_platform->registerDoctrineTypeMapping('foo', 'bar');
+ $this->expectException(DBALException::class);
+ $this->platform->registerDoctrineTypeMapping('foo', 'bar');
}
/**
@@ -117,39 +117,38 @@ public function testRegisterUnknownDoctrineMappingType()
*/
public function testRegistersCommentedDoctrineMappingTypeImplicitly()
{
- if (!Type::hasType('my_commented')) {
+ if (! Type::hasType('my_commented')) {
Type::addType('my_commented', CommentedType::class);
}
$type = Type::getType('my_commented');
- $this->_platform->registerDoctrineTypeMapping('foo', 'my_commented');
+ $this->platform->registerDoctrineTypeMapping('foo', 'my_commented');
- self::assertTrue($this->_platform->isCommentedDoctrineType($type));
+ self::assertTrue($this->platform->isCommentedDoctrineType($type));
}
/**
* @group DBAL-939
- *
* @dataProvider getIsCommentedDoctrineType
*/
public function testIsCommentedDoctrineType(Type $type, $commented)
{
- self::assertSame($commented, $this->_platform->isCommentedDoctrineType($type));
+ self::assertSame($commented, $this->platform->isCommentedDoctrineType($type));
}
public function getIsCommentedDoctrineType()
{
$this->setUp();
- $data = array();
+ $data = [];
foreach (Type::getTypesMap() as $typeName => $className) {
$type = Type::getType($typeName);
- $data[$typeName] = array(
+ $data[$typeName] = [
$type,
- $type->requiresSQLCommentHint($this->_platform),
- );
+ $type->requiresSQLCommentHint($this->platform),
+ ];
}
return $data;
@@ -159,18 +158,18 @@ public function testCreateWithNoColumns()
{
$table = new Table('test');
- $this->expectException('Doctrine\DBAL\DBALException');
- $sql = $this->_platform->getCreateTableSQL($table);
+ $this->expectException(DBALException::class);
+ $sql = $this->platform->getCreateTableSQL($table);
}
public function testGeneratesTableCreationSql()
{
$table = new Table('test');
- $table->addColumn('id', 'integer', array('notnull' => true, 'autoincrement' => true));
- $table->addColumn('test', 'string', array('notnull' => false, 'length' => 255));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('id', 'integer', ['notnull' => true, 'autoincrement' => true]);
+ $table->addColumn('test', 'string', ['notnull' => false, 'length' => 255]);
+ $table->setPrimaryKey(['id']);
- $sql = $this->_platform->getCreateTableSQL($table);
+ $sql = $this->platform->getCreateTableSQL($table);
self::assertEquals($this->getGenerateTableSql(), $sql[0]);
}
@@ -179,11 +178,11 @@ abstract public function getGenerateTableSql();
public function testGenerateTableWithMultiColumnUniqueIndex()
{
$table = new Table('test');
- $table->addColumn('foo', 'string', array('notnull' => false, 'length' => 255));
- $table->addColumn('bar', 'string', array('notnull' => false, 'length' => 255));
- $table->addUniqueIndex(array("foo", "bar"));
+ $table->addColumn('foo', 'string', ['notnull' => false, 'length' => 255]);
+ $table->addColumn('bar', 'string', ['notnull' => false, 'length' => 255]);
+ $table->addUniqueIndex(['foo', 'bar']);
- $sql = $this->_platform->getCreateTableSQL($table);
+ $sql = $this->platform->getCreateTableSQL($table);
self::assertEquals($this->getGenerateTableWithMultiColumnUniqueIndexSql(), $sql);
}
@@ -191,11 +190,11 @@ abstract public function getGenerateTableWithMultiColumnUniqueIndexSql();
public function testGeneratesIndexCreationSql()
{
- $indexDef = new \Doctrine\DBAL\Schema\Index('my_idx', array('user_name', 'last_login'));
+ $indexDef = new Index('my_idx', ['user_name', 'last_login']);
self::assertEquals(
$this->getGenerateIndexSql(),
- $this->_platform->getCreateIndexSQL($indexDef, 'mytable')
+ $this->platform->getCreateIndexSQL($indexDef, 'mytable')
);
}
@@ -203,9 +202,9 @@ abstract public function getGenerateIndexSql();
public function testGeneratesUniqueIndexCreationSql()
{
- $indexDef = new \Doctrine\DBAL\Schema\Index('index_name', array('test', 'test2'), true);
+ $indexDef = new Index('index_name', ['test', 'test2'], true);
- $sql = $this->_platform->getCreateIndexSQL($indexDef, 'test');
+ $sql = $this->platform->getCreateIndexSQL($indexDef, 'test');
self::assertEquals($this->getGenerateUniqueIndexSql(), $sql);
}
@@ -213,23 +212,23 @@ abstract public function getGenerateUniqueIndexSql();
public function testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes()
{
- $where = 'test IS NULL AND test2 IS NOT NULL';
- $indexDef = new \Doctrine\DBAL\Schema\Index('name', array('test', 'test2'), false, false, array(), array('where' => $where));
- $uniqueIndex = new \Doctrine\DBAL\Schema\Index('name', array('test', 'test2'), true, false, array(), array('where' => $where));
+ $where = 'test IS NULL AND test2 IS NOT NULL';
+ $indexDef = new Index('name', ['test', 'test2'], false, false, [], ['where' => $where]);
+ $uniqueIndex = new Index('name', ['test', 'test2'], true, false, [], ['where' => $where]);
$expected = ' WHERE ' . $where;
- $actuals = array();
+ $actuals = [];
if ($this->supportsInlineIndexDeclaration()) {
- $actuals []= $this->_platform->getIndexDeclarationSQL('name', $indexDef);
+ $actuals[] = $this->platform->getIndexDeclarationSQL('name', $indexDef);
}
- $actuals []= $this->_platform->getUniqueConstraintDeclarationSQL('name', $uniqueIndex);
- $actuals []= $this->_platform->getCreateIndexSQL($indexDef, 'table');
+ $actuals[] = $this->platform->getUniqueConstraintDeclarationSQL('name', $uniqueIndex);
+ $actuals[] = $this->platform->getCreateIndexSQL($indexDef, 'table');
foreach ($actuals as $actual) {
- if ($this->_platform->supportsPartialIndexes()) {
+ if ($this->platform->supportsPartialIndexes()) {
self::assertStringEndsWith($expected, $actual, 'WHERE clause should be present');
} else {
self::assertStringEndsNotWith($expected, $actual, 'WHERE clause should NOT be present');
@@ -239,9 +238,9 @@ public function testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes()
public function testGeneratesForeignKeyCreationSql()
{
- $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name_id'), 'other_table', array('id'), '');
+ $fk = new ForeignKeyConstraint(['fk_name_id'], 'other_table', ['id'], '');
- $sql = $this->_platform->getCreateForeignKeySQL($fk, 'test');
+ $sql = $this->platform->getCreateForeignKeySQL($fk, 'test');
self::assertEquals($sql, $this->getGenerateForeignKeySql());
}
@@ -249,31 +248,31 @@ abstract public function getGenerateForeignKeySql();
public function testGeneratesConstraintCreationSql()
{
- $idx = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, false);
- $sql = $this->_platform->getCreateConstraintSQL($idx, 'test');
+ $idx = new Index('constraint_name', ['test'], true, false);
+ $sql = $this->platform->getCreateConstraintSQL($idx, 'test');
self::assertEquals($this->getGenerateConstraintUniqueIndexSql(), $sql);
- $pk = new \Doctrine\DBAL\Schema\Index('constraint_name', array('test'), true, true);
- $sql = $this->_platform->getCreateConstraintSQL($pk, 'test');
+ $pk = new Index('constraint_name', ['test'], true, true);
+ $sql = $this->platform->getCreateConstraintSQL($pk, 'test');
self::assertEquals($this->getGenerateConstraintPrimaryIndexSql(), $sql);
- $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name'), 'foreign', array('id'), 'constraint_fk');
- $sql = $this->_platform->getCreateConstraintSQL($fk, 'test');
+ $fk = new ForeignKeyConstraint(['fk_name'], 'foreign', ['id'], 'constraint_fk');
+ $sql = $this->platform->getCreateConstraintSQL($fk, 'test');
self::assertEquals($this->getGenerateConstraintForeignKeySql($fk), $sql);
}
public function testGeneratesForeignKeySqlOnlyWhenSupportingForeignKeys()
{
- $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('fk_name'), 'foreign', array('id'), 'constraint_fk');
+ $fk = new ForeignKeyConstraint(['fk_name'], 'foreign', ['id'], 'constraint_fk');
- if ($this->_platform->supportsForeignKeyConstraints()) {
+ if ($this->platform->supportsForeignKeyConstraints()) {
self::assertInternalType(
'string',
- $this->_platform->getCreateForeignKeySQL($fk, 'test')
+ $this->platform->getCreateForeignKeySQL($fk, 'test')
);
} else {
- $this->expectException('Doctrine\DBAL\DBALException');
- $this->_platform->getCreateForeignKeySQL($fk, 'test');
+ $this->expectException(DBALException::class);
+ $this->platform->getCreateForeignKeySQL($fk, 'test');
}
}
@@ -287,11 +286,11 @@ protected function getBitAndComparisonExpressionSql($value1, $value2)
*/
public function testGeneratesBitAndComparisonExpressionSql()
{
- $sql = $this->_platform->getBitAndComparisonExpression(2, 4);
+ $sql = $this->platform->getBitAndComparisonExpression(2, 4);
self::assertEquals($this->getBitAndComparisonExpressionSql(2, 4), $sql);
}
- protected function getBitOrComparisonExpressionSql($value1, $value2)
+ protected function getBitOrComparisonExpressionSql($value1, $value2)
{
return '(' . $value1 . ' | ' . $value2 . ')';
}
@@ -301,7 +300,7 @@ protected function getBitOrComparisonExpressionSql($value1, $value2)
*/
public function testGeneratesBitOrComparisonExpressionSql()
{
- $sql = $this->_platform->getBitOrComparisonExpression(2, 4);
+ $sql = $this->platform->getBitOrComparisonExpression(2, 4);
self::assertEquals($this->getBitOrComparisonExpressionSql(2, 4), $sql);
}
@@ -317,9 +316,12 @@ public function getGenerateConstraintPrimaryIndexSql()
public function getGenerateConstraintForeignKeySql(ForeignKeyConstraint $fk)
{
- $quotedForeignTable = $fk->getQuotedForeignTableName($this->_platform);
+ $quotedForeignTable = $fk->getQuotedForeignTableName($this->platform);
- return "ALTER TABLE test ADD CONSTRAINT constraint_fk FOREIGN KEY (fk_name) REFERENCES $quotedForeignTable (id)";
+ return sprintf(
+ 'ALTER TABLE test ADD CONSTRAINT constraint_fk FOREIGN KEY (fk_name) REFERENCES %s (id)',
+ $quotedForeignTable
+ );
}
abstract public function getGenerateAlterTableSql();
@@ -329,45 +331,51 @@ public function testGeneratesTableAlterationSql()
$expectedSql = $this->getGenerateAlterTableSql();
$table = new Table('mytable');
- $table->addColumn('id', 'integer', array('autoincrement' => true));
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('foo', 'integer');
$table->addColumn('bar', 'string');
$table->addColumn('bloo', 'boolean');
- $table->setPrimaryKey(array('id'));
-
- $tableDiff = new TableDiff('mytable');
- $tableDiff->fromTable = $table;
- $tableDiff->newName = 'userlist';
- $tableDiff->addedColumns['quota'] = new \Doctrine\DBAL\Schema\Column('quota', \Doctrine\DBAL\Types\Type::getType('integer'), array('notnull' => false));
- $tableDiff->removedColumns['foo'] = new \Doctrine\DBAL\Schema\Column('foo', \Doctrine\DBAL\Types\Type::getType('integer'));
- $tableDiff->changedColumns['bar'] = new \Doctrine\DBAL\Schema\ColumnDiff(
- 'bar', new \Doctrine\DBAL\Schema\Column(
- 'baz', \Doctrine\DBAL\Types\Type::getType('string'), array('default' => 'def')
+ $table->setPrimaryKey(['id']);
+
+ $tableDiff = new TableDiff('mytable');
+ $tableDiff->fromTable = $table;
+ $tableDiff->newName = 'userlist';
+ $tableDiff->addedColumns['quota'] = new Column('quota', Type::getType('integer'), ['notnull' => false]);
+ $tableDiff->removedColumns['foo'] = new Column('foo', Type::getType('integer'));
+ $tableDiff->changedColumns['bar'] = new ColumnDiff(
+ 'bar',
+ new Column(
+ 'baz',
+ Type::getType('string'),
+ ['default' => 'def']
),
- array('type', 'notnull', 'default')
+ ['type', 'notnull', 'default']
);
- $tableDiff->changedColumns['bloo'] = new \Doctrine\DBAL\Schema\ColumnDiff(
- 'bloo', new \Doctrine\DBAL\Schema\Column(
- 'bloo', \Doctrine\DBAL\Types\Type::getType('boolean'), array('default' => false)
+ $tableDiff->changedColumns['bloo'] = new ColumnDiff(
+ 'bloo',
+ new Column(
+ 'bloo',
+ Type::getType('boolean'),
+ ['default' => false]
),
- array('type', 'notnull', 'default')
+ ['type', 'notnull', 'default']
);
- $sql = $this->_platform->getAlterTableSQL($tableDiff);
+ $sql = $this->platform->getAlterTableSQL($tableDiff);
self::assertEquals($expectedSql, $sql);
}
public function testGetCustomColumnDeclarationSql()
{
- $field = array('columnDefinition' => 'MEDIUMINT(6) UNSIGNED');
- self::assertEquals('foo MEDIUMINT(6) UNSIGNED', $this->_platform->getColumnDeclarationSQL('foo', $field));
+ $field = ['columnDefinition' => 'MEDIUMINT(6) UNSIGNED'];
+ self::assertEquals('foo MEDIUMINT(6) UNSIGNED', $this->platform->getColumnDeclarationSQL('foo', $field));
}
public function testGetCreateTableSqlDispatchEvent()
{
$listenerMock = $this->getMockBuilder('GetCreateTableSqlDispatchEvenListener')
- ->setMethods(array('onSchemaCreateTable', 'onSchemaCreateTableColumn'))
+ ->setMethods(['onSchemaCreateTable', 'onSchemaCreateTableColumn'])
->getMock();
$listenerMock
->expects($this->once())
@@ -377,43 +385,43 @@ public function testGetCreateTableSqlDispatchEvent()
->method('onSchemaCreateTableColumn');
$eventManager = new EventManager();
- $eventManager->addEventListener(array(Events::onSchemaCreateTable, Events::onSchemaCreateTableColumn), $listenerMock);
+ $eventManager->addEventListener([Events::onSchemaCreateTable, Events::onSchemaCreateTableColumn], $listenerMock);
- $this->_platform->setEventManager($eventManager);
+ $this->platform->setEventManager($eventManager);
$table = new Table('test');
- $table->addColumn('foo', 'string', array('notnull' => false, 'length' => 255));
- $table->addColumn('bar', 'string', array('notnull' => false, 'length' => 255));
+ $table->addColumn('foo', 'string', ['notnull' => false, 'length' => 255]);
+ $table->addColumn('bar', 'string', ['notnull' => false, 'length' => 255]);
- $this->_platform->getCreateTableSQL($table);
+ $this->platform->getCreateTableSQL($table);
}
public function testGetDropTableSqlDispatchEvent()
{
$listenerMock = $this->getMockBuilder('GetDropTableSqlDispatchEventListener')
- ->setMethods(array('onSchemaDropTable'))
+ ->setMethods(['onSchemaDropTable'])
->getMock();
$listenerMock
->expects($this->once())
->method('onSchemaDropTable');
$eventManager = new EventManager();
- $eventManager->addEventListener(array(Events::onSchemaDropTable), $listenerMock);
+ $eventManager->addEventListener([Events::onSchemaDropTable], $listenerMock);
- $this->_platform->setEventManager($eventManager);
+ $this->platform->setEventManager($eventManager);
- $this->_platform->getDropTableSQL('TABLE');
+ $this->platform->getDropTableSQL('TABLE');
}
public function testGetAlterTableSqlDispatchEvent()
{
- $events = array(
+ $events = [
'onSchemaAlterTable',
'onSchemaAlterTableAddColumn',
'onSchemaAlterTableRemoveColumn',
'onSchemaAlterTableChangeColumn',
- 'onSchemaAlterTableRenameColumn'
- );
+ 'onSchemaAlterTableRenameColumn',
+ ];
$listenerMock = $this->getMockBuilder('GetAlterTableSqlDispatchEvenListener')
->setMethods($events)
@@ -435,35 +443,38 @@ public function testGetAlterTableSqlDispatchEvent()
->method('onSchemaAlterTableRenameColumn');
$eventManager = new EventManager();
- $events = array(
+ $events = [
Events::onSchemaAlterTable,
Events::onSchemaAlterTableAddColumn,
Events::onSchemaAlterTableRemoveColumn,
Events::onSchemaAlterTableChangeColumn,
- Events::onSchemaAlterTableRenameColumn
- );
+ Events::onSchemaAlterTableRenameColumn,
+ ];
$eventManager->addEventListener($events, $listenerMock);
- $this->_platform->setEventManager($eventManager);
+ $this->platform->setEventManager($eventManager);
$table = new Table('mytable');
$table->addColumn('removed', 'integer');
$table->addColumn('changed', 'integer');
$table->addColumn('renamed', 'integer');
- $tableDiff = new TableDiff('mytable');
- $tableDiff->fromTable = $table;
- $tableDiff->addedColumns['added'] = new \Doctrine\DBAL\Schema\Column('added', \Doctrine\DBAL\Types\Type::getType('integer'), array());
- $tableDiff->removedColumns['removed'] = new \Doctrine\DBAL\Schema\Column('removed', \Doctrine\DBAL\Types\Type::getType('integer'), array());
- $tableDiff->changedColumns['changed'] = new \Doctrine\DBAL\Schema\ColumnDiff(
- 'changed', new \Doctrine\DBAL\Schema\Column(
- 'changed2', \Doctrine\DBAL\Types\Type::getType('string'), array()
+ $tableDiff = new TableDiff('mytable');
+ $tableDiff->fromTable = $table;
+ $tableDiff->addedColumns['added'] = new Column('added', Type::getType('integer'), []);
+ $tableDiff->removedColumns['removed'] = new Column('removed', Type::getType('integer'), []);
+ $tableDiff->changedColumns['changed'] = new ColumnDiff(
+ 'changed',
+ new Column(
+ 'changed2',
+ Type::getType('string'),
+ []
),
- array()
+ []
);
- $tableDiff->renamedColumns['renamed'] = new \Doctrine\DBAL\Schema\Column('renamed2', \Doctrine\DBAL\Types\Type::getType('integer'), array());
+ $tableDiff->renamedColumns['renamed'] = new Column('renamed2', Type::getType('integer'), []);
- $this->_platform->getAlterTableSQL($tableDiff);
+ $this->platform->getAlterTableSQL($tableDiff);
}
/**
@@ -472,10 +483,10 @@ public function testGetAlterTableSqlDispatchEvent()
public function testCreateTableColumnComments()
{
$table = new Table('test');
- $table->addColumn('id', 'integer', array('comment' => 'This is a comment'));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('id', 'integer', ['comment' => 'This is a comment']);
+ $table->setPrimaryKey(['id']);
- self::assertEquals($this->getCreateTableColumnCommentsSQL(), $this->_platform->getCreateTableSQL($table));
+ self::assertEquals($this->getCreateTableColumnCommentsSQL(), $this->platform->getCreateTableSQL($table));
}
/**
@@ -483,22 +494,27 @@ public function testCreateTableColumnComments()
*/
public function testAlterTableColumnComments()
{
- $tableDiff = new TableDiff('mytable');
- $tableDiff->addedColumns['quota'] = new \Doctrine\DBAL\Schema\Column('quota', \Doctrine\DBAL\Types\Type::getType('integer'), array('comment' => 'A comment'));
- $tableDiff->changedColumns['foo'] = new \Doctrine\DBAL\Schema\ColumnDiff(
- 'foo', new \Doctrine\DBAL\Schema\Column(
- 'foo', \Doctrine\DBAL\Types\Type::getType('string')
+ $tableDiff = new TableDiff('mytable');
+ $tableDiff->addedColumns['quota'] = new Column('quota', Type::getType('integer'), ['comment' => 'A comment']);
+ $tableDiff->changedColumns['foo'] = new ColumnDiff(
+ 'foo',
+ new Column(
+ 'foo',
+ Type::getType('string')
),
- array('comment')
+ ['comment']
);
- $tableDiff->changedColumns['bar'] = new \Doctrine\DBAL\Schema\ColumnDiff(
- 'bar', new \Doctrine\DBAL\Schema\Column(
- 'baz', \Doctrine\DBAL\Types\Type::getType('string'), array('comment' => 'B comment')
+ $tableDiff->changedColumns['bar'] = new ColumnDiff(
+ 'bar',
+ new Column(
+ 'baz',
+ Type::getType('string'),
+ ['comment' => 'B comment']
),
- array('comment')
+ ['comment']
);
- self::assertEquals($this->getAlterTableColumnCommentsSQL(), $this->_platform->getAlterTableSQL($tableDiff));
+ self::assertEquals($this->getAlterTableColumnCommentsSQL(), $this->platform->getAlterTableSQL($tableDiff));
}
public function testCreateTableColumnTypeComments()
@@ -506,9 +522,9 @@ public function testCreateTableColumnTypeComments()
$table = new Table('test');
$table->addColumn('id', 'integer');
$table->addColumn('data', 'array');
- $table->setPrimaryKey(array('id'));
+ $table->setPrimaryKey(['id']);
- self::assertEquals($this->getCreateTableColumnTypeCommentsSQL(), $this->_platform->getCreateTableSQL($table));
+ self::assertEquals($this->getCreateTableColumnTypeCommentsSQL(), $this->platform->getCreateTableSQL($table));
}
public function getCreateTableColumnCommentsSQL()
@@ -529,12 +545,12 @@ public function getCreateTableColumnTypeCommentsSQL()
public function testGetDefaultValueDeclarationSQL()
{
// non-timestamp value will get single quotes
- $field = array(
+ $field = [
'type' => Type::getType('string'),
- 'default' => 'non_timestamp'
- );
+ 'default' => 'non_timestamp',
+ ];
- self::assertEquals(" DEFAULT 'non_timestamp'", $this->_platform->getDefaultValueDeclarationSQL($field));
+ self::assertEquals(" DEFAULT 'non_timestamp'", $this->platform->getDefaultValueDeclarationSQL($field));
}
/**
@@ -546,27 +562,27 @@ public function testGetDefaultValueDeclarationSQLDateTime() : void
foreach (['datetime', 'datetimetz', 'datetime_immutable', 'datetimetz_immutable'] as $type) {
$field = [
'type' => Type::getType($type),
- 'default' => $this->_platform->getCurrentTimestampSQL(),
+ 'default' => $this->platform->getCurrentTimestampSQL(),
];
self::assertSame(
- ' DEFAULT ' . $this->_platform->getCurrentTimestampSQL(),
- $this->_platform->getDefaultValueDeclarationSQL($field)
+ ' DEFAULT ' . $this->platform->getCurrentTimestampSQL(),
+ $this->platform->getDefaultValueDeclarationSQL($field)
);
}
}
public function testGetDefaultValueDeclarationSQLForIntegerTypes()
{
- foreach(array('bigint', 'integer', 'smallint') as $type) {
- $field = array(
+ foreach (['bigint', 'integer', 'smallint'] as $type) {
+ $field = [
'type' => Type::getType($type),
- 'default' => 1
- );
+ 'default' => 1,
+ ];
self::assertEquals(
' DEFAULT 1',
- $this->_platform->getDefaultValueDeclarationSQL($field)
+ $this->platform->getDefaultValueDeclarationSQL($field)
);
}
}
@@ -576,7 +592,7 @@ public function testGetDefaultValueDeclarationSQLForIntegerTypes()
*/
public function testGetDefaultValueDeclarationSQLForDateType() : void
{
- $currentDateSql = $this->_platform->getCurrentDateSQL();
+ $currentDateSql = $this->platform->getCurrentDateSQL();
foreach (['date', 'date_immutable'] as $type) {
$field = [
'type' => Type::getType($type),
@@ -585,7 +601,7 @@ public function testGetDefaultValueDeclarationSQLForDateType() : void
self::assertSame(
' DEFAULT ' . $currentDateSql,
- $this->_platform->getDefaultValueDeclarationSQL($field)
+ $this->platform->getDefaultValueDeclarationSQL($field)
);
}
}
@@ -595,8 +611,8 @@ public function testGetDefaultValueDeclarationSQLForDateType() : void
*/
public function testKeywordList()
{
- $keywordList = $this->_platform->getReservedKeywordsList();
- self::assertInstanceOf('Doctrine\DBAL\Platforms\Keywords\KeywordList', $keywordList);
+ $keywordList = $this->platform->getReservedKeywordsList();
+ self::assertInstanceOf(KeywordList::class, $keywordList);
self::assertTrue($keywordList->isKeyword('table'));
}
@@ -608,9 +624,9 @@ public function testQuotedColumnInPrimaryKeyPropagation()
{
$table = new Table('`quoted`');
$table->addColumn('create', 'string');
- $table->setPrimaryKey(array('create'));
+ $table->setPrimaryKey(['create']);
- $sql = $this->_platform->getCreateTableSQL($table);
+ $sql = $this->platform->getCreateTableSQL($table);
self::assertEquals($this->getQuotedColumnInPrimaryKeySQL(), $sql);
}
@@ -626,9 +642,9 @@ public function testQuotedColumnInIndexPropagation()
{
$table = new Table('`quoted`');
$table->addColumn('create', 'string');
- $table->addIndex(array('create'));
+ $table->addIndex(['create']);
- $sql = $this->_platform->getCreateTableSQL($table);
+ $sql = $this->platform->getCreateTableSQL($table);
self::assertEquals($this->getQuotedColumnInIndexSQL(), $sql);
}
@@ -636,9 +652,9 @@ public function testQuotedNameInIndexSQL()
{
$table = new Table('test');
$table->addColumn('column1', 'string');
- $table->addIndex(array('column1'), '`key`');
+ $table->addIndex(['column1'], '`key`');
- $sql = $this->_platform->getCreateTableSQL($table);
+ $sql = $this->platform->getCreateTableSQL($table);
self::assertEquals($this->getQuotedNameInIndexSQL(), $sql);
}
@@ -658,7 +674,7 @@ public function testQuotedColumnInForeignKeyPropagation()
$foreignTable->addColumn('bar', 'string'); // Foreign column with non-reserved keyword as name (does not need quotation).
$foreignTable->addColumn('`foo-bar`', 'string'); // Foreign table with special character in name (needs quotation on some platforms, e.g. Sqlite).
- $table->addForeignKeyConstraint($foreignTable, array('create', 'foo', '`bar`'), array('create', 'bar', '`foo-bar`'), array(), 'FK_WITH_RESERVED_KEYWORD');
+ $table->addForeignKeyConstraint($foreignTable, ['create', 'foo', '`bar`'], ['create', 'bar', '`foo-bar`'], [], 'FK_WITH_RESERVED_KEYWORD');
// Foreign table with non-reserved keyword as name (does not need quotation).
$foreignTable = new Table('foo');
@@ -666,7 +682,7 @@ public function testQuotedColumnInForeignKeyPropagation()
$foreignTable->addColumn('bar', 'string'); // Foreign column with non-reserved keyword as name (does not need quotation).
$foreignTable->addColumn('`foo-bar`', 'string'); // Foreign table with special character in name (needs quotation on some platforms, e.g. Sqlite).
- $table->addForeignKeyConstraint($foreignTable, array('create', 'foo', '`bar`'), array('create', 'bar', '`foo-bar`'), array(), 'FK_WITH_NON_RESERVED_KEYWORD');
+ $table->addForeignKeyConstraint($foreignTable, ['create', 'foo', '`bar`'], ['create', 'bar', '`foo-bar`'], [], 'FK_WITH_NON_RESERVED_KEYWORD');
// Foreign table with special character in name (needs quotation on some platforms, e.g. Sqlite).
$foreignTable = new Table('`foo-bar`');
@@ -674,9 +690,9 @@ public function testQuotedColumnInForeignKeyPropagation()
$foreignTable->addColumn('bar', 'string'); // Foreign column with non-reserved keyword as name (does not need quotation).
$foreignTable->addColumn('`foo-bar`', 'string'); // Foreign table with special character in name (needs quotation on some platforms, e.g. Sqlite).
- $table->addForeignKeyConstraint($foreignTable, array('create', 'foo', '`bar`'), array('create', 'bar', '`foo-bar`'), array(), 'FK_WITH_INTENDED_QUOTATION');
+ $table->addForeignKeyConstraint($foreignTable, ['create', 'foo', '`bar`'], ['create', 'bar', '`foo-bar`'], [], 'FK_WITH_INTENDED_QUOTATION');
- $sql = $this->_platform->getCreateTableSQL($table, AbstractPlatform::CREATE_FOREIGNKEYS);
+ $sql = $this->platform->getCreateTableSQL($table, AbstractPlatform::CREATE_FOREIGNKEYS);
self::assertEquals($this->getQuotedColumnInForeignKeySQL(), $sql);
}
@@ -685,11 +701,11 @@ public function testQuotedColumnInForeignKeyPropagation()
*/
public function testQuotesReservedKeywordInUniqueConstraintDeclarationSQL()
{
- $index = new Index('select', array('foo'), true);
+ $index = new Index('select', ['foo'], true);
self::assertSame(
$this->getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(),
- $this->_platform->getUniqueConstraintDeclarationSQL('select', $index)
+ $this->platform->getUniqueConstraintDeclarationSQL('select', $index)
);
}
@@ -705,7 +721,7 @@ public function testQuotesReservedKeywordInTruncateTableSQL()
{
self::assertSame(
$this->getQuotesReservedKeywordInTruncateTableSQL(),
- $this->_platform->getTruncateTableSQL('select')
+ $this->platform->getTruncateTableSQL('select')
);
}
@@ -719,15 +735,15 @@ abstract protected function getQuotesReservedKeywordInTruncateTableSQL();
*/
public function testQuotesReservedKeywordInIndexDeclarationSQL()
{
- $index = new Index('select', array('foo'));
+ $index = new Index('select', ['foo']);
if (! $this->supportsInlineIndexDeclaration()) {
- $this->expectException('Doctrine\DBAL\DBALException');
+ $this->expectException(DBALException::class);
}
self::assertSame(
$this->getQuotesReservedKeywordInIndexDeclarationSQL(),
- $this->_platform->getIndexDeclarationSQL('select', $index)
+ $this->platform->getIndexDeclarationSQL('select', $index)
);
}
@@ -746,7 +762,7 @@ protected function supportsInlineIndexDeclaration()
public function testSupportsCommentOnStatement()
{
- self::assertSame($this->supportsCommentOnStatement(), $this->_platform->supportsCommentOnStatement());
+ self::assertSame($this->supportsCommentOnStatement(), $this->platform->supportsCommentOnStatement());
}
/**
@@ -762,7 +778,7 @@ protected function supportsCommentOnStatement()
*/
public function testGetCreateSchemaSQL()
{
- $this->_platform->getCreateSchemaSQL('schema');
+ $this->platform->getCreateSchemaSQL('schema');
}
/**
@@ -770,18 +786,20 @@ public function testGetCreateSchemaSQL()
*/
public function testAlterTableChangeQuotedColumn()
{
- $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('mytable');
- $tableDiff->fromTable = new \Doctrine\DBAL\Schema\Table('mytable');
- $tableDiff->changedColumns['foo'] = new \Doctrine\DBAL\Schema\ColumnDiff(
- 'select', new \Doctrine\DBAL\Schema\Column(
- 'select', \Doctrine\DBAL\Types\Type::getType('string')
+ $tableDiff = new TableDiff('mytable');
+ $tableDiff->fromTable = new Table('mytable');
+ $tableDiff->changedColumns['foo'] = new ColumnDiff(
+ 'select',
+ new Column(
+ 'select',
+ Type::getType('string')
),
- array('type')
+ ['type']
);
self::assertContains(
- $this->_platform->quoteIdentifier('select'),
- implode(';', $this->_platform->getAlterTableSQL($tableDiff))
+ $this->platform->quoteIdentifier('select'),
+ implode(';', $this->platform->getAlterTableSQL($tableDiff))
);
}
@@ -790,7 +808,7 @@ public function testAlterTableChangeQuotedColumn()
*/
public function testUsesSequenceEmulatedIdentityColumns()
{
- self::assertFalse($this->_platform->usesSequenceEmulatedIdentityColumns());
+ self::assertFalse($this->platform->usesSequenceEmulatedIdentityColumns());
}
/**
@@ -799,12 +817,12 @@ public function testUsesSequenceEmulatedIdentityColumns()
*/
public function testReturnsIdentitySequenceName()
{
- $this->_platform->getIdentitySequenceName('mytable', 'mycolumn');
+ $this->platform->getIdentitySequenceName('mytable', 'mycolumn');
}
public function testReturnsBinaryDefaultLength()
{
- self::assertSame($this->getBinaryDefaultLength(), $this->_platform->getBinaryDefaultLength());
+ self::assertSame($this->getBinaryDefaultLength(), $this->platform->getBinaryDefaultLength());
}
protected function getBinaryDefaultLength()
@@ -814,7 +832,7 @@ protected function getBinaryDefaultLength()
public function testReturnsBinaryMaxLength()
{
- self::assertSame($this->getBinaryMaxLength(), $this->_platform->getBinaryMaxLength());
+ self::assertSame($this->getBinaryMaxLength(), $this->platform->getBinaryMaxLength());
}
protected function getBinaryMaxLength()
@@ -827,7 +845,7 @@ protected function getBinaryMaxLength()
*/
public function testReturnsBinaryTypeDeclarationSQL()
{
- $this->_platform->getBinaryTypeDeclarationSQL(array());
+ $this->platform->getBinaryTypeDeclarationSQL([]);
}
public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL()
@@ -840,7 +858,7 @@ public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL()
*/
public function hasNativeJsonType()
{
- self::assertFalse($this->_platform->hasNativeJsonType());
+ self::assertFalse($this->platform->hasNativeJsonType());
}
/**
@@ -848,15 +866,15 @@ public function hasNativeJsonType()
*/
public function testReturnsJsonTypeDeclarationSQL()
{
- $column = array(
+ $column = [
'length' => 666,
'notnull' => true,
'type' => Type::getType('json_array'),
- );
+ ];
self::assertSame(
- $this->_platform->getClobTypeDeclarationSQL($column),
- $this->_platform->getJsonTypeDeclarationSQL($column)
+ $this->platform->getClobTypeDeclarationSQL($column),
+ $this->platform->getJsonTypeDeclarationSQL($column)
);
}
@@ -865,17 +883,17 @@ public function testReturnsJsonTypeDeclarationSQL()
*/
public function testAlterTableRenameIndex()
{
- $tableDiff = new TableDiff('mytable');
+ $tableDiff = new TableDiff('mytable');
$tableDiff->fromTable = new Table('mytable');
$tableDiff->fromTable->addColumn('id', 'integer');
- $tableDiff->fromTable->setPrimaryKey(array('id'));
- $tableDiff->renamedIndexes = array(
- 'idx_foo' => new Index('idx_bar', array('id'))
- );
+ $tableDiff->fromTable->setPrimaryKey(['id']);
+ $tableDiff->renamedIndexes = [
+ 'idx_foo' => new Index('idx_bar', ['id']),
+ ];
self::assertSame(
$this->getAlterTableRenameIndexSQL(),
- $this->_platform->getAlterTableSQL($tableDiff)
+ $this->platform->getAlterTableSQL($tableDiff)
);
}
@@ -884,10 +902,10 @@ public function testAlterTableRenameIndex()
*/
protected function getAlterTableRenameIndexSQL()
{
- return array(
+ return [
'DROP INDEX idx_foo',
'CREATE INDEX idx_bar ON mytable (id)',
- );
+ ];
}
/**
@@ -895,18 +913,18 @@ protected function getAlterTableRenameIndexSQL()
*/
public function testQuotesAlterTableRenameIndex()
{
- $tableDiff = new TableDiff('table');
+ $tableDiff = new TableDiff('table');
$tableDiff->fromTable = new Table('table');
$tableDiff->fromTable->addColumn('id', 'integer');
- $tableDiff->fromTable->setPrimaryKey(array('id'));
- $tableDiff->renamedIndexes = array(
- 'create' => new Index('select', array('id')),
- '`foo`' => new Index('`bar`', array('id')),
- );
+ $tableDiff->fromTable->setPrimaryKey(['id']);
+ $tableDiff->renamedIndexes = [
+ 'create' => new Index('select', ['id']),
+ '`foo`' => new Index('`bar`', ['id']),
+ ];
self::assertSame(
$this->getQuotedAlterTableRenameIndexSQL(),
- $this->_platform->getAlterTableSQL($tableDiff)
+ $this->platform->getAlterTableSQL($tableDiff)
);
}
@@ -915,12 +933,12 @@ public function testQuotesAlterTableRenameIndex()
*/
protected function getQuotedAlterTableRenameIndexSQL()
{
- return array(
+ return [
'DROP INDEX "create"',
'CREATE INDEX "select" ON "table" (id)',
'DROP INDEX "foo"',
'CREATE INDEX "bar" ON "table" (id)',
- );
+ ];
}
/**
@@ -930,44 +948,44 @@ public function testQuotesAlterTableRenameColumn()
{
$fromTable = new Table('mytable');
- $fromTable->addColumn('unquoted1', 'integer', array('comment' => 'Unquoted 1'));
- $fromTable->addColumn('unquoted2', 'integer', array('comment' => 'Unquoted 2'));
- $fromTable->addColumn('unquoted3', 'integer', array('comment' => 'Unquoted 3'));
+ $fromTable->addColumn('unquoted1', 'integer', ['comment' => 'Unquoted 1']);
+ $fromTable->addColumn('unquoted2', 'integer', ['comment' => 'Unquoted 2']);
+ $fromTable->addColumn('unquoted3', 'integer', ['comment' => 'Unquoted 3']);
- $fromTable->addColumn('create', 'integer', array('comment' => 'Reserved keyword 1'));
- $fromTable->addColumn('table', 'integer', array('comment' => 'Reserved keyword 2'));
- $fromTable->addColumn('select', 'integer', array('comment' => 'Reserved keyword 3'));
+ $fromTable->addColumn('create', 'integer', ['comment' => 'Reserved keyword 1']);
+ $fromTable->addColumn('table', 'integer', ['comment' => 'Reserved keyword 2']);
+ $fromTable->addColumn('select', 'integer', ['comment' => 'Reserved keyword 3']);
- $fromTable->addColumn('`quoted1`', 'integer', array('comment' => 'Quoted 1'));
- $fromTable->addColumn('`quoted2`', 'integer', array('comment' => 'Quoted 2'));
- $fromTable->addColumn('`quoted3`', 'integer', array('comment' => 'Quoted 3'));
+ $fromTable->addColumn('`quoted1`', 'integer', ['comment' => 'Quoted 1']);
+ $fromTable->addColumn('`quoted2`', 'integer', ['comment' => 'Quoted 2']);
+ $fromTable->addColumn('`quoted3`', 'integer', ['comment' => 'Quoted 3']);
$toTable = new Table('mytable');
- $toTable->addColumn('unquoted', 'integer', array('comment' => 'Unquoted 1')); // unquoted -> unquoted
- $toTable->addColumn('where', 'integer', array('comment' => 'Unquoted 2')); // unquoted -> reserved keyword
- $toTable->addColumn('`foo`', 'integer', array('comment' => 'Unquoted 3')); // unquoted -> quoted
+ $toTable->addColumn('unquoted', 'integer', ['comment' => 'Unquoted 1']); // unquoted -> unquoted
+ $toTable->addColumn('where', 'integer', ['comment' => 'Unquoted 2']); // unquoted -> reserved keyword
+ $toTable->addColumn('`foo`', 'integer', ['comment' => 'Unquoted 3']); // unquoted -> quoted
- $toTable->addColumn('reserved_keyword', 'integer', array('comment' => 'Reserved keyword 1')); // reserved keyword -> unquoted
- $toTable->addColumn('from', 'integer', array('comment' => 'Reserved keyword 2')); // reserved keyword -> reserved keyword
- $toTable->addColumn('`bar`', 'integer', array('comment' => 'Reserved keyword 3')); // reserved keyword -> quoted
+ $toTable->addColumn('reserved_keyword', 'integer', ['comment' => 'Reserved keyword 1']); // reserved keyword -> unquoted
+ $toTable->addColumn('from', 'integer', ['comment' => 'Reserved keyword 2']); // reserved keyword -> reserved keyword
+ $toTable->addColumn('`bar`', 'integer', ['comment' => 'Reserved keyword 3']); // reserved keyword -> quoted
- $toTable->addColumn('quoted', 'integer', array('comment' => 'Quoted 1')); // quoted -> unquoted
- $toTable->addColumn('and', 'integer', array('comment' => 'Quoted 2')); // quoted -> reserved keyword
- $toTable->addColumn('`baz`', 'integer', array('comment' => 'Quoted 3')); // quoted -> quoted
+ $toTable->addColumn('quoted', 'integer', ['comment' => 'Quoted 1']); // quoted -> unquoted
+ $toTable->addColumn('and', 'integer', ['comment' => 'Quoted 2']); // quoted -> reserved keyword
+ $toTable->addColumn('`baz`', 'integer', ['comment' => 'Quoted 3']); // quoted -> quoted
$comparator = new Comparator();
self::assertEquals(
$this->getQuotedAlterTableRenameColumnSQL(),
- $this->_platform->getAlterTableSQL($comparator->diffTable($fromTable, $toTable))
+ $this->platform->getAlterTableSQL($comparator->diffTable($fromTable, $toTable))
);
}
/**
* Returns SQL statements for {@link testQuotesAlterTableRenameColumn}.
*
- * @return array
+ * @return string[]
*
* @group DBAL-835
*/
@@ -980,36 +998,36 @@ public function testQuotesAlterTableChangeColumnLength()
{
$fromTable = new Table('mytable');
- $fromTable->addColumn('unquoted1', 'string', array('comment' => 'Unquoted 1', 'length' => 10));
- $fromTable->addColumn('unquoted2', 'string', array('comment' => 'Unquoted 2', 'length' => 10));
- $fromTable->addColumn('unquoted3', 'string', array('comment' => 'Unquoted 3', 'length' => 10));
+ $fromTable->addColumn('unquoted1', 'string', ['comment' => 'Unquoted 1', 'length' => 10]);
+ $fromTable->addColumn('unquoted2', 'string', ['comment' => 'Unquoted 2', 'length' => 10]);
+ $fromTable->addColumn('unquoted3', 'string', ['comment' => 'Unquoted 3', 'length' => 10]);
- $fromTable->addColumn('create', 'string', array('comment' => 'Reserved keyword 1', 'length' => 10));
- $fromTable->addColumn('table', 'string', array('comment' => 'Reserved keyword 2', 'length' => 10));
- $fromTable->addColumn('select', 'string', array('comment' => 'Reserved keyword 3', 'length' => 10));
+ $fromTable->addColumn('create', 'string', ['comment' => 'Reserved keyword 1', 'length' => 10]);
+ $fromTable->addColumn('table', 'string', ['comment' => 'Reserved keyword 2', 'length' => 10]);
+ $fromTable->addColumn('select', 'string', ['comment' => 'Reserved keyword 3', 'length' => 10]);
$toTable = new Table('mytable');
- $toTable->addColumn('unquoted1', 'string', array('comment' => 'Unquoted 1', 'length' => 255));
- $toTable->addColumn('unquoted2', 'string', array('comment' => 'Unquoted 2', 'length' => 255));
- $toTable->addColumn('unquoted3', 'string', array('comment' => 'Unquoted 3', 'length' => 255));
+ $toTable->addColumn('unquoted1', 'string', ['comment' => 'Unquoted 1', 'length' => 255]);
+ $toTable->addColumn('unquoted2', 'string', ['comment' => 'Unquoted 2', 'length' => 255]);
+ $toTable->addColumn('unquoted3', 'string', ['comment' => 'Unquoted 3', 'length' => 255]);
- $toTable->addColumn('create', 'string', array('comment' => 'Reserved keyword 1', 'length' => 255));
- $toTable->addColumn('table', 'string', array('comment' => 'Reserved keyword 2', 'length' => 255));
- $toTable->addColumn('select', 'string', array('comment' => 'Reserved keyword 3', 'length' => 255));
+ $toTable->addColumn('create', 'string', ['comment' => 'Reserved keyword 1', 'length' => 255]);
+ $toTable->addColumn('table', 'string', ['comment' => 'Reserved keyword 2', 'length' => 255]);
+ $toTable->addColumn('select', 'string', ['comment' => 'Reserved keyword 3', 'length' => 255]);
$comparator = new Comparator();
self::assertEquals(
$this->getQuotedAlterTableChangeColumnLengthSQL(),
- $this->_platform->getAlterTableSQL($comparator->diffTable($fromTable, $toTable))
+ $this->platform->getAlterTableSQL($comparator->diffTable($fromTable, $toTable))
);
}
/**
* Returns SQL statements for {@link testQuotesAlterTableChangeColumnLength}.
*
- * @return array
+ * @return string[]
*
* @group DBAL-835
*/
@@ -1020,17 +1038,17 @@ abstract protected function getQuotedAlterTableChangeColumnLengthSQL();
*/
public function testAlterTableRenameIndexInSchema()
{
- $tableDiff = new TableDiff('myschema.mytable');
+ $tableDiff = new TableDiff('myschema.mytable');
$tableDiff->fromTable = new Table('myschema.mytable');
$tableDiff->fromTable->addColumn('id', 'integer');
- $tableDiff->fromTable->setPrimaryKey(array('id'));
- $tableDiff->renamedIndexes = array(
- 'idx_foo' => new Index('idx_bar', array('id'))
- );
+ $tableDiff->fromTable->setPrimaryKey(['id']);
+ $tableDiff->renamedIndexes = [
+ 'idx_foo' => new Index('idx_bar', ['id']),
+ ];
self::assertSame(
$this->getAlterTableRenameIndexInSchemaSQL(),
- $this->_platform->getAlterTableSQL($tableDiff)
+ $this->platform->getAlterTableSQL($tableDiff)
);
}
@@ -1039,10 +1057,10 @@ public function testAlterTableRenameIndexInSchema()
*/
protected function getAlterTableRenameIndexInSchemaSQL()
{
- return array(
+ return [
'DROP INDEX idx_foo',
'CREATE INDEX idx_bar ON myschema.mytable (id)',
- );
+ ];
}
/**
@@ -1050,18 +1068,18 @@ protected function getAlterTableRenameIndexInSchemaSQL()
*/
public function testQuotesAlterTableRenameIndexInSchema()
{
- $tableDiff = new TableDiff('`schema`.table');
+ $tableDiff = new TableDiff('`schema`.table');
$tableDiff->fromTable = new Table('`schema`.table');
$tableDiff->fromTable->addColumn('id', 'integer');
- $tableDiff->fromTable->setPrimaryKey(array('id'));
- $tableDiff->renamedIndexes = array(
- 'create' => new Index('select', array('id')),
- '`foo`' => new Index('`bar`', array('id')),
- );
+ $tableDiff->fromTable->setPrimaryKey(['id']);
+ $tableDiff->renamedIndexes = [
+ 'create' => new Index('select', ['id']),
+ '`foo`' => new Index('`bar`', ['id']),
+ ];
self::assertSame(
$this->getQuotedAlterTableRenameIndexInSchemaSQL(),
- $this->_platform->getAlterTableSQL($tableDiff)
+ $this->platform->getAlterTableSQL($tableDiff)
);
}
@@ -1070,12 +1088,12 @@ public function testQuotesAlterTableRenameIndexInSchema()
*/
protected function getQuotedAlterTableRenameIndexInSchemaSQL()
{
- return array(
+ return [
'DROP INDEX "schema"."create"',
'CREATE INDEX "select" ON "schema"."table" (id)',
'DROP INDEX "schema"."foo"',
'CREATE INDEX "bar" ON "schema"."table" (id)',
- );
+ ];
}
/**
@@ -1083,20 +1101,20 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL()
*/
public function testQuotesDropForeignKeySQL()
{
- if (! $this->_platform->supportsForeignKeyConstraints()) {
+ if (! $this->platform->supportsForeignKeyConstraints()) {
$this->markTestSkipped(
- sprintf('%s does not support foreign key constraints.', get_class($this->_platform))
+ sprintf('%s does not support foreign key constraints.', get_class($this->platform))
);
}
- $tableName = 'table';
- $table = new Table($tableName);
+ $tableName = 'table';
+ $table = new Table($tableName);
$foreignKeyName = 'select';
- $foreignKey = new ForeignKeyConstraint(array(), 'foo', array(), 'select');
- $expectedSql = $this->getQuotesDropForeignKeySQL();
+ $foreignKey = new ForeignKeyConstraint([], 'foo', [], 'select');
+ $expectedSql = $this->getQuotesDropForeignKeySQL();
- self::assertSame($expectedSql, $this->_platform->getDropForeignKeySQL($foreignKeyName, $tableName));
- self::assertSame($expectedSql, $this->_platform->getDropForeignKeySQL($foreignKey, $table));
+ self::assertSame($expectedSql, $this->platform->getDropForeignKeySQL($foreignKeyName, $tableName));
+ self::assertSame($expectedSql, $this->platform->getDropForeignKeySQL($foreignKey, $table));
}
protected function getQuotesDropForeignKeySQL()
@@ -1109,14 +1127,14 @@ protected function getQuotesDropForeignKeySQL()
*/
public function testQuotesDropConstraintSQL()
{
- $tableName = 'table';
- $table = new Table($tableName);
+ $tableName = 'table';
+ $table = new Table($tableName);
$constraintName = 'select';
- $constraint = new ForeignKeyConstraint(array(), 'foo', array(), 'select');
- $expectedSql = $this->getQuotesDropConstraintSQL();
+ $constraint = new ForeignKeyConstraint([], 'foo', [], 'select');
+ $expectedSql = $this->getQuotesDropConstraintSQL();
- self::assertSame($expectedSql, $this->_platform->getDropConstraintSQL($constraintName, $tableName));
- self::assertSame($expectedSql, $this->_platform->getDropConstraintSQL($constraint, $table));
+ self::assertSame($expectedSql, $this->platform->getDropConstraintSQL($constraintName, $tableName));
+ self::assertSame($expectedSql, $this->platform->getDropConstraintSQL($constraint, $table));
}
protected function getQuotesDropConstraintSQL()
@@ -1131,7 +1149,7 @@ protected function getStringLiteralQuoteCharacter()
public function testGetStringLiteralQuoteCharacter()
{
- self::assertSame($this->getStringLiteralQuoteCharacter(), $this->_platform->getStringLiteralQuoteCharacter());
+ self::assertSame($this->getStringLiteralQuoteCharacter(), $this->platform->getStringLiteralQuoteCharacter());
}
protected function getQuotedCommentOnColumnSQLWithoutQuoteCharacter()
@@ -1143,7 +1161,7 @@ public function testGetCommentOnColumnSQLWithoutQuoteCharacter()
{
self::assertEquals(
$this->getQuotedCommentOnColumnSQLWithoutQuoteCharacter(),
- $this->_platform->getCommentOnColumnSQL('mytable', 'id', 'This is a comment')
+ $this->platform->getCommentOnColumnSQL('mytable', 'id', 'This is a comment')
);
}
@@ -1158,14 +1176,14 @@ public function testGetCommentOnColumnSQLWithQuoteCharacter()
self::assertEquals(
$this->getQuotedCommentOnColumnSQLWithQuoteCharacter(),
- $this->_platform->getCommentOnColumnSQL('mytable', 'id', "It" . $c . "s a quote !")
+ $this->platform->getCommentOnColumnSQL('mytable', 'id', 'It' . $c . 's a quote !')
);
}
/**
- * @return array
- *
* @see testGetCommentOnColumnSQL
+ *
+ * @return string[]
*/
abstract protected function getCommentOnColumnSQL();
@@ -1176,41 +1194,40 @@ public function testGetCommentOnColumnSQL()
{
self::assertSame(
$this->getCommentOnColumnSQL(),
- array(
- $this->_platform->getCommentOnColumnSQL('foo', 'bar', 'comment'), // regular identifiers
- $this->_platform->getCommentOnColumnSQL('`Foo`', '`BAR`', 'comment'), // explicitly quoted identifiers
- $this->_platform->getCommentOnColumnSQL('select', 'from', 'comment'), // reserved keyword identifiers
- )
+ [
+ $this->platform->getCommentOnColumnSQL('foo', 'bar', 'comment'), // regular identifiers
+ $this->platform->getCommentOnColumnSQL('`Foo`', '`BAR`', 'comment'), // explicitly quoted identifiers
+ $this->platform->getCommentOnColumnSQL('select', 'from', 'comment'), // reserved keyword identifiers
+ ]
);
}
/**
* @group DBAL-1176
- *
* @dataProvider getGeneratesInlineColumnCommentSQL
*/
public function testGeneratesInlineColumnCommentSQL($comment, $expectedSql)
{
- if (! $this->_platform->supportsInlineColumnComments()) {
- $this->markTestSkipped(sprintf('%s does not support inline column comments.', get_class($this->_platform)));
+ if (! $this->platform->supportsInlineColumnComments()) {
+ $this->markTestSkipped(sprintf('%s does not support inline column comments.', get_class($this->platform)));
}
- self::assertSame($expectedSql, $this->_platform->getInlineColumnCommentSQL($comment));
+ self::assertSame($expectedSql, $this->platform->getInlineColumnCommentSQL($comment));
}
public function getGeneratesInlineColumnCommentSQL()
{
- return array(
- 'regular comment' => array('Regular comment', $this->getInlineColumnRegularCommentSQL()),
- 'comment requiring escaping' => array(
+ return [
+ 'regular comment' => ['Regular comment', $this->getInlineColumnRegularCommentSQL()],
+ 'comment requiring escaping' => [
sprintf(
'Using inline comment delimiter %s works',
$this->getInlineColumnCommentDelimiter()
),
- $this->getInlineColumnCommentRequiringEscapingSQL()
- ),
- 'empty comment' => array('', $this->getInlineColumnEmptyCommentSQL()),
- );
+ $this->getInlineColumnCommentRequiringEscapingSQL(),
+ ],
+ 'empty comment' => ['', $this->getInlineColumnEmptyCommentSQL()],
+ ];
}
protected function getInlineColumnCommentDelimiter()
@@ -1253,15 +1270,15 @@ protected function getQuotedStringLiteralQuoteCharacter()
*/
public function testThrowsExceptionOnGeneratingInlineColumnCommentSQLIfUnsupported()
{
- if ($this->_platform->supportsInlineColumnComments()) {
- $this->markTestSkipped(sprintf('%s supports inline column comments.', get_class($this->_platform)));
+ if ($this->platform->supportsInlineColumnComments()) {
+ $this->markTestSkipped(sprintf('%s supports inline column comments.', get_class($this->platform)));
}
- $this->expectException('Doctrine\DBAL\DBALException');
+ $this->expectException(DBALException::class);
$this->expectExceptionMessage("Operation 'Doctrine\\DBAL\\Platforms\\AbstractPlatform::getInlineColumnCommentSQL' is not supported by platform.");
$this->expectExceptionCode(0);
- $this->_platform->getInlineColumnCommentSQL('unsupported');
+ $this->platform->getInlineColumnCommentSQL('unsupported');
}
public function testQuoteStringLiteral()
@@ -1270,26 +1287,25 @@ public function testQuoteStringLiteral()
self::assertEquals(
$this->getQuotedStringLiteralWithoutQuoteCharacter(),
- $this->_platform->quoteStringLiteral('No quote')
+ $this->platform->quoteStringLiteral('No quote')
);
self::assertEquals(
$this->getQuotedStringLiteralWithQuoteCharacter(),
- $this->_platform->quoteStringLiteral('It' . $c . 's a quote')
+ $this->platform->quoteStringLiteral('It' . $c . 's a quote')
);
self::assertEquals(
$this->getQuotedStringLiteralQuoteCharacter(),
- $this->_platform->quoteStringLiteral($c)
+ $this->platform->quoteStringLiteral($c)
);
}
/**
* @group DBAL-423
- *
* @expectedException \Doctrine\DBAL\DBALException
*/
public function testReturnsGuidTypeDeclarationSQL()
{
- $this->_platform->getGuidTypeDeclarationSQL(array());
+ $this->platform->getGuidTypeDeclarationSQL([]);
}
/**
@@ -1301,22 +1317,22 @@ public function testGeneratesAlterTableRenameColumnSQL()
$table->addColumn(
'bar',
'integer',
- array('notnull' => true, 'default' => 666, 'comment' => 'rename test')
+ ['notnull' => true, 'default' => 666, 'comment' => 'rename test']
);
- $tableDiff = new TableDiff('foo');
- $tableDiff->fromTable = $table;
+ $tableDiff = new TableDiff('foo');
+ $tableDiff->fromTable = $table;
$tableDiff->renamedColumns['bar'] = new Column(
'baz',
Type::getType('integer'),
- array('notnull' => true, 'default' => 666, 'comment' => 'rename test')
+ ['notnull' => true, 'default' => 666, 'comment' => 'rename test']
);
- self::assertSame($this->getAlterTableRenameColumnSQL(), $this->_platform->getAlterTableSQL($tableDiff));
+ self::assertSame($this->getAlterTableRenameColumnSQL(), $this->platform->getAlterTableSQL($tableDiff));
}
/**
- * @return array
+ * @return string[]
*/
abstract public function getAlterTableRenameColumnSQL();
@@ -1332,33 +1348,33 @@ public function testQuotesTableIdentifiersInAlterTableSQL()
$table->addColumn('fk3', 'integer');
$table->addColumn('bar', 'integer');
$table->addColumn('baz', 'integer');
- $table->addForeignKeyConstraint('fk_table', array('fk'), array('id'), array(), 'fk1');
- $table->addForeignKeyConstraint('fk_table', array('fk2'), array('id'), array(), 'fk2');
+ $table->addForeignKeyConstraint('fk_table', ['fk'], ['id'], [], 'fk1');
+ $table->addForeignKeyConstraint('fk_table', ['fk2'], ['id'], [], 'fk2');
- $tableDiff = new TableDiff('"foo"');
- $tableDiff->fromTable = $table;
- $tableDiff->newName = 'table';
- $tableDiff->addedColumns['bloo'] = new Column('bloo', Type::getType('integer'));
+ $tableDiff = new TableDiff('"foo"');
+ $tableDiff->fromTable = $table;
+ $tableDiff->newName = 'table';
+ $tableDiff->addedColumns['bloo'] = new Column('bloo', Type::getType('integer'));
$tableDiff->changedColumns['bar'] = new ColumnDiff(
'bar',
- new Column('bar', Type::getType('integer'), array('notnull' => false)),
- array('notnull'),
+ new Column('bar', Type::getType('integer'), ['notnull' => false]),
+ ['notnull'],
$table->getColumn('bar')
);
- $tableDiff->renamedColumns['id'] = new Column('war', Type::getType('integer'));
+ $tableDiff->renamedColumns['id'] = new Column('war', Type::getType('integer'));
$tableDiff->removedColumns['baz'] = new Column('baz', Type::getType('integer'));
- $tableDiff->addedForeignKeys[] = new ForeignKeyConstraint(array('fk3'), 'fk_table', array('id'), 'fk_add');
- $tableDiff->changedForeignKeys[] = new ForeignKeyConstraint(array('fk2'), 'fk_table2', array('id'), 'fk2');
- $tableDiff->removedForeignKeys[] = new ForeignKeyConstraint(array('fk'), 'fk_table', array('id'), 'fk1');
+ $tableDiff->addedForeignKeys[] = new ForeignKeyConstraint(['fk3'], 'fk_table', ['id'], 'fk_add');
+ $tableDiff->changedForeignKeys[] = new ForeignKeyConstraint(['fk2'], 'fk_table2', ['id'], 'fk2');
+ $tableDiff->removedForeignKeys[] = new ForeignKeyConstraint(['fk'], 'fk_table', ['id'], 'fk1');
self::assertSame(
$this->getQuotesTableIdentifiersInAlterTableSQL(),
- $this->_platform->getAlterTableSQL($tableDiff)
+ $this->platform->getAlterTableSQL($tableDiff)
);
}
/**
- * @return array
+ * @return string[]
*/
abstract protected function getQuotesTableIdentifiersInAlterTableSQL();
@@ -1367,21 +1383,23 @@ abstract protected function getQuotesTableIdentifiersInAlterTableSQL();
*/
public function testAlterStringToFixedString()
{
-
$table = new Table('mytable');
- $table->addColumn('name', 'string', array('length' => 2));
+ $table->addColumn('name', 'string', ['length' => 2]);
- $tableDiff = new TableDiff('mytable');
+ $tableDiff = new TableDiff('mytable');
$tableDiff->fromTable = $table;
- $tableDiff->changedColumns['name'] = new \Doctrine\DBAL\Schema\ColumnDiff(
- 'name', new \Doctrine\DBAL\Schema\Column(
- 'name', \Doctrine\DBAL\Types\Type::getType('string'), array('fixed' => true, 'length' => 2)
+ $tableDiff->changedColumns['name'] = new ColumnDiff(
+ 'name',
+ new Column(
+ 'name',
+ Type::getType('string'),
+ ['fixed' => true, 'length' => 2]
),
- array('fixed')
+ ['fixed']
);
- $sql = $this->_platform->getAlterTableSQL($tableDiff);
+ $sql = $this->platform->getAlterTableSQL($tableDiff);
$expectedSql = $this->getAlterStringToFixedStringSQL();
@@ -1389,7 +1407,7 @@ public function testAlterStringToFixedString()
}
/**
- * @return array
+ * @return string[]
*/
abstract protected function getAlterStringToFixedStringSQL();
@@ -1400,87 +1418,89 @@ public function testGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
{
$foreignTable = new Table('foreign_table');
$foreignTable->addColumn('id', 'integer');
- $foreignTable->setPrimaryKey(array('id'));
+ $foreignTable->setPrimaryKey(['id']);
$primaryTable = new Table('mytable');
$primaryTable->addColumn('foo', 'integer');
$primaryTable->addColumn('bar', 'integer');
$primaryTable->addColumn('baz', 'integer');
- $primaryTable->addIndex(array('foo'), 'idx_foo');
- $primaryTable->addIndex(array('bar'), 'idx_bar');
- $primaryTable->addForeignKeyConstraint($foreignTable, array('foo'), array('id'), array(), 'fk_foo');
- $primaryTable->addForeignKeyConstraint($foreignTable, array('bar'), array('id'), array(), 'fk_bar');
+ $primaryTable->addIndex(['foo'], 'idx_foo');
+ $primaryTable->addIndex(['bar'], 'idx_bar');
+ $primaryTable->addForeignKeyConstraint($foreignTable, ['foo'], ['id'], [], 'fk_foo');
+ $primaryTable->addForeignKeyConstraint($foreignTable, ['bar'], ['id'], [], 'fk_bar');
- $tableDiff = new TableDiff('mytable');
- $tableDiff->fromTable = $primaryTable;
- $tableDiff->renamedIndexes['idx_foo'] = new Index('idx_foo_renamed', array('foo'));
+ $tableDiff = new TableDiff('mytable');
+ $tableDiff->fromTable = $primaryTable;
+ $tableDiff->renamedIndexes['idx_foo'] = new Index('idx_foo_renamed', ['foo']);
self::assertSame(
$this->getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(),
- $this->_platform->getAlterTableSQL($tableDiff)
+ $this->platform->getAlterTableSQL($tableDiff)
);
}
/**
- * @return array
+ * @return string[]
*/
abstract protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL();
/**
- * @group DBAL-1082
+ * @param mixed[] $column
*
+ * @group DBAL-1082
* @dataProvider getGeneratesDecimalTypeDeclarationSQL
*/
public function testGeneratesDecimalTypeDeclarationSQL(array $column, $expectedSql)
{
- self::assertSame($expectedSql, $this->_platform->getDecimalTypeDeclarationSQL($column));
+ self::assertSame($expectedSql, $this->platform->getDecimalTypeDeclarationSQL($column));
}
/**
- * @return array
+ * @return mixed[]
*/
public function getGeneratesDecimalTypeDeclarationSQL()
{
- return array(
- array(array(), 'NUMERIC(10, 0)'),
- array(array('unsigned' => true), 'NUMERIC(10, 0)'),
- array(array('unsigned' => false), 'NUMERIC(10, 0)'),
- array(array('precision' => 5), 'NUMERIC(5, 0)'),
- array(array('scale' => 5), 'NUMERIC(10, 5)'),
- array(array('precision' => 8, 'scale' => 2), 'NUMERIC(8, 2)'),
- );
+ return [
+ [[], 'NUMERIC(10, 0)'],
+ [['unsigned' => true], 'NUMERIC(10, 0)'],
+ [['unsigned' => false], 'NUMERIC(10, 0)'],
+ [['precision' => 5], 'NUMERIC(5, 0)'],
+ [['scale' => 5], 'NUMERIC(10, 5)'],
+ [['precision' => 8, 'scale' => 2], 'NUMERIC(8, 2)'],
+ ];
}
/**
- * @group DBAL-1082
+ * @param mixed[] $column
*
+ * @group DBAL-1082
* @dataProvider getGeneratesFloatDeclarationSQL
*/
public function testGeneratesFloatDeclarationSQL(array $column, $expectedSql)
{
- self::assertSame($expectedSql, $this->_platform->getFloatDeclarationSQL($column));
+ self::assertSame($expectedSql, $this->platform->getFloatDeclarationSQL($column));
}
/**
- * @return array
+ * @return mixed[]
*/
public function getGeneratesFloatDeclarationSQL()
{
- return array(
- array(array(), 'DOUBLE PRECISION'),
- array(array('unsigned' => true), 'DOUBLE PRECISION'),
- array(array('unsigned' => false), 'DOUBLE PRECISION'),
- array(array('precision' => 5), 'DOUBLE PRECISION'),
- array(array('scale' => 5), 'DOUBLE PRECISION'),
- array(array('precision' => 8, 'scale' => 2), 'DOUBLE PRECISION'),
- );
+ return [
+ [[], 'DOUBLE PRECISION'],
+ [['unsigned' => true], 'DOUBLE PRECISION'],
+ [['unsigned' => false], 'DOUBLE PRECISION'],
+ [['precision' => 5], 'DOUBLE PRECISION'],
+ [['scale' => 5], 'DOUBLE PRECISION'],
+ [['precision' => 8, 'scale' => 2], 'DOUBLE PRECISION'],
+ ];
}
public function testItEscapesStringsForLike() : void
{
self::assertSame(
'\_25\% off\_ your next purchase \\\\o/',
- $this->_platform->escapeStringForLike('_25% off_ your next purchase \o/', '\\')
+ $this->platform->escapeStringForLike('_25% off_ your next purchase \o/', '\\')
);
}
@@ -1490,7 +1510,7 @@ public function testZeroOffsetWithoutLimitIsIgnored() : void
self::assertSame(
$query,
- $this->_platform->modifyLimitQuery($query, null, 0)
+ $this->platform->modifyLimitQuery($query, null, 0)
);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
index bca9063c55c..5c0da268107 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php
@@ -3,11 +3,15 @@
namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\DBAL\Schema\Column;
+use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Comparator;
+use Doctrine\DBAL\Schema\ForeignKeyConstraint;
+use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\Type;
+use function sprintf;
abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCase
{
@@ -18,15 +22,15 @@ public function getGenerateTableSql()
public function getGenerateTableWithMultiColumnUniqueIndexSql()
{
- return array(
+ return [
'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)',
- 'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)'
- );
+ 'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)',
+ ];
}
public function getGenerateAlterTableSql()
{
- return array(
+ return [
'ALTER TABLE mytable ADD quota INT DEFAULT NULL',
'ALTER TABLE mytable DROP foo',
'ALTER TABLE mytable ALTER bar TYPE VARCHAR(255)',
@@ -36,7 +40,7 @@ public function getGenerateAlterTableSql()
"ALTER TABLE mytable ALTER bloo SET DEFAULT 'false'",
'ALTER TABLE mytable ALTER bloo SET NOT NULL',
'ALTER TABLE mytable RENAME TO userlist',
- );
+ ];
}
public function getGenerateIndexSql()
@@ -51,100 +55,127 @@ public function getGenerateForeignKeySql()
public function testGeneratesForeignKeySqlForNonStandardOptions()
{
- $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
- array('foreign_id'), 'my_table', array('id'), 'my_fk', array('onDelete' => 'CASCADE')
+ $foreignKey = new ForeignKeyConstraint(
+ ['foreign_id'],
+ 'my_table',
+ ['id'],
+ 'my_fk',
+ ['onDelete' => 'CASCADE']
);
self::assertEquals(
- "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE",
- $this->_platform->getForeignKeyDeclarationSQL($foreignKey)
+ 'CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE',
+ $this->platform->getForeignKeyDeclarationSQL($foreignKey)
);
- $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
- array('foreign_id'), 'my_table', array('id'), 'my_fk', array('match' => 'full')
+ $foreignKey = new ForeignKeyConstraint(
+ ['foreign_id'],
+ 'my_table',
+ ['id'],
+ 'my_fk',
+ ['match' => 'full']
);
self::assertEquals(
- "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) MATCH full NOT DEFERRABLE INITIALLY IMMEDIATE",
- $this->_platform->getForeignKeyDeclarationSQL($foreignKey)
+ 'CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) MATCH full NOT DEFERRABLE INITIALLY IMMEDIATE',
+ $this->platform->getForeignKeyDeclarationSQL($foreignKey)
);
- $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
- array('foreign_id'), 'my_table', array('id'), 'my_fk', array('deferrable' => true)
+ $foreignKey = new ForeignKeyConstraint(
+ ['foreign_id'],
+ 'my_table',
+ ['id'],
+ 'my_fk',
+ ['deferrable' => true]
);
self::assertEquals(
- "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) DEFERRABLE INITIALLY IMMEDIATE",
- $this->_platform->getForeignKeyDeclarationSQL($foreignKey)
+ 'CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) DEFERRABLE INITIALLY IMMEDIATE',
+ $this->platform->getForeignKeyDeclarationSQL($foreignKey)
);
- $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
- array('foreign_id'), 'my_table', array('id'), 'my_fk', array('deferred' => true)
+ $foreignKey = new ForeignKeyConstraint(
+ ['foreign_id'],
+ 'my_table',
+ ['id'],
+ 'my_fk',
+ ['deferred' => true]
);
self::assertEquals(
- "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) NOT DEFERRABLE INITIALLY DEFERRED",
- $this->_platform->getForeignKeyDeclarationSQL($foreignKey)
+ 'CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) NOT DEFERRABLE INITIALLY DEFERRED',
+ $this->platform->getForeignKeyDeclarationSQL($foreignKey)
);
- $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
- array('foreign_id'), 'my_table', array('id'), 'my_fk', array('feferred' => true)
+ $foreignKey = new ForeignKeyConstraint(
+ ['foreign_id'],
+ 'my_table',
+ ['id'],
+ 'my_fk',
+ ['feferred' => true]
);
self::assertEquals(
- "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) NOT DEFERRABLE INITIALLY DEFERRED",
- $this->_platform->getForeignKeyDeclarationSQL($foreignKey)
+ 'CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) NOT DEFERRABLE INITIALLY DEFERRED',
+ $this->platform->getForeignKeyDeclarationSQL($foreignKey)
);
- $foreignKey = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(
- array('foreign_id'), 'my_table', array('id'), 'my_fk', array('deferrable' => true, 'deferred' => true, 'match' => 'full')
+ $foreignKey = new ForeignKeyConstraint(
+ ['foreign_id'],
+ 'my_table',
+ ['id'],
+ 'my_fk',
+ ['deferrable' => true, 'deferred' => true, 'match' => 'full']
);
self::assertEquals(
- "CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) MATCH full DEFERRABLE INITIALLY DEFERRED",
- $this->_platform->getForeignKeyDeclarationSQL($foreignKey)
+ 'CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) MATCH full DEFERRABLE INITIALLY DEFERRED',
+ $this->platform->getForeignKeyDeclarationSQL($foreignKey)
);
}
public function testGeneratesSqlSnippets()
{
- self::assertEquals('SIMILAR TO', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct');
- self::assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
- self::assertEquals('column1 || column2 || column3', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
- self::assertEquals('SUBSTRING(column FROM 5)', $this->_platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct');
- self::assertEquals('SUBSTRING(column FROM 1 FOR 5)', $this->_platform->getSubstringExpression('column', 1, 5), 'Substring expression with length is not correct');
+ self::assertEquals('SIMILAR TO', $this->platform->getRegexpExpression(), 'Regular expression operator is not correct');
+ self::assertEquals('"', $this->platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
+ self::assertEquals('column1 || column2 || column3', $this->platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
+ self::assertEquals('SUBSTRING(column FROM 5)', $this->platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct');
+ self::assertEquals('SUBSTRING(column FROM 1 FOR 5)', $this->platform->getSubstringExpression('column', 1, 5), 'Substring expression with length is not correct');
}
public function testGeneratesTransactionCommands()
{
self::assertEquals(
'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ UNCOMMITTED',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_UNCOMMITTED)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_UNCOMMITTED)
);
self::assertEquals(
'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_COMMITTED)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_COMMITTED)
);
self::assertEquals(
'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL REPEATABLE READ',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::REPEATABLE_READ)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::REPEATABLE_READ)
);
self::assertEquals(
'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::SERIALIZABLE)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::SERIALIZABLE)
);
}
public function testGeneratesDDLSnippets()
{
- self::assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar'));
- self::assertEquals('DROP DATABASE foobar', $this->_platform->getDropDatabaseSQL('foobar'));
- self::assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));
+ self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar'));
+ self::assertEquals('DROP DATABASE foobar', $this->platform->getDropDatabaseSQL('foobar'));
+ self::assertEquals('DROP TABLE foobar', $this->platform->getDropTableSQL('foobar'));
}
public function testGenerateTableWithAutoincrement()
{
- $table = new \Doctrine\DBAL\Schema\Table('autoinc_table');
+ $table = new Table('autoinc_table');
$column = $table->addColumn('id', 'integer');
$column->setAutoincrement(true);
- self::assertEquals(array('CREATE TABLE autoinc_table (id SERIAL NOT NULL)'), $this->_platform->getCreateTableSQL($table));
+ self::assertEquals(['CREATE TABLE autoinc_table (id SERIAL NOT NULL)'], $this->platform->getCreateTableSQL($table));
}
+ /**
+ * @return string[][]
+ */
public static function serialTypes() : array
{
return [
@@ -159,14 +190,14 @@ public static function serialTypes() : array
*/
public function testGenerateTableWithAutoincrementDoesNotSetDefault(string $type, string $definition) : void
{
- $table = new \Doctrine\DBAL\Schema\Table('autoinc_table_notnull');
+ $table = new Table('autoinc_table_notnull');
$column = $table->addColumn('id', $type);
$column->setAutoIncrement(true);
$column->setNotNull(false);
- $sql = $this->_platform->getCreateTableSQL($table);
+ $sql = $this->platform->getCreateTableSQL($table);
- self::assertEquals(["CREATE TABLE autoinc_table_notnull (id $definition)"], $sql);
+ self::assertEquals([sprintf('CREATE TABLE autoinc_table_notnull (id %s)', $definition)], $sql);
}
/**
@@ -175,14 +206,14 @@ public function testGenerateTableWithAutoincrementDoesNotSetDefault(string $type
*/
public function testCreateTableWithAutoincrementAndNotNullAddsConstraint(string $type, string $definition) : void
{
- $table = new \Doctrine\DBAL\Schema\Table('autoinc_table_notnull_enabled');
+ $table = new Table('autoinc_table_notnull_enabled');
$column = $table->addColumn('id', $type);
$column->setAutoIncrement(true);
$column->setNotNull(true);
- $sql = $this->_platform->getCreateTableSQL($table);
+ $sql = $this->platform->getCreateTableSQL($table);
- self::assertEquals(["CREATE TABLE autoinc_table_notnull_enabled (id $definition NOT NULL)"], $sql);
+ self::assertEquals([sprintf('CREATE TABLE autoinc_table_notnull_enabled (id %s NOT NULL)', $definition)], $sql);
}
/**
@@ -191,7 +222,7 @@ public function testCreateTableWithAutoincrementAndNotNullAddsConstraint(string
*/
public function testGetDefaultValueDeclarationSQLIgnoresTheDefaultKeyWhenTheFieldIsSerial(string $type) : void
{
- $sql = $this->_platform->getDefaultValueDeclarationSQL(
+ $sql = $this->platform->getDefaultValueDeclarationSQL(
[
'autoincrement' => true,
'type' => Type::getType($type),
@@ -206,34 +237,36 @@ public function testGeneratesTypeDeclarationForIntegers()
{
self::assertEquals(
'INT',
- $this->_platform->getIntegerTypeDeclarationSQL(array())
+ $this->platform->getIntegerTypeDeclarationSQL([])
);
self::assertEquals(
'SERIAL',
- $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)
- ));
+ $this->platform->getIntegerTypeDeclarationSQL(['autoincrement' => true])
+ );
self::assertEquals(
'SERIAL',
- $this->_platform->getIntegerTypeDeclarationSQL(
- array('autoincrement' => true, 'primary' => true)
- ));
+ $this->platform->getIntegerTypeDeclarationSQL(
+ ['autoincrement' => true, 'primary' => true]
+ )
+ );
}
public function testGeneratesTypeDeclarationForStrings()
{
self::assertEquals(
'CHAR(10)',
- $this->_platform->getVarcharTypeDeclarationSQL(
- array('length' => 10, 'fixed' => true))
+ $this->platform->getVarcharTypeDeclarationSQL(
+ ['length' => 10, 'fixed' => true]
+ )
);
self::assertEquals(
'VARCHAR(50)',
- $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
+ $this->platform->getVarcharTypeDeclarationSQL(['length' => 50]),
'Variable string declaration is not correct'
);
self::assertEquals(
'VARCHAR(255)',
- $this->_platform->getVarcharTypeDeclarationSQL(array()),
+ $this->platform->getVarcharTypeDeclarationSQL([]),
'Long string declaration is not correct'
);
}
@@ -245,44 +278,44 @@ public function getGenerateUniqueIndexSql()
public function testGeneratesSequenceSqlCommands()
{
- $sequence = new \Doctrine\DBAL\Schema\Sequence('myseq', 20, 1);
+ $sequence = new Sequence('myseq', 20, 1);
self::assertEquals(
'CREATE SEQUENCE myseq INCREMENT BY 20 MINVALUE 1 START 1',
- $this->_platform->getCreateSequenceSQL($sequence)
+ $this->platform->getCreateSequenceSQL($sequence)
);
self::assertEquals(
'DROP SEQUENCE myseq CASCADE',
- $this->_platform->getDropSequenceSQL('myseq')
+ $this->platform->getDropSequenceSQL('myseq')
);
self::assertEquals(
"SELECT NEXTVAL('myseq')",
- $this->_platform->getSequenceNextValSQL('myseq')
+ $this->platform->getSequenceNextValSQL('myseq')
);
}
public function testDoesNotPreferIdentityColumns()
{
- self::assertFalse($this->_platform->prefersIdentityColumns());
+ self::assertFalse($this->platform->prefersIdentityColumns());
}
public function testPrefersSequences()
{
- self::assertTrue($this->_platform->prefersSequences());
+ self::assertTrue($this->platform->prefersSequences());
}
public function testSupportsIdentityColumns()
{
- self::assertTrue($this->_platform->supportsIdentityColumns());
+ self::assertTrue($this->platform->supportsIdentityColumns());
}
public function testSupportsSavePoints()
{
- self::assertTrue($this->_platform->supportsSavepoints());
+ self::assertTrue($this->platform->supportsSavepoints());
}
public function testSupportsSequences()
{
- self::assertTrue($this->_platform->supportsSequences());
+ self::assertTrue($this->platform->supportsSequences());
}
/**
@@ -295,83 +328,81 @@ protected function supportsCommentOnStatement()
public function testModifyLimitQuery()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
self::assertEquals('SELECT * FROM user LIMIT 10', $sql);
}
public function testModifyLimitQueryWithEmptyOffset()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10);
self::assertEquals('SELECT * FROM user LIMIT 10', $sql);
}
public function getCreateTableColumnCommentsSQL()
{
- return array(
- "CREATE TABLE test (id INT NOT NULL, PRIMARY KEY(id))",
+ return [
+ 'CREATE TABLE test (id INT NOT NULL, PRIMARY KEY(id))',
"COMMENT ON COLUMN test.id IS 'This is a comment'",
- );
+ ];
}
public function getAlterTableColumnCommentsSQL()
{
- return array(
- "ALTER TABLE mytable ADD quota INT NOT NULL",
+ return [
+ 'ALTER TABLE mytable ADD quota INT NOT NULL',
"COMMENT ON COLUMN mytable.quota IS 'A comment'",
- "COMMENT ON COLUMN mytable.foo IS NULL",
+ 'COMMENT ON COLUMN mytable.foo IS NULL',
"COMMENT ON COLUMN mytable.baz IS 'B comment'",
- );
+ ];
}
public function getCreateTableColumnTypeCommentsSQL()
{
- return array(
- "CREATE TABLE test (id INT NOT NULL, data TEXT NOT NULL, PRIMARY KEY(id))",
- "COMMENT ON COLUMN test.data IS '(DC2Type:array)'"
- );
+ return [
+ 'CREATE TABLE test (id INT NOT NULL, data TEXT NOT NULL, PRIMARY KEY(id))',
+ "COMMENT ON COLUMN test.data IS '(DC2Type:array)'",
+ ];
}
protected function getQuotedColumnInPrimaryKeySQL()
{
- return array(
- 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY("create"))',
- );
+ return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY("create"))'];
}
protected function getQuotedColumnInIndexSQL()
{
- return array(
+ return [
'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)',
'CREATE INDEX IDX_22660D028FD6E0FB ON "quoted" ("create")',
- );
+ ];
}
protected function getQuotedNameInIndexSQL()
{
- return array(
+ return [
'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)',
'CREATE INDEX "key" ON test (column1)',
- );
+ ];
}
protected function getQuotedColumnInForeignKeySQL()
{
- return array(
+ return [
'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, "bar" VARCHAR(255) NOT NULL)',
'ALTER TABLE "quoted" ADD CONSTRAINT FK_WITH_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES "foreign" ("create", bar, "foo-bar") NOT DEFERRABLE INITIALLY IMMEDIATE',
'ALTER TABLE "quoted" ADD CONSTRAINT FK_WITH_NON_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES foo ("create", bar, "foo-bar") NOT DEFERRABLE INITIALLY IMMEDIATE',
'ALTER TABLE "quoted" ADD CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY ("create", foo, "bar") REFERENCES "foo-bar" ("create", bar, "foo-bar") NOT DEFERRABLE INITIALLY IMMEDIATE',
- );
+ ];
}
/**
- * @group DBAL-457
- * @dataProvider pgBooleanProvider
- *
* @param string $databaseValue
* @param string $preparedStatementValue
* @param int $integerValue
* @param bool $booleanValue
+ *
+ * @group DBAL-457
+ * @dataProvider pgBooleanProvider
*/
public function testConvertBooleanAsLiteralStrings(
$databaseValue,
@@ -400,21 +431,20 @@ public function testConvertBooleanAsLiteralIntegers()
}
/**
- * @group DBAL-630
- * @dataProvider pgBooleanProvider
- *
* @param string $databaseValue
* @param string $preparedStatementValue
* @param int $integerValue
* @param bool $booleanValue
+ *
+ * @group DBAL-630
+ * @dataProvider pgBooleanProvider
*/
public function testConvertBooleanAsDatabaseValueStrings(
$databaseValue,
$preparedStatementValue,
$integerValue,
$booleanValue
- )
- {
+ ) {
$platform = $this->createPlatform();
self::assertSame($integerValue, $platform->convertBooleansToDatabaseValue($booleanValue));
@@ -433,12 +463,12 @@ public function testConvertBooleanAsDatabaseValueIntegers()
}
/**
- * @dataProvider pgBooleanProvider
- *
* @param string $databaseValue
* @param string $prepareStatementValue
* @param int $integerValue
* @param bool $booleanValue
+ *
+ * @dataProvider pgBooleanProvider
*/
public function testConvertFromBoolean($databaseValue, $prepareStatementValue, $integerValue, $booleanValue)
{
@@ -453,60 +483,71 @@ public function testConvertFromBoolean($databaseValue, $prepareStatementValue, $
*/
public function testThrowsExceptionWithInvalidBooleanLiteral()
{
- $platform = $this->createPlatform()->convertBooleansToDatabaseValue("my-bool");
+ $platform = $this->createPlatform()->convertBooleansToDatabaseValue('my-bool');
}
public function testGetCreateSchemaSQL()
{
$schemaName = 'schema';
- $sql = $this->_platform->getCreateSchemaSQL($schemaName);
+ $sql = $this->platform->getCreateSchemaSQL($schemaName);
self::assertEquals('CREATE SCHEMA ' . $schemaName, $sql);
}
public function testAlterDecimalPrecisionScale()
{
-
$table = new Table('mytable');
$table->addColumn('dfoo1', 'decimal');
- $table->addColumn('dfoo2', 'decimal', array('precision' => 10, 'scale' => 6));
- $table->addColumn('dfoo3', 'decimal', array('precision' => 10, 'scale' => 6));
- $table->addColumn('dfoo4', 'decimal', array('precision' => 10, 'scale' => 6));
+ $table->addColumn('dfoo2', 'decimal', ['precision' => 10, 'scale' => 6]);
+ $table->addColumn('dfoo3', 'decimal', ['precision' => 10, 'scale' => 6]);
+ $table->addColumn('dfoo4', 'decimal', ['precision' => 10, 'scale' => 6]);
- $tableDiff = new TableDiff('mytable');
+ $tableDiff = new TableDiff('mytable');
$tableDiff->fromTable = $table;
- $tableDiff->changedColumns['dloo1'] = new \Doctrine\DBAL\Schema\ColumnDiff(
- 'dloo1', new \Doctrine\DBAL\Schema\Column(
- 'dloo1', \Doctrine\DBAL\Types\Type::getType('decimal'), array('precision' => 16, 'scale' => 6)
+ $tableDiff->changedColumns['dloo1'] = new ColumnDiff(
+ 'dloo1',
+ new Column(
+ 'dloo1',
+ Type::getType('decimal'),
+ ['precision' => 16, 'scale' => 6]
),
- array('precision')
- );
- $tableDiff->changedColumns['dloo2'] = new \Doctrine\DBAL\Schema\ColumnDiff(
- 'dloo2', new \Doctrine\DBAL\Schema\Column(
- 'dloo2', \Doctrine\DBAL\Types\Type::getType('decimal'), array('precision' => 10, 'scale' => 4)
+ ['precision']
+ );
+ $tableDiff->changedColumns['dloo2'] = new ColumnDiff(
+ 'dloo2',
+ new Column(
+ 'dloo2',
+ Type::getType('decimal'),
+ ['precision' => 10, 'scale' => 4]
),
- array('scale')
- );
- $tableDiff->changedColumns['dloo3'] = new \Doctrine\DBAL\Schema\ColumnDiff(
- 'dloo3', new \Doctrine\DBAL\Schema\Column(
- 'dloo3', \Doctrine\DBAL\Types\Type::getType('decimal'), array('precision' => 10, 'scale' => 6)
+ ['scale']
+ );
+ $tableDiff->changedColumns['dloo3'] = new ColumnDiff(
+ 'dloo3',
+ new Column(
+ 'dloo3',
+ Type::getType('decimal'),
+ ['precision' => 10, 'scale' => 6]
),
- array()
- );
- $tableDiff->changedColumns['dloo4'] = new \Doctrine\DBAL\Schema\ColumnDiff(
- 'dloo4', new \Doctrine\DBAL\Schema\Column(
- 'dloo4', \Doctrine\DBAL\Types\Type::getType('decimal'), array('precision' => 16, 'scale' => 8)
+ []
+ );
+ $tableDiff->changedColumns['dloo4'] = new ColumnDiff(
+ 'dloo4',
+ new Column(
+ 'dloo4',
+ Type::getType('decimal'),
+ ['precision' => 16, 'scale' => 8]
),
- array('precision', 'scale')
+ ['precision', 'scale']
);
- $sql = $this->_platform->getAlterTableSQL($tableDiff);
+ $sql = $this->platform->getAlterTableSQL($tableDiff);
- $expectedSql = array(
+ $expectedSql = [
'ALTER TABLE mytable ALTER dloo1 TYPE NUMERIC(16, 6)',
'ALTER TABLE mytable ALTER dloo2 TYPE NUMERIC(10, 4)',
'ALTER TABLE mytable ALTER dloo4 TYPE NUMERIC(16, 8)',
- );
+ ];
self::assertEquals($expectedSql, $sql);
}
@@ -518,22 +559,22 @@ public function testDroppingConstraintsBeforeColumns()
{
$newTable = new Table('mytable');
$newTable->addColumn('id', 'integer');
- $newTable->setPrimaryKey(array('id'));
+ $newTable->setPrimaryKey(['id']);
$oldTable = clone $newTable;
$oldTable->addColumn('parent_id', 'integer');
- $oldTable->addUnnamedForeignKeyConstraint('mytable', array('parent_id'), array('id'));
+ $oldTable->addUnnamedForeignKeyConstraint('mytable', ['parent_id'], ['id']);
- $comparator = new \Doctrine\DBAL\Schema\Comparator();
- $tableDiff = $comparator->diffTable($oldTable, $newTable);
+ $comparator = new Comparator();
+ $tableDiff = $comparator->diffTable($oldTable, $newTable);
- $sql = $this->_platform->getAlterTableSQL($tableDiff);
+ $sql = $this->platform->getAlterTableSQL($tableDiff);
- $expectedSql = array(
+ $expectedSql = [
'ALTER TABLE mytable DROP CONSTRAINT FK_6B2BD609727ACA70',
'DROP INDEX IDX_6B2BD609727ACA70',
'ALTER TABLE mytable DROP parent_id',
- );
+ ];
self::assertEquals($expectedSql, $sql);
}
@@ -543,7 +584,7 @@ public function testDroppingConstraintsBeforeColumns()
*/
public function testUsesSequenceEmulatedIdentityColumns()
{
- self::assertTrue($this->_platform->usesSequenceEmulatedIdentityColumns());
+ self::assertTrue($this->platform->usesSequenceEmulatedIdentityColumns());
}
/**
@@ -551,7 +592,7 @@ public function testUsesSequenceEmulatedIdentityColumns()
*/
public function testReturnsIdentitySequenceName()
{
- self::assertSame('mytable_mycolumn_seq', $this->_platform->getIdentitySequenceName('mytable', 'mycolumn'));
+ self::assertSame('mytable_mycolumn_seq', $this->platform->getIdentitySequenceName('mytable', 'mycolumn'));
}
/**
@@ -560,15 +601,15 @@ public function testReturnsIdentitySequenceName()
*/
public function testCreateSequenceWithCache($cacheSize, $expectedSql)
{
- $sequence = new \Doctrine\DBAL\Schema\Sequence('foo', 1, 1, $cacheSize);
- self::assertContains($expectedSql, $this->_platform->getCreateSequenceSQL($sequence));
+ $sequence = new Sequence('foo', 1, 1, $cacheSize);
+ self::assertContains($expectedSql, $this->platform->getCreateSequenceSQL($sequence));
}
public function dataCreateSequenceWithCache()
{
- return array(
- array(3, 'CACHE 3')
- );
+ return [
+ [3, 'CACHE 3'],
+ ];
}
protected function getBinaryDefaultLength()
@@ -583,24 +624,24 @@ protected function getBinaryMaxLength()
public function testReturnsBinaryTypeDeclarationSQL()
{
- self::assertSame('BYTEA', $this->_platform->getBinaryTypeDeclarationSQL(array()));
- self::assertSame('BYTEA', $this->_platform->getBinaryTypeDeclarationSQL(array('length' => 0)));
- self::assertSame('BYTEA', $this->_platform->getBinaryTypeDeclarationSQL(array('length' => 9999999)));
+ self::assertSame('BYTEA', $this->platform->getBinaryTypeDeclarationSQL([]));
+ self::assertSame('BYTEA', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0]));
+ self::assertSame('BYTEA', $this->platform->getBinaryTypeDeclarationSQL(['length' => 9999999]));
- self::assertSame('BYTEA', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true)));
- self::assertSame('BYTEA', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true, 'length' => 0)));
- self::assertSame('BYTEA', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true, 'length' => 9999999)));
+ self::assertSame('BYTEA', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true]));
+ self::assertSame('BYTEA', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 0]));
+ self::assertSame('BYTEA', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 9999999]));
}
public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType()
{
$table1 = new Table('mytable');
$table1->addColumn('column_varbinary', 'binary');
- $table1->addColumn('column_binary', 'binary', array('fixed' => true));
+ $table1->addColumn('column_binary', 'binary', ['fixed' => true]);
$table1->addColumn('column_blob', 'blob');
$table2 = new Table('mytable');
- $table2->addColumn('column_varbinary', 'binary', array('fixed' => true));
+ $table2->addColumn('column_varbinary', 'binary', ['fixed' => true]);
$table2->addColumn('column_binary', 'binary');
$table2->addColumn('column_blob', 'binary');
@@ -609,27 +650,27 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType()
// VARBINARY -> BINARY
// BINARY -> VARBINARY
// BLOB -> VARBINARY
- self::assertEmpty($this->_platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
+ self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
$table2 = new Table('mytable');
- $table2->addColumn('column_varbinary', 'binary', array('length' => 42));
+ $table2->addColumn('column_varbinary', 'binary', ['length' => 42]);
$table2->addColumn('column_binary', 'blob');
- $table2->addColumn('column_blob', 'binary', array('length' => 11, 'fixed' => true));
+ $table2->addColumn('column_blob', 'binary', ['length' => 11, 'fixed' => true]);
// VARBINARY -> VARBINARY with changed length
// BINARY -> BLOB
// BLOB -> BINARY
- self::assertEmpty($this->_platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
+ self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
$table2 = new Table('mytable');
$table2->addColumn('column_varbinary', 'blob');
- $table2->addColumn('column_binary', 'binary', array('length' => 42, 'fixed' => true));
+ $table2->addColumn('column_binary', 'binary', ['length' => 42, 'fixed' => true]);
$table2->addColumn('column_blob', 'blob');
// VARBINARY -> BLOB
// BINARY -> BINARY with changed length
// BLOB -> BLOB
- self::assertEmpty($this->_platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
+ self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
}
/**
@@ -637,9 +678,7 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType()
*/
protected function getAlterTableRenameIndexSQL()
{
- return array(
- 'ALTER INDEX idx_foo RENAME TO idx_bar',
- );
+ return ['ALTER INDEX idx_foo RENAME TO idx_bar'];
}
/**
@@ -647,38 +686,39 @@ protected function getAlterTableRenameIndexSQL()
*/
protected function getQuotedAlterTableRenameIndexSQL()
{
- return array(
+ return [
'ALTER INDEX "create" RENAME TO "select"',
'ALTER INDEX "foo" RENAME TO "bar"',
- );
+ ];
}
/**
* PostgreSQL boolean strings provider
- * @return array
+ *
+ * @return mixed[]
*/
public function pgBooleanProvider()
{
- return array(
+ return [
// Database value, prepared statement value, boolean integer value, boolean value.
- array(true, 'true', 1, true),
- array('t', 'true', 1, true),
- array('true', 'true', 1, true),
- array('y', 'true', 1, true),
- array('yes', 'true', 1, true),
- array('on', 'true', 1, true),
- array('1', 'true', 1, true),
-
- array(false, 'false', 0, false),
- array('f', 'false', 0, false),
- array('false', 'false', 0, false),
- array( 'n', 'false', 0, false),
- array('no', 'false', 0, false),
- array('off', 'false', 0, false),
- array('0', 'false', 0, false),
-
- array(null, 'NULL', null, null)
- );
+ [true, 'true', 1, true],
+ ['t', 'true', 1, true],
+ ['true', 'true', 1, true],
+ ['y', 'true', 1, true],
+ ['yes', 'true', 1, true],
+ ['on', 'true', 1, true],
+ ['1', 'true', 1, true],
+
+ [false, 'false', 0, false],
+ ['f', 'false', 0, false],
+ ['false', 'false', 0, false],
+ [ 'n', 'false', 0, false],
+ ['no', 'false', 0, false],
+ ['off', 'false', 0, false],
+ ['0', 'false', 0, false],
+
+ [null, 'NULL', null, null],
+ ];
}
/**
@@ -686,7 +726,7 @@ public function pgBooleanProvider()
*/
protected function getQuotedAlterTableRenameColumnSQL()
{
- return array(
+ return [
'ALTER TABLE mytable RENAME COLUMN unquoted1 TO unquoted',
'ALTER TABLE mytable RENAME COLUMN unquoted2 TO "where"',
'ALTER TABLE mytable RENAME COLUMN unquoted3 TO "foo"',
@@ -696,7 +736,7 @@ protected function getQuotedAlterTableRenameColumnSQL()
'ALTER TABLE mytable RENAME COLUMN quoted1 TO quoted',
'ALTER TABLE mytable RENAME COLUMN quoted2 TO "and"',
'ALTER TABLE mytable RENAME COLUMN quoted3 TO "baz"',
- );
+ ];
}
/**
@@ -704,14 +744,14 @@ protected function getQuotedAlterTableRenameColumnSQL()
*/
protected function getQuotedAlterTableChangeColumnLengthSQL()
{
- return array(
+ return [
'ALTER TABLE mytable ALTER unquoted1 TYPE VARCHAR(255)',
'ALTER TABLE mytable ALTER unquoted2 TYPE VARCHAR(255)',
'ALTER TABLE mytable ALTER unquoted3 TYPE VARCHAR(255)',
'ALTER TABLE mytable ALTER "create" TYPE VARCHAR(255)',
'ALTER TABLE mytable ALTER "table" TYPE VARCHAR(255)',
'ALTER TABLE mytable ALTER "select" TYPE VARCHAR(255)',
- );
+ ];
}
/**
@@ -719,9 +759,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL()
*/
protected function getAlterTableRenameIndexInSchemaSQL()
{
- return array(
- 'ALTER INDEX myschema.idx_foo RENAME TO idx_bar',
- );
+ return ['ALTER INDEX myschema.idx_foo RENAME TO idx_bar'];
}
/**
@@ -729,10 +767,10 @@ protected function getAlterTableRenameIndexInSchemaSQL()
*/
protected function getQuotedAlterTableRenameIndexInSchemaSQL()
{
- return array(
+ return [
'ALTER INDEX "schema"."create" RENAME TO "select"',
'ALTER INDEX "schema"."foo" RENAME TO "bar"',
- );
+ ];
}
protected function getQuotesDropForeignKeySQL()
@@ -743,8 +781,8 @@ protected function getQuotesDropForeignKeySQL()
public function testGetNullCommentOnColumnSQL()
{
self::assertEquals(
- "COMMENT ON COLUMN mytable.id IS NULL",
- $this->_platform->getCommentOnColumnSQL('mytable', 'id', null)
+ 'COMMENT ON COLUMN mytable.id IS NULL',
+ $this->platform->getCommentOnColumnSQL('mytable', 'id', null)
);
}
@@ -753,7 +791,7 @@ public function testGetNullCommentOnColumnSQL()
*/
public function testReturnsGuidTypeDeclarationSQL()
{
- self::assertSame('UUID', $this->_platform->getGuidTypeDeclarationSQL(array()));
+ self::assertSame('UUID', $this->platform->getGuidTypeDeclarationSQL([]));
}
/**
@@ -761,9 +799,7 @@ public function testReturnsGuidTypeDeclarationSQL()
*/
public function getAlterTableRenameColumnSQL()
{
- return array(
- 'ALTER TABLE foo RENAME COLUMN bar TO baz',
- );
+ return ['ALTER TABLE foo RENAME COLUMN bar TO baz'];
}
/**
@@ -771,7 +807,7 @@ public function getAlterTableRenameColumnSQL()
*/
protected function getQuotesTableIdentifiersInAlterTableSQL()
{
- return array(
+ return [
'ALTER TABLE "foo" DROP CONSTRAINT fk1',
'ALTER TABLE "foo" DROP CONSTRAINT fk2',
'ALTER TABLE "foo" ADD bloo INT NOT NULL',
@@ -783,7 +819,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL()
'INITIALLY IMMEDIATE',
'ALTER TABLE "table" ADD CONSTRAINT fk2 FOREIGN KEY (fk2) REFERENCES fk_table2 (id) NOT DEFERRABLE ' .
'INITIALLY IMMEDIATE',
- );
+ ];
}
/**
@@ -791,11 +827,11 @@ protected function getQuotesTableIdentifiersInAlterTableSQL()
*/
protected function getCommentOnColumnSQL()
{
- return array(
+ return [
'COMMENT ON COLUMN foo.bar IS \'comment\'',
'COMMENT ON COLUMN "Foo"."BAR" IS \'comment\'',
'COMMENT ON COLUMN "select"."from" IS \'comment\'',
- );
+ ];
}
/**
@@ -803,19 +839,17 @@ protected function getCommentOnColumnSQL()
*/
public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers()
{
- $table1 = new Table('"foo"', array(new Column('"bar"', Type::getType('integer'))));
- $table2 = new Table('"foo"', array(new Column('"bar"', Type::getType('integer'), array('comment' => 'baz'))));
+ $table1 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'))]);
+ $table2 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'), ['comment' => 'baz'])]);
$comparator = new Comparator();
$tableDiff = $comparator->diffTable($table1, $table2);
- self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
+ self::assertInstanceOf(TableDiff::class, $tableDiff);
self::assertSame(
- array(
- 'COMMENT ON COLUMN "foo"."bar" IS \'baz\'',
- ),
- $this->_platform->getAlterTableSQL($tableDiff)
+ ['COMMENT ON COLUMN "foo"."bar" IS \'baz\''],
+ $this->platform->getAlterTableSQL($tableDiff)
);
}
@@ -848,9 +882,7 @@ protected function getQuotesReservedKeywordInTruncateTableSQL()
*/
protected function getAlterStringToFixedStringSQL()
{
- return array(
- 'ALTER TABLE mytable ALTER name TYPE CHAR(2)',
- );
+ return ['ALTER TABLE mytable ALTER name TYPE CHAR(2)'];
}
/**
@@ -858,9 +890,7 @@ protected function getAlterStringToFixedStringSQL()
*/
protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
{
- return array(
- 'ALTER INDEX idx_foo RENAME TO idx_foo_renamed',
- );
+ return ['ALTER INDEX idx_foo RENAME TO idx_foo_renamed'];
}
/**
@@ -868,8 +898,8 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
*/
public function testInitializesTsvectorTypeMapping()
{
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('tsvector'));
- self::assertEquals('text', $this->_platform->getDoctrineTypeMapping('tsvector'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('tsvector'));
+ self::assertEquals('text', $this->platform->getDoctrineTypeMapping('tsvector'));
}
/**
@@ -879,7 +909,7 @@ public function testReturnsDisallowDatabaseConnectionsSQL()
{
self::assertSame(
"UPDATE pg_database SET datallowconn = 'false' WHERE datname = 'foo'",
- $this->_platform->getDisallowDatabaseConnectionsSQL('foo')
+ $this->platform->getDisallowDatabaseConnectionsSQL('foo')
);
}
@@ -890,7 +920,7 @@ public function testReturnsCloseActiveDatabaseConnectionsSQL()
{
self::assertSame(
"SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname = 'foo'",
- $this->_platform->getCloseActiveDatabaseConnectionsSQL('foo')
+ $this->platform->getCloseActiveDatabaseConnectionsSQL('foo')
);
}
@@ -899,7 +929,7 @@ public function testReturnsCloseActiveDatabaseConnectionsSQL()
*/
public function testQuotesTableNameInListTableForeignKeysSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
}
/**
@@ -909,7 +939,7 @@ public function testQuotesSchemaNameInListTableForeignKeysSQL()
{
self::assertContains(
"'Foo''Bar\\\\'",
- $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\.baz_table"),
+ $this->platform->getListTableForeignKeysSQL("Foo'Bar\\.baz_table"),
'',
true
);
@@ -920,7 +950,7 @@ public function testQuotesSchemaNameInListTableForeignKeysSQL()
*/
public function testQuotesTableNameInListTableConstraintsSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true);
}
/**
@@ -928,7 +958,7 @@ public function testQuotesTableNameInListTableConstraintsSQL()
*/
public function testQuotesTableNameInListTableIndexesSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableIndexesSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableIndexesSQL("Foo'Bar\\"), '', true);
}
/**
@@ -938,7 +968,7 @@ public function testQuotesSchemaNameInListTableIndexesSQL()
{
self::assertContains(
"'Foo''Bar\\\\'",
- $this->_platform->getListTableIndexesSQL("Foo'Bar\\.baz_table"),
+ $this->platform->getListTableIndexesSQL("Foo'Bar\\.baz_table"),
'',
true
);
@@ -949,7 +979,7 @@ public function testQuotesSchemaNameInListTableIndexesSQL()
*/
public function testQuotesTableNameInListTableColumnsSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableColumnsSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableColumnsSQL("Foo'Bar\\"), '', true);
}
/**
@@ -959,7 +989,7 @@ public function testQuotesSchemaNameInListTableColumnsSQL()
{
self::assertContains(
"'Foo''Bar\\\\'",
- $this->_platform->getListTableColumnsSQL("Foo'Bar\\.baz_table"),
+ $this->platform->getListTableColumnsSQL("Foo'Bar\\.baz_table"),
'',
true
);
@@ -972,7 +1002,7 @@ public function testQuotesDatabaseNameInCloseActiveDatabaseConnectionsSQL()
{
self::assertContains(
"'Foo''Bar\\\\'",
- $this->_platform->getCloseActiveDatabaseConnectionsSQL("Foo'Bar\\"),
+ $this->platform->getCloseActiveDatabaseConnectionsSQL("Foo'Bar\\"),
'',
true
);
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
index 72864db1250..1341c9e8819 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
@@ -2,8 +2,10 @@
namespace Doctrine\Tests\DBAL\Platforms;
+use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff;
+use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel;
@@ -19,15 +21,15 @@ public function getGenerateTableSql()
public function getGenerateTableWithMultiColumnUniqueIndexSql()
{
- return array(
+ return [
'CREATE TABLE test (foo NVARCHAR(255), bar NVARCHAR(255))',
- 'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar) WHERE foo IS NOT NULL AND bar IS NOT NULL'
- );
+ 'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar) WHERE foo IS NOT NULL AND bar IS NOT NULL',
+ ];
}
public function getGenerateAlterTableSql()
{
- return array(
+ return [
'ALTER TABLE mytable ADD quota INT',
'ALTER TABLE mytable DROP COLUMN foo',
'ALTER TABLE mytable ALTER COLUMN baz NVARCHAR(255) NOT NULL',
@@ -38,11 +40,11 @@ public function getGenerateAlterTableSql()
"DECLARE @sql NVARCHAR(MAX) = N''; " .
"SELECT @sql += N'EXEC sp_rename N''' + dc.name + ''', N''' " .
"+ REPLACE(dc.name, '6B2BD609', 'E2B58069') + ''', ''OBJECT'';' " .
- "FROM sys.default_constraints dc " .
- "JOIN sys.tables tbl ON dc.parent_object_id = tbl.object_id " .
+ 'FROM sys.default_constraints dc ' .
+ 'JOIN sys.tables tbl ON dc.parent_object_id = tbl.object_id ' .
"WHERE tbl.name = 'userlist';" .
- "EXEC sp_executesql @sql"
- );
+ 'EXEC sp_executesql @sql',
+ ];
}
/**
@@ -50,35 +52,35 @@ public function getGenerateAlterTableSql()
*/
public function testDoesNotSupportRegexp()
{
- $this->_platform->getRegexpExpression();
+ $this->platform->getRegexpExpression();
}
public function testGeneratesSqlSnippets()
{
- self::assertEquals('CONVERT(date, GETDATE())', $this->_platform->getCurrentDateSQL());
- self::assertEquals('CONVERT(time, GETDATE())', $this->_platform->getCurrentTimeSQL());
- self::assertEquals('CURRENT_TIMESTAMP', $this->_platform->getCurrentTimestampSQL());
- self::assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
- self::assertEquals('(column1 + column2 + column3)', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
+ self::assertEquals('CONVERT(date, GETDATE())', $this->platform->getCurrentDateSQL());
+ self::assertEquals('CONVERT(time, GETDATE())', $this->platform->getCurrentTimeSQL());
+ self::assertEquals('CURRENT_TIMESTAMP', $this->platform->getCurrentTimestampSQL());
+ self::assertEquals('"', $this->platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
+ self::assertEquals('(column1 + column2 + column3)', $this->platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
}
public function testGeneratesTransactionsCommands()
{
self::assertEquals(
'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_UNCOMMITTED)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_UNCOMMITTED)
);
self::assertEquals(
'SET TRANSACTION ISOLATION LEVEL READ COMMITTED',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_COMMITTED)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_COMMITTED)
);
self::assertEquals(
'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::REPEATABLE_READ)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::REPEATABLE_READ)
);
self::assertEquals(
'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::SERIALIZABLE)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::SERIALIZABLE)
);
}
@@ -86,76 +88,78 @@ public function testGeneratesDDLSnippets()
{
$dropDatabaseExpectation = 'DROP DATABASE foobar';
- self::assertEquals('SELECT * FROM sys.databases', $this->_platform->getListDatabasesSQL());
- self::assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar'));
- self::assertEquals($dropDatabaseExpectation, $this->_platform->getDropDatabaseSQL('foobar'));
- self::assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));
+ self::assertEquals('SELECT * FROM sys.databases', $this->platform->getListDatabasesSQL());
+ self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar'));
+ self::assertEquals($dropDatabaseExpectation, $this->platform->getDropDatabaseSQL('foobar'));
+ self::assertEquals('DROP TABLE foobar', $this->platform->getDropTableSQL('foobar'));
}
public function testGeneratesTypeDeclarationForIntegers()
{
self::assertEquals(
- 'INT',
- $this->_platform->getIntegerTypeDeclarationSQL(array())
+ 'INT',
+ $this->platform->getIntegerTypeDeclarationSQL([])
);
self::assertEquals(
- 'INT IDENTITY',
- $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)
- ));
+ 'INT IDENTITY',
+ $this->platform->getIntegerTypeDeclarationSQL(['autoincrement' => true])
+ );
self::assertEquals(
- 'INT IDENTITY',
- $this->_platform->getIntegerTypeDeclarationSQL(
- array('autoincrement' => true, 'primary' => true)
- ));
+ 'INT IDENTITY',
+ $this->platform->getIntegerTypeDeclarationSQL(
+ ['autoincrement' => true, 'primary' => true]
+ )
+ );
}
public function testGeneratesTypeDeclarationsForStrings()
{
self::assertEquals(
- 'NCHAR(10)',
- $this->_platform->getVarcharTypeDeclarationSQL(
- array('length' => 10, 'fixed' => true)
- ));
+ 'NCHAR(10)',
+ $this->platform->getVarcharTypeDeclarationSQL(
+ ['length' => 10, 'fixed' => true]
+ )
+ );
self::assertEquals(
- 'NVARCHAR(50)',
- $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
- 'Variable string declaration is not correct'
+ 'NVARCHAR(50)',
+ $this->platform->getVarcharTypeDeclarationSQL(['length' => 50]),
+ 'Variable string declaration is not correct'
);
self::assertEquals(
- 'NVARCHAR(255)',
- $this->_platform->getVarcharTypeDeclarationSQL(array()),
- 'Long string declaration is not correct'
+ 'NVARCHAR(255)',
+ $this->platform->getVarcharTypeDeclarationSQL([]),
+ 'Long string declaration is not correct'
);
- self::assertSame('VARCHAR(MAX)', $this->_platform->getClobTypeDeclarationSQL(array()));
+ self::assertSame('VARCHAR(MAX)', $this->platform->getClobTypeDeclarationSQL([]));
self::assertSame(
'VARCHAR(MAX)',
- $this->_platform->getClobTypeDeclarationSQL(array('length' => 5, 'fixed' => true))
+ $this->platform->getClobTypeDeclarationSQL(['length' => 5, 'fixed' => true])
);
}
public function testPrefersIdentityColumns()
{
- self::assertTrue($this->_platform->prefersIdentityColumns());
+ self::assertTrue($this->platform->prefersIdentityColumns());
}
public function testSupportsIdentityColumns()
{
- self::assertTrue($this->_platform->supportsIdentityColumns());
+ self::assertTrue($this->platform->supportsIdentityColumns());
}
public function testSupportsCreateDropDatabase()
{
- self::assertTrue($this->_platform->supportsCreateDropDatabase());
+ self::assertTrue($this->platform->supportsCreateDropDatabase());
}
public function testSupportsSchemas()
{
- self::assertTrue($this->_platform->supportsSchemas());
+ self::assertTrue($this->platform->supportsSchemas());
}
public function testDoesNotSupportSavePoints()
{
- self::assertTrue($this->_platform->supportsSavepoints());
+ self::assertTrue($this->platform->supportsSavepoints());
}
public function getGenerateIndexSql()
@@ -175,114 +179,114 @@ public function getGenerateForeignKeySql()
public function testModifyLimitQuery()
{
- $querySql = 'SELECT * FROM user';
+ $querySql = 'SELECT * FROM user';
$alteredSql = 'SELECT TOP 10 * FROM user';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10, 0);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10, 0);
$this->expectCteWithMaxRowNum($alteredSql, 10, $sql);
}
public function testModifyLimitQueryWithEmptyOffset()
{
- $querySql = 'SELECT * FROM user';
+ $querySql = 'SELECT * FROM user';
$alteredSql = 'SELECT TOP 10 * FROM user';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10);
$this->expectCteWithMaxRowNum($alteredSql, 10, $sql);
}
public function testModifyLimitQueryWithOffset()
{
- if ( ! $this->_platform->supportsLimitOffset()) {
- $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->_platform->getName()));
+ if (! $this->platform->supportsLimitOffset()) {
+ $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->platform->getName()));
}
- $querySql = 'SELECT * FROM user ORDER BY username DESC';
+ $querySql = 'SELECT * FROM user ORDER BY username DESC';
$alteredSql = 'SELECT TOP 15 * FROM user ORDER BY username DESC';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10, 5);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10, 5);
$this->expectCteWithMinAndMaxRowNums($alteredSql, 6, 15, $sql);
}
public function testModifyLimitQueryWithAscOrderBy()
{
- $querySql = 'SELECT * FROM user ORDER BY username ASC';
+ $querySql = 'SELECT * FROM user ORDER BY username ASC';
$alteredSql = 'SELECT TOP 10 * FROM user ORDER BY username ASC';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10);
$this->expectCteWithMaxRowNum($alteredSql, 10, $sql);
}
public function testModifyLimitQueryWithLowercaseOrderBy()
{
- $querySql = 'SELECT * FROM user order by username';
+ $querySql = 'SELECT * FROM user order by username';
$alteredSql = 'SELECT TOP 10 * FROM user order by username';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10);
$this->expectCteWithMaxRowNum($alteredSql, 10, $sql);
}
public function testModifyLimitQueryWithDescOrderBy()
{
- $querySql = 'SELECT * FROM user ORDER BY username DESC';
+ $querySql = 'SELECT * FROM user ORDER BY username DESC';
$alteredSql = 'SELECT TOP 10 * FROM user ORDER BY username DESC';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10);
$this->expectCteWithMaxRowNum($alteredSql, 10, $sql);
}
public function testModifyLimitQueryWithMultipleOrderBy()
{
- $querySql = 'SELECT * FROM user ORDER BY username DESC, usereamil ASC';
+ $querySql = 'SELECT * FROM user ORDER BY username DESC, usereamil ASC';
$alteredSql = 'SELECT TOP 10 * FROM user ORDER BY username DESC, usereamil ASC';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10);
$this->expectCteWithMaxRowNum($alteredSql, 10, $sql);
}
public function testModifyLimitQueryWithSubSelect()
{
- $querySql = 'SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result';
+ $querySql = 'SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result';
$alteredSql = 'SELECT TOP 10 * FROM (SELECT u.id as uid, u.name as uname) dctrn_result';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10);
$this->expectCteWithMaxRowNum($alteredSql, 10, $sql);
}
public function testModifyLimitQueryWithSubSelectAndOrder()
{
- $querySql = 'SELECT * FROM (SELECT u.id as uid, u.name as uname ORDER BY u.name DESC) dctrn_result';
+ $querySql = 'SELECT * FROM (SELECT u.id as uid, u.name as uname ORDER BY u.name DESC) dctrn_result';
$alteredSql = 'SELECT TOP 10 * FROM (SELECT u.id as uid, u.name as uname) dctrn_result';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10);
$this->expectCteWithMaxRowNum($alteredSql, 10, $sql);
- $querySql = 'SELECT * FROM (SELECT u.id, u.name ORDER BY u.name DESC) dctrn_result';
+ $querySql = 'SELECT * FROM (SELECT u.id, u.name ORDER BY u.name DESC) dctrn_result';
$alteredSql = 'SELECT TOP 10 * FROM (SELECT u.id, u.name) dctrn_result';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10);
$this->expectCteWithMaxRowNum($alteredSql, 10, $sql);
}
public function testModifyLimitQueryWithSubSelectAndMultipleOrder()
{
- if ( ! $this->_platform->supportsLimitOffset()) {
- $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->_platform->getName()));
+ if (! $this->platform->supportsLimitOffset()) {
+ $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->platform->getName()));
}
- $querySql = 'SELECT * FROM (SELECT u.id as uid, u.name as uname ORDER BY u.name DESC, id ASC) dctrn_result';
+ $querySql = 'SELECT * FROM (SELECT u.id as uid, u.name as uname ORDER BY u.name DESC, id ASC) dctrn_result';
$alteredSql = 'SELECT TOP 15 * FROM (SELECT u.id as uid, u.name as uname) dctrn_result';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10, 5);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10, 5);
$this->expectCteWithMinAndMaxRowNums($alteredSql, 6, 15, $sql);
- $querySql = 'SELECT * FROM (SELECT u.id uid, u.name uname ORDER BY u.name DESC, id ASC) dctrn_result';
+ $querySql = 'SELECT * FROM (SELECT u.id uid, u.name uname ORDER BY u.name DESC, id ASC) dctrn_result';
$alteredSql = 'SELECT TOP 15 * FROM (SELECT u.id uid, u.name uname) dctrn_result';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10, 5);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10, 5);
$this->expectCteWithMinAndMaxRowNums($alteredSql, 6, 15, $sql);
- $querySql = 'SELECT * FROM (SELECT u.id, u.name ORDER BY u.name DESC, id ASC) dctrn_result';
+ $querySql = 'SELECT * FROM (SELECT u.id, u.name ORDER BY u.name DESC, id ASC) dctrn_result';
$alteredSql = 'SELECT TOP 15 * FROM (SELECT u.id, u.name) dctrn_result';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10, 5);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10, 5);
$this->expectCteWithMinAndMaxRowNums($alteredSql, 6, 15, $sql);
}
public function testModifyLimitQueryWithFromColumnNames()
{
- $querySql = 'SELECT a.fromFoo, fromBar FROM foo';
+ $querySql = 'SELECT a.fromFoo, fromBar FROM foo';
$alteredSql = 'SELECT TOP 10 a.fromFoo, fromBar FROM foo';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10);
$this->expectCteWithMaxRowNum($alteredSql, 10, $sql);
}
@@ -291,17 +295,17 @@ public function testModifyLimitQueryWithFromColumnNames()
*/
public function testModifyLimitQueryWithExtraLongQuery()
{
- $query = 'SELECT table1.column1, table2.column2, table3.column3, table4.column4, table5.column5, table6.column6, table7.column7, table8.column8 FROM table1, table2, table3, table4, table5, table6, table7, table8 ';
- $query.= 'WHERE (table1.column1 = table2.column2) AND (table1.column1 = table3.column3) AND (table1.column1 = table4.column4) AND (table1.column1 = table5.column5) AND (table1.column1 = table6.column6) AND (table1.column1 = table7.column7) AND (table1.column1 = table8.column8) AND (table2.column2 = table3.column3) AND (table2.column2 = table4.column4) AND (table2.column2 = table5.column5) AND (table2.column2 = table6.column6) ';
- $query.= 'AND (table2.column2 = table7.column7) AND (table2.column2 = table8.column8) AND (table3.column3 = table4.column4) AND (table3.column3 = table5.column5) AND (table3.column3 = table6.column6) AND (table3.column3 = table7.column7) AND (table3.column3 = table8.column8) AND (table4.column4 = table5.column5) AND (table4.column4 = table6.column6) AND (table4.column4 = table7.column7) AND (table4.column4 = table8.column8) ';
- $query.= 'AND (table5.column5 = table6.column6) AND (table5.column5 = table7.column7) AND (table5.column5 = table8.column8) AND (table6.column6 = table7.column7) AND (table6.column6 = table8.column8) AND (table7.column7 = table8.column8)';
+ $query = 'SELECT table1.column1, table2.column2, table3.column3, table4.column4, table5.column5, table6.column6, table7.column7, table8.column8 FROM table1, table2, table3, table4, table5, table6, table7, table8 ';
+ $query .= 'WHERE (table1.column1 = table2.column2) AND (table1.column1 = table3.column3) AND (table1.column1 = table4.column4) AND (table1.column1 = table5.column5) AND (table1.column1 = table6.column6) AND (table1.column1 = table7.column7) AND (table1.column1 = table8.column8) AND (table2.column2 = table3.column3) AND (table2.column2 = table4.column4) AND (table2.column2 = table5.column5) AND (table2.column2 = table6.column6) ';
+ $query .= 'AND (table2.column2 = table7.column7) AND (table2.column2 = table8.column8) AND (table3.column3 = table4.column4) AND (table3.column3 = table5.column5) AND (table3.column3 = table6.column6) AND (table3.column3 = table7.column7) AND (table3.column3 = table8.column8) AND (table4.column4 = table5.column5) AND (table4.column4 = table6.column6) AND (table4.column4 = table7.column7) AND (table4.column4 = table8.column8) ';
+ $query .= 'AND (table5.column5 = table6.column6) AND (table5.column5 = table7.column7) AND (table5.column5 = table8.column8) AND (table6.column6 = table7.column7) AND (table6.column6 = table8.column8) AND (table7.column7 = table8.column8)';
- $alteredSql = 'SELECT TOP 10 table1.column1, table2.column2, table3.column3, table4.column4, table5.column5, table6.column6, table7.column7, table8.column8 FROM table1, table2, table3, table4, table5, table6, table7, table8 ';
- $alteredSql.= 'WHERE (table1.column1 = table2.column2) AND (table1.column1 = table3.column3) AND (table1.column1 = table4.column4) AND (table1.column1 = table5.column5) AND (table1.column1 = table6.column6) AND (table1.column1 = table7.column7) AND (table1.column1 = table8.column8) AND (table2.column2 = table3.column3) AND (table2.column2 = table4.column4) AND (table2.column2 = table5.column5) AND (table2.column2 = table6.column6) ';
- $alteredSql.= 'AND (table2.column2 = table7.column7) AND (table2.column2 = table8.column8) AND (table3.column3 = table4.column4) AND (table3.column3 = table5.column5) AND (table3.column3 = table6.column6) AND (table3.column3 = table7.column7) AND (table3.column3 = table8.column8) AND (table4.column4 = table5.column5) AND (table4.column4 = table6.column6) AND (table4.column4 = table7.column7) AND (table4.column4 = table8.column8) ';
- $alteredSql.= 'AND (table5.column5 = table6.column6) AND (table5.column5 = table7.column7) AND (table5.column5 = table8.column8) AND (table6.column6 = table7.column7) AND (table6.column6 = table8.column8) AND (table7.column7 = table8.column8)';
+ $alteredSql = 'SELECT TOP 10 table1.column1, table2.column2, table3.column3, table4.column4, table5.column5, table6.column6, table7.column7, table8.column8 FROM table1, table2, table3, table4, table5, table6, table7, table8 ';
+ $alteredSql .= 'WHERE (table1.column1 = table2.column2) AND (table1.column1 = table3.column3) AND (table1.column1 = table4.column4) AND (table1.column1 = table5.column5) AND (table1.column1 = table6.column6) AND (table1.column1 = table7.column7) AND (table1.column1 = table8.column8) AND (table2.column2 = table3.column3) AND (table2.column2 = table4.column4) AND (table2.column2 = table5.column5) AND (table2.column2 = table6.column6) ';
+ $alteredSql .= 'AND (table2.column2 = table7.column7) AND (table2.column2 = table8.column8) AND (table3.column3 = table4.column4) AND (table3.column3 = table5.column5) AND (table3.column3 = table6.column6) AND (table3.column3 = table7.column7) AND (table3.column3 = table8.column8) AND (table4.column4 = table5.column5) AND (table4.column4 = table6.column6) AND (table4.column4 = table7.column7) AND (table4.column4 = table8.column8) ';
+ $alteredSql .= 'AND (table5.column5 = table6.column6) AND (table5.column5 = table7.column7) AND (table5.column5 = table8.column8) AND (table6.column6 = table7.column7) AND (table6.column6 = table8.column8) AND (table7.column7 = table8.column8)';
- $sql = $this->_platform->modifyLimitQuery($query, 10);
+ $sql = $this->platform->modifyLimitQuery($query, 10);
$this->expectCteWithMaxRowNum($alteredSql, 10, $sql);
}
@@ -310,13 +314,13 @@ public function testModifyLimitQueryWithExtraLongQuery()
*/
public function testModifyLimitQueryWithOrderByClause()
{
- if ( ! $this->_platform->supportsLimitOffset()) {
- $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->_platform->getName()));
+ if (! $this->platform->supportsLimitOffset()) {
+ $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->platform->getName()));
}
$sql = 'SELECT m0_.NOMBRE AS NOMBRE0, m0_.FECHAINICIO AS FECHAINICIO1, m0_.FECHAFIN AS FECHAFIN2 FROM MEDICION m0_ WITH (NOLOCK) INNER JOIN ESTUDIO e1_ ON m0_.ESTUDIO_ID = e1_.ID INNER JOIN CLIENTE c2_ ON e1_.CLIENTE_ID = c2_.ID INNER JOIN USUARIO u3_ ON c2_.ID = u3_.CLIENTE_ID WHERE u3_.ID = ? ORDER BY m0_.FECHAINICIO DESC';
$alteredSql = 'SELECT TOP 15 m0_.NOMBRE AS NOMBRE0, m0_.FECHAINICIO AS FECHAINICIO1, m0_.FECHAFIN AS FECHAFIN2 FROM MEDICION m0_ WITH (NOLOCK) INNER JOIN ESTUDIO e1_ ON m0_.ESTUDIO_ID = e1_.ID INNER JOIN CLIENTE c2_ ON e1_.CLIENTE_ID = c2_.ID INNER JOIN USUARIO u3_ ON c2_.ID = u3_.CLIENTE_ID WHERE u3_.ID = ? ORDER BY m0_.FECHAINICIO DESC';
- $actual = $this->_platform->modifyLimitQuery($sql, 10, 5);
+ $actual = $this->platform->modifyLimitQuery($sql, 10, 5);
$this->expectCteWithMinAndMaxRowNums($alteredSql, 6, 15, $actual);
}
@@ -326,21 +330,21 @@ public function testModifyLimitQueryWithOrderByClause()
*/
public function testModifyLimitQueryWithSubSelectInSelectList()
{
- $querySql = "SELECT " .
- "u.id, " .
- "(u.foo/2) foodiv, " .
- "CONCAT(u.bar, u.baz) barbaz, " .
- "(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count " .
- "FROM user u " .
+ $querySql = 'SELECT ' .
+ 'u.id, ' .
+ '(u.foo/2) foodiv, ' .
+ 'CONCAT(u.bar, u.baz) barbaz, ' .
+ '(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count ' .
+ 'FROM user u ' .
"WHERE u.status = 'disabled'";
- $alteredSql = "SELECT TOP 10 " .
- "u.id, " .
- "(u.foo/2) foodiv, " .
- "CONCAT(u.bar, u.baz) barbaz, " .
- "(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count " .
- "FROM user u " .
+ $alteredSql = 'SELECT TOP 10 ' .
+ 'u.id, ' .
+ '(u.foo/2) foodiv, ' .
+ 'CONCAT(u.bar, u.baz) barbaz, ' .
+ '(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count ' .
+ 'FROM user u ' .
"WHERE u.status = 'disabled'";
- $sql = $this->_platform->modifyLimitQuery($querySql, 10);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10);
$this->expectCteWithMaxRowNum($alteredSql, 10, $sql);
}
@@ -350,27 +354,27 @@ public function testModifyLimitQueryWithSubSelectInSelectList()
*/
public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause()
{
- if ( ! $this->_platform->supportsLimitOffset()) {
- $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->_platform->getName()));
+ if (! $this->platform->supportsLimitOffset()) {
+ $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->platform->getName()));
}
- $querySql = "SELECT " .
- "u.id, " .
- "(u.foo/2) foodiv, " .
- "CONCAT(u.bar, u.baz) barbaz, " .
- "(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count " .
- "FROM user u " .
+ $querySql = 'SELECT ' .
+ 'u.id, ' .
+ '(u.foo/2) foodiv, ' .
+ 'CONCAT(u.bar, u.baz) barbaz, ' .
+ '(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count ' .
+ 'FROM user u ' .
"WHERE u.status = 'disabled' " .
- "ORDER BY u.username DESC";
- $alteredSql = "SELECT TOP 15 " .
- "u.id, " .
- "(u.foo/2) foodiv, " .
- "CONCAT(u.bar, u.baz) barbaz, " .
- "(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count " .
- "FROM user u " .
+ 'ORDER BY u.username DESC';
+ $alteredSql = 'SELECT TOP 15 ' .
+ 'u.id, ' .
+ '(u.foo/2) foodiv, ' .
+ 'CONCAT(u.bar, u.baz) barbaz, ' .
+ '(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count ' .
+ 'FROM user u ' .
"WHERE u.status = 'disabled' " .
- "ORDER BY u.username DESC";
- $sql = $this->_platform->modifyLimitQuery($querySql, 10, 5);
+ 'ORDER BY u.username DESC';
+ $sql = $this->platform->modifyLimitQuery($querySql, 10, 5);
$this->expectCteWithMinAndMaxRowNums($alteredSql, 6, 15, $sql);
}
@@ -379,102 +383,102 @@ public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause()
*/
public function testModifyLimitQueryWithAggregateFunctionInOrderByClause()
{
- $querySql = "SELECT " .
- "MAX(heading_id) aliased, " .
- "code " .
- "FROM operator_model_operator " .
- "GROUP BY code " .
- "ORDER BY MAX(heading_id) DESC";
- $alteredSql = "SELECT TOP 1 " .
- "MAX(heading_id) aliased, " .
- "code " .
- "FROM operator_model_operator " .
- "GROUP BY code " .
- "ORDER BY MAX(heading_id) DESC";
- $sql = $this->_platform->modifyLimitQuery($querySql, 1, 0);
+ $querySql = 'SELECT ' .
+ 'MAX(heading_id) aliased, ' .
+ 'code ' .
+ 'FROM operator_model_operator ' .
+ 'GROUP BY code ' .
+ 'ORDER BY MAX(heading_id) DESC';
+ $alteredSql = 'SELECT TOP 1 ' .
+ 'MAX(heading_id) aliased, ' .
+ 'code ' .
+ 'FROM operator_model_operator ' .
+ 'GROUP BY code ' .
+ 'ORDER BY MAX(heading_id) DESC';
+ $sql = $this->platform->modifyLimitQuery($querySql, 1, 0);
$this->expectCteWithMaxRowNum($alteredSql, 1, $sql);
}
/**
- * @throws \Doctrine\DBAL\DBALException
+ * @throws DBALException
*/
public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBaseTable()
{
- $querySql = "SELECT DISTINCT id_0, name_1 "
- . "FROM ("
- . "SELECT t1.id AS id_0, t2.name AS name_1 "
- . "FROM table_parent t1 "
- . "LEFT JOIN join_table t2 ON t1.id = t2.table_id "
- . "ORDER BY t1.id ASC"
- . ") dctrn_result "
- . "ORDER BY id_0 ASC";
- $alteredSql = "SELECT DISTINCT TOP 5 id_0, name_1 "
- . "FROM ("
- . "SELECT t1.id AS id_0, t2.name AS name_1 "
- . "FROM table_parent t1 "
- . "LEFT JOIN join_table t2 ON t1.id = t2.table_id"
- . ") dctrn_result "
- . "ORDER BY id_0 ASC";
- $sql = $this->_platform->modifyLimitQuery($querySql, 5);
+ $querySql = 'SELECT DISTINCT id_0, name_1 '
+ . 'FROM ('
+ . 'SELECT t1.id AS id_0, t2.name AS name_1 '
+ . 'FROM table_parent t1 '
+ . 'LEFT JOIN join_table t2 ON t1.id = t2.table_id '
+ . 'ORDER BY t1.id ASC'
+ . ') dctrn_result '
+ . 'ORDER BY id_0 ASC';
+ $alteredSql = 'SELECT DISTINCT TOP 5 id_0, name_1 '
+ . 'FROM ('
+ . 'SELECT t1.id AS id_0, t2.name AS name_1 '
+ . 'FROM table_parent t1 '
+ . 'LEFT JOIN join_table t2 ON t1.id = t2.table_id'
+ . ') dctrn_result '
+ . 'ORDER BY id_0 ASC';
+ $sql = $this->platform->modifyLimitQuery($querySql, 5);
$this->expectCteWithMaxRowNum($alteredSql, 5, $sql);
}
/**
- * @throws \Doctrine\DBAL\DBALException
+ * @throws DBALException
*/
public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoinTable()
{
- $querySql = "SELECT DISTINCT id_0, name_1 "
- . "FROM ("
- . "SELECT t1.id AS id_0, t2.name AS name_1 "
- . "FROM table_parent t1 "
- . "LEFT JOIN join_table t2 ON t1.id = t2.table_id "
- . "ORDER BY t2.name ASC"
- . ") dctrn_result "
- . "ORDER BY name_1 ASC";
- $alteredSql = "SELECT DISTINCT TOP 5 id_0, name_1 "
- . "FROM ("
- . "SELECT t1.id AS id_0, t2.name AS name_1 "
- . "FROM table_parent t1 "
- . "LEFT JOIN join_table t2 ON t1.id = t2.table_id"
- . ") dctrn_result "
- . "ORDER BY name_1 ASC";
- $sql = $this->_platform->modifyLimitQuery($querySql, 5);
+ $querySql = 'SELECT DISTINCT id_0, name_1 '
+ . 'FROM ('
+ . 'SELECT t1.id AS id_0, t2.name AS name_1 '
+ . 'FROM table_parent t1 '
+ . 'LEFT JOIN join_table t2 ON t1.id = t2.table_id '
+ . 'ORDER BY t2.name ASC'
+ . ') dctrn_result '
+ . 'ORDER BY name_1 ASC';
+ $alteredSql = 'SELECT DISTINCT TOP 5 id_0, name_1 '
+ . 'FROM ('
+ . 'SELECT t1.id AS id_0, t2.name AS name_1 '
+ . 'FROM table_parent t1 '
+ . 'LEFT JOIN join_table t2 ON t1.id = t2.table_id'
+ . ') dctrn_result '
+ . 'ORDER BY name_1 ASC';
+ $sql = $this->platform->modifyLimitQuery($querySql, 5);
$this->expectCteWithMaxRowNum($alteredSql, 5, $sql);
}
/**
- * @throws \Doctrine\DBAL\DBALException
+ * @throws DBALException
*/
public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBothTables()
{
- $querySql = "SELECT DISTINCT id_0, name_1, foo_2 "
- . "FROM ("
- . "SELECT t1.id AS id_0, t2.name AS name_1, t2.foo AS foo_2 "
- . "FROM table_parent t1 "
- . "LEFT JOIN join_table t2 ON t1.id = t2.table_id "
- . "ORDER BY t2.name ASC, t2.foo DESC"
- . ") dctrn_result "
- . "ORDER BY name_1 ASC, foo_2 DESC";
- $alteredSql = "SELECT DISTINCT TOP 5 id_0, name_1, foo_2 "
- . "FROM ("
- . "SELECT t1.id AS id_0, t2.name AS name_1, t2.foo AS foo_2 "
- . "FROM table_parent t1 "
- . "LEFT JOIN join_table t2 ON t1.id = t2.table_id"
- . ") dctrn_result "
- . "ORDER BY name_1 ASC, foo_2 DESC";
- $sql = $this->_platform->modifyLimitQuery($querySql, 5);
+ $querySql = 'SELECT DISTINCT id_0, name_1, foo_2 '
+ . 'FROM ('
+ . 'SELECT t1.id AS id_0, t2.name AS name_1, t2.foo AS foo_2 '
+ . 'FROM table_parent t1 '
+ . 'LEFT JOIN join_table t2 ON t1.id = t2.table_id '
+ . 'ORDER BY t2.name ASC, t2.foo DESC'
+ . ') dctrn_result '
+ . 'ORDER BY name_1 ASC, foo_2 DESC';
+ $alteredSql = 'SELECT DISTINCT TOP 5 id_0, name_1, foo_2 '
+ . 'FROM ('
+ . 'SELECT t1.id AS id_0, t2.name AS name_1, t2.foo AS foo_2 '
+ . 'FROM table_parent t1 '
+ . 'LEFT JOIN join_table t2 ON t1.id = t2.table_id'
+ . ') dctrn_result '
+ . 'ORDER BY name_1 ASC, foo_2 DESC';
+ $sql = $this->platform->modifyLimitQuery($querySql, 5);
$this->expectCteWithMaxRowNum($alteredSql, 5, $sql);
}
public function testModifyLimitSubquerySimple()
{
- $querySql = "SELECT DISTINCT id_0 FROM "
- . "(SELECT k0_.id AS id_0, k0_.field AS field_1 "
- . "FROM key_table k0_ WHERE (k0_.where_field IN (1))) dctrn_result";
- $alteredSql = "SELECT DISTINCT TOP 20 id_0 FROM (SELECT k0_.id AS id_0, k0_.field AS field_1 "
- . "FROM key_table k0_ WHERE (k0_.where_field IN (1))) dctrn_result";
- $sql = $this->_platform->modifyLimitQuery($querySql, 20);
+ $querySql = 'SELECT DISTINCT id_0 FROM '
+ . '(SELECT k0_.id AS id_0, k0_.field AS field_1 '
+ . 'FROM key_table k0_ WHERE (k0_.where_field IN (1))) dctrn_result';
+ $alteredSql = 'SELECT DISTINCT TOP 20 id_0 FROM (SELECT k0_.id AS id_0, k0_.field AS field_1 '
+ . 'FROM key_table k0_ WHERE (k0_.where_field IN (1))) dctrn_result';
+ $sql = $this->platform->modifyLimitQuery($querySql, 20);
$this->expectCteWithMaxRowNum($alteredSql, 20, $sql);
}
@@ -483,9 +487,9 @@ public function testModifyLimitSubquerySimple()
*/
public function testQuoteIdentifier()
{
- self::assertEquals('[fo][o]', $this->_platform->quoteIdentifier('fo]o'));
- self::assertEquals('[test]', $this->_platform->quoteIdentifier('test'));
- self::assertEquals('[test].[test]', $this->_platform->quoteIdentifier('test.test'));
+ self::assertEquals('[fo][o]', $this->platform->quoteIdentifier('fo]o'));
+ self::assertEquals('[test]', $this->platform->quoteIdentifier('test'));
+ self::assertEquals('[test].[test]', $this->platform->quoteIdentifier('test.test'));
}
/**
@@ -493,9 +497,9 @@ public function testQuoteIdentifier()
*/
public function testQuoteSingleIdentifier()
{
- self::assertEquals('[fo][o]', $this->_platform->quoteSingleIdentifier('fo]o'));
- self::assertEquals('[test]', $this->_platform->quoteSingleIdentifier('test'));
- self::assertEquals('[test.test]', $this->_platform->quoteSingleIdentifier('test.test'));
+ self::assertEquals('[fo][o]', $this->platform->quoteSingleIdentifier('fo]o'));
+ self::assertEquals('[test]', $this->platform->quoteSingleIdentifier('test'));
+ self::assertEquals('[test.test]', $this->platform->quoteSingleIdentifier('test.test'));
}
/**
@@ -503,9 +507,9 @@ public function testQuoteSingleIdentifier()
*/
public function testCreateClusteredIndex()
{
- $idx = new \Doctrine\DBAL\Schema\Index('idx', array('id'));
+ $idx = new Index('idx', ['id']);
$idx->addFlag('clustered');
- self::assertEquals('CREATE CLUSTERED INDEX idx ON tbl (id)', $this->_platform->getCreateIndexSQL($idx, 'tbl'));
+ self::assertEquals('CREATE CLUSTERED INDEX idx ON tbl (id)', $this->platform->getCreateIndexSQL($idx, 'tbl'));
}
/**
@@ -513,12 +517,12 @@ public function testCreateClusteredIndex()
*/
public function testCreateNonClusteredPrimaryKeyInTable()
{
- $table = new \Doctrine\DBAL\Schema\Table("tbl");
- $table->addColumn("id", "integer");
- $table->setPrimaryKey(Array("id"));
+ $table = new Table('tbl');
+ $table->addColumn('id', 'integer');
+ $table->setPrimaryKey(['id']);
$table->getIndex('primary')->addFlag('nonclustered');
- self::assertEquals(array('CREATE TABLE tbl (id INT NOT NULL, PRIMARY KEY NONCLUSTERED (id))'), $this->_platform->getCreateTableSQL($table));
+ self::assertEquals(['CREATE TABLE tbl (id INT NOT NULL, PRIMARY KEY NONCLUSTERED (id))'], $this->platform->getCreateTableSQL($table));
}
/**
@@ -526,54 +530,52 @@ public function testCreateNonClusteredPrimaryKeyInTable()
*/
public function testCreateNonClusteredPrimaryKey()
{
- $idx = new \Doctrine\DBAL\Schema\Index('idx', array('id'), false, true);
+ $idx = new Index('idx', ['id'], false, true);
$idx->addFlag('nonclustered');
- self::assertEquals('ALTER TABLE tbl ADD PRIMARY KEY NONCLUSTERED (id)', $this->_platform->getCreatePrimaryKeySQL($idx, 'tbl'));
+ self::assertEquals('ALTER TABLE tbl ADD PRIMARY KEY NONCLUSTERED (id)', $this->platform->getCreatePrimaryKeySQL($idx, 'tbl'));
}
public function testAlterAddPrimaryKey()
{
- $idx = new \Doctrine\DBAL\Schema\Index('idx', array('id'), false, true);
- self::assertEquals('ALTER TABLE tbl ADD PRIMARY KEY (id)', $this->_platform->getCreateIndexSQL($idx, 'tbl'));
+ $idx = new Index('idx', ['id'], false, true);
+ self::assertEquals('ALTER TABLE tbl ADD PRIMARY KEY (id)', $this->platform->getCreateIndexSQL($idx, 'tbl'));
}
protected function getQuotedColumnInPrimaryKeySQL()
{
- return array(
- 'CREATE TABLE [quoted] ([create] NVARCHAR(255) NOT NULL, PRIMARY KEY ([create]))',
- );
+ return ['CREATE TABLE [quoted] ([create] NVARCHAR(255) NOT NULL, PRIMARY KEY ([create]))'];
}
protected function getQuotedColumnInIndexSQL()
{
- return array(
+ return [
'CREATE TABLE [quoted] ([create] NVARCHAR(255) NOT NULL)',
'CREATE INDEX IDX_22660D028FD6E0FB ON [quoted] ([create])',
- );
+ ];
}
protected function getQuotedNameInIndexSQL()
{
- return array(
+ return [
'CREATE TABLE test (column1 NVARCHAR(255) NOT NULL)',
'CREATE INDEX [key] ON test (column1)',
- );
+ ];
}
protected function getQuotedColumnInForeignKeySQL()
{
- return array(
+ return [
'CREATE TABLE [quoted] ([create] NVARCHAR(255) NOT NULL, foo NVARCHAR(255) NOT NULL, [bar] NVARCHAR(255) NOT NULL)',
'ALTER TABLE [quoted] ADD CONSTRAINT FK_WITH_RESERVED_KEYWORD FOREIGN KEY ([create], foo, [bar]) REFERENCES [foreign] ([create], bar, [foo-bar])',
'ALTER TABLE [quoted] ADD CONSTRAINT FK_WITH_NON_RESERVED_KEYWORD FOREIGN KEY ([create], foo, [bar]) REFERENCES foo ([create], bar, [foo-bar])',
'ALTER TABLE [quoted] ADD CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY ([create], foo, [bar]) REFERENCES [foo-bar] ([create], bar, [foo-bar])',
- );
+ ];
}
public function testGetCreateSchemaSQL()
{
$schemaName = 'schema';
- $sql = $this->_platform->getCreateSchemaSQL($schemaName);
+ $sql = $this->platform->getCreateSchemaSQL($schemaName);
self::assertEquals('CREATE SCHEMA ' . $schemaName, $sql);
}
@@ -588,7 +590,7 @@ public function testCreateTableWithSchemaColumnComments()
"EXEC sp_addextendedproperty N'MS_Description', N'This is a comment', N'SCHEMA', 'testschema', N'TABLE', 'test', N'COLUMN', id",
];
- self::assertEquals($expectedSql, $this->_platform->getCreateTableSQL($table));
+ self::assertEquals($expectedSql, $this->platform->getCreateTableSQL($table));
}
public function testAlterTableWithSchemaColumnComments()
@@ -601,7 +603,7 @@ public function testAlterTableWithSchemaColumnComments()
"EXEC sp_addextendedproperty N'MS_Description', N'A comment', N'SCHEMA', 'testschema', N'TABLE', 'mytable', N'COLUMN', quota",
];
- self::assertEquals($expectedSql, $this->_platform->getAlterTableSQL($tableDiff));
+ self::assertEquals($expectedSql, $this->platform->getAlterTableSQL($tableDiff));
}
public function testAlterTableWithSchemaDropColumnComments()
@@ -616,7 +618,7 @@ public function testAlterTableWithSchemaDropColumnComments()
$expectedSql = ["EXEC sp_dropextendedproperty N'MS_Description', N'SCHEMA', 'testschema', N'TABLE', 'mytable', N'COLUMN', quota"];
- self::assertEquals($expectedSql, $this->_platform->getAlterTableSQL($tableDiff));
+ self::assertEquals($expectedSql, $this->platform->getAlterTableSQL($tableDiff));
}
public function testAlterTableWithSchemaUpdateColumnComments()
@@ -631,7 +633,7 @@ public function testAlterTableWithSchemaUpdateColumnComments()
$expectedSql = ["EXEC sp_updateextendedproperty N'MS_Description', N'B comment', N'SCHEMA', 'testschema', N'TABLE', 'mytable', N'COLUMN', quota"];
- self::assertEquals($expectedSql, $this->_platform->getAlterTableSQL($tableDiff));
+ self::assertEquals($expectedSql, $this->platform->getAlterTableSQL($tableDiff));
}
/**
@@ -639,10 +641,10 @@ public function testAlterTableWithSchemaUpdateColumnComments()
*/
public function getCreateTableColumnCommentsSQL()
{
- return array(
- "CREATE TABLE test (id INT NOT NULL, PRIMARY KEY (id))",
+ return [
+ 'CREATE TABLE test (id INT NOT NULL, PRIMARY KEY (id))',
"EXEC sp_addextendedproperty N'MS_Description', N'This is a comment', N'SCHEMA', 'dbo', N'TABLE', 'test', N'COLUMN', id",
- );
+ ];
}
/**
@@ -650,12 +652,12 @@ public function getCreateTableColumnCommentsSQL()
*/
public function getAlterTableColumnCommentsSQL()
{
- return array(
- "ALTER TABLE mytable ADD quota INT NOT NULL",
+ return [
+ 'ALTER TABLE mytable ADD quota INT NOT NULL',
"EXEC sp_addextendedproperty N'MS_Description', N'A comment', N'SCHEMA', 'dbo', N'TABLE', 'mytable', N'COLUMN', quota",
// todo
//"EXEC sp_addextendedproperty N'MS_Description', N'B comment', N'SCHEMA', dbo, N'TABLE', mytable, N'COLUMN', baz",
- );
+ ];
}
/**
@@ -663,10 +665,10 @@ public function getAlterTableColumnCommentsSQL()
*/
public function getCreateTableColumnTypeCommentsSQL()
{
- return array(
- "CREATE TABLE test (id INT NOT NULL, data VARCHAR(MAX) NOT NULL, PRIMARY KEY (id))",
+ return [
+ 'CREATE TABLE test (id INT NOT NULL, data VARCHAR(MAX) NOT NULL, PRIMARY KEY (id))',
"EXEC sp_addextendedproperty N'MS_Description', N'(DC2Type:array)', N'SCHEMA', 'dbo', N'TABLE', 'test', N'COLUMN', data",
- );
+ ];
}
/**
@@ -675,24 +677,24 @@ public function getCreateTableColumnTypeCommentsSQL()
public function testGeneratesCreateTableSQLWithColumnComments()
{
$table = new Table('mytable');
- $table->addColumn('id', 'integer', array('autoincrement' => true));
- $table->addColumn('comment_null', 'integer', array('comment' => null));
- $table->addColumn('comment_false', 'integer', array('comment' => false));
- $table->addColumn('comment_empty_string', 'integer', array('comment' => ''));
- $table->addColumn('comment_integer_0', 'integer', array('comment' => 0));
- $table->addColumn('comment_float_0', 'integer', array('comment' => 0.0));
- $table->addColumn('comment_string_0', 'integer', array('comment' => '0'));
- $table->addColumn('comment', 'integer', array('comment' => 'Doctrine 0wnz you!'));
- $table->addColumn('`comment_quoted`', 'integer', array('comment' => 'Doctrine 0wnz comments for explicitly quoted columns!'));
- $table->addColumn('create', 'integer', array('comment' => 'Doctrine 0wnz comments for reserved keyword columns!'));
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
+ $table->addColumn('comment_null', 'integer', ['comment' => null]);
+ $table->addColumn('comment_false', 'integer', ['comment' => false]);
+ $table->addColumn('comment_empty_string', 'integer', ['comment' => '']);
+ $table->addColumn('comment_integer_0', 'integer', ['comment' => 0]);
+ $table->addColumn('comment_float_0', 'integer', ['comment' => 0.0]);
+ $table->addColumn('comment_string_0', 'integer', ['comment' => '0']);
+ $table->addColumn('comment', 'integer', ['comment' => 'Doctrine 0wnz you!']);
+ $table->addColumn('`comment_quoted`', 'integer', ['comment' => 'Doctrine 0wnz comments for explicitly quoted columns!']);
+ $table->addColumn('create', 'integer', ['comment' => 'Doctrine 0wnz comments for reserved keyword columns!']);
$table->addColumn('commented_type', 'object');
- $table->addColumn('commented_type_with_comment', 'array', array('comment' => 'Doctrine array type.'));
- $table->addColumn('comment_with_string_literal_char', 'string', array('comment' => "O'Reilly"));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('commented_type_with_comment', 'array', ['comment' => 'Doctrine array type.']);
+ $table->addColumn('comment_with_string_literal_char', 'string', ['comment' => "O'Reilly"]);
+ $table->setPrimaryKey(['id']);
self::assertEquals(
- array(
- "CREATE TABLE mytable (id INT IDENTITY NOT NULL, comment_null INT NOT NULL, comment_false INT NOT NULL, comment_empty_string INT NOT NULL, comment_integer_0 INT NOT NULL, comment_float_0 INT NOT NULL, comment_string_0 INT NOT NULL, comment INT NOT NULL, [comment_quoted] INT NOT NULL, [create] INT NOT NULL, commented_type VARCHAR(MAX) NOT NULL, commented_type_with_comment VARCHAR(MAX) NOT NULL, comment_with_string_literal_char NVARCHAR(255) NOT NULL, PRIMARY KEY (id))",
+ [
+ 'CREATE TABLE mytable (id INT IDENTITY NOT NULL, comment_null INT NOT NULL, comment_false INT NOT NULL, comment_empty_string INT NOT NULL, comment_integer_0 INT NOT NULL, comment_float_0 INT NOT NULL, comment_string_0 INT NOT NULL, comment INT NOT NULL, [comment_quoted] INT NOT NULL, [create] INT NOT NULL, commented_type VARCHAR(MAX) NOT NULL, commented_type_with_comment VARCHAR(MAX) NOT NULL, comment_with_string_literal_char NVARCHAR(255) NOT NULL, PRIMARY KEY (id))',
"EXEC sp_addextendedproperty N'MS_Description', N'0', N'SCHEMA', 'dbo', N'TABLE', 'mytable', N'COLUMN', comment_integer_0",
"EXEC sp_addextendedproperty N'MS_Description', N'0', N'SCHEMA', 'dbo', N'TABLE', 'mytable', N'COLUMN', comment_float_0",
"EXEC sp_addextendedproperty N'MS_Description', N'0', N'SCHEMA', 'dbo', N'TABLE', 'mytable', N'COLUMN', comment_string_0",
@@ -702,8 +704,8 @@ public function testGeneratesCreateTableSQLWithColumnComments()
"EXEC sp_addextendedproperty N'MS_Description', N'(DC2Type:object)', N'SCHEMA', 'dbo', N'TABLE', 'mytable', N'COLUMN', commented_type",
"EXEC sp_addextendedproperty N'MS_Description', N'Doctrine array type.(DC2Type:array)', N'SCHEMA', 'dbo', N'TABLE', 'mytable', N'COLUMN', commented_type_with_comment",
"EXEC sp_addextendedproperty N'MS_Description', N'O''Reilly', N'SCHEMA', 'dbo', N'TABLE', 'mytable', N'COLUMN', comment_with_string_literal_char",
- ),
- $this->_platform->getCreateTableSQL($table)
+ ],
+ $this->platform->getCreateTableSQL($table)
);
}
@@ -714,108 +716,108 @@ public function testGeneratesCreateTableSQLWithColumnComments()
public function testGeneratesAlterTableSQLWithColumnComments()
{
$table = new Table('mytable');
- $table->addColumn('id', 'integer', array('autoincrement' => true));
- $table->addColumn('comment_null', 'integer', array('comment' => null));
- $table->addColumn('comment_false', 'integer', array('comment' => false));
- $table->addColumn('comment_empty_string', 'integer', array('comment' => ''));
- $table->addColumn('comment_integer_0', 'integer', array('comment' => 0));
- $table->addColumn('comment_float_0', 'integer', array('comment' => 0.0));
- $table->addColumn('comment_string_0', 'integer', array('comment' => '0'));
- $table->addColumn('comment', 'integer', array('comment' => 'Doctrine 0wnz you!'));
- $table->addColumn('`comment_quoted`', 'integer', array('comment' => 'Doctrine 0wnz comments for explicitly quoted columns!'));
- $table->addColumn('create', 'integer', array('comment' => 'Doctrine 0wnz comments for reserved keyword columns!'));
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
+ $table->addColumn('comment_null', 'integer', ['comment' => null]);
+ $table->addColumn('comment_false', 'integer', ['comment' => false]);
+ $table->addColumn('comment_empty_string', 'integer', ['comment' => '']);
+ $table->addColumn('comment_integer_0', 'integer', ['comment' => 0]);
+ $table->addColumn('comment_float_0', 'integer', ['comment' => 0.0]);
+ $table->addColumn('comment_string_0', 'integer', ['comment' => '0']);
+ $table->addColumn('comment', 'integer', ['comment' => 'Doctrine 0wnz you!']);
+ $table->addColumn('`comment_quoted`', 'integer', ['comment' => 'Doctrine 0wnz comments for explicitly quoted columns!']);
+ $table->addColumn('create', 'integer', ['comment' => 'Doctrine 0wnz comments for reserved keyword columns!']);
$table->addColumn('commented_type', 'object');
- $table->addColumn('commented_type_with_comment', 'array', array('comment' => 'Doctrine array type.'));
- $table->addColumn('comment_with_string_literal_quote_char', 'array', array('comment' => "O'Reilly"));
- $table->setPrimaryKey(array('id'));
-
- $tableDiff = new TableDiff('mytable');
- $tableDiff->fromTable = $table;
- $tableDiff->addedColumns['added_comment_none'] = new Column('added_comment_none', Type::getType('integer'));
- $tableDiff->addedColumns['added_comment_null'] = new Column('added_comment_null', Type::getType('integer'), array('comment' => null));
- $tableDiff->addedColumns['added_comment_false'] = new Column('added_comment_false', Type::getType('integer'), array('comment' => false));
- $tableDiff->addedColumns['added_comment_empty_string'] = new Column('added_comment_empty_string', Type::getType('integer'), array('comment' => ''));
- $tableDiff->addedColumns['added_comment_integer_0'] = new Column('added_comment_integer_0', Type::getType('integer'), array('comment' => 0));
- $tableDiff->addedColumns['added_comment_float_0'] = new Column('added_comment_float_0', Type::getType('integer'), array('comment' => 0.0));
- $tableDiff->addedColumns['added_comment_string_0'] = new Column('added_comment_string_0', Type::getType('integer'), array('comment' => '0'));
- $tableDiff->addedColumns['added_comment'] = new Column('added_comment', Type::getType('integer'), array('comment' => 'Doctrine'));
- $tableDiff->addedColumns['`added_comment_quoted`'] = new Column('`added_comment_quoted`', Type::getType('integer'), array('comment' => 'rulez'));
- $tableDiff->addedColumns['select'] = new Column('select', Type::getType('integer'), array('comment' => '666'));
- $tableDiff->addedColumns['added_commented_type'] = new Column('added_commented_type', Type::getType('object'));
- $tableDiff->addedColumns['added_commented_type_with_comment'] = new Column('added_commented_type_with_comment', Type::getType('array'), array('comment' => '666'));
- $tableDiff->addedColumns['added_comment_with_string_literal_char'] = new Column('added_comment_with_string_literal_char', Type::getType('string'), array('comment' => "''"));
-
- $tableDiff->renamedColumns['comment_float_0'] = new Column('comment_double_0', Type::getType('decimal'), array('comment' => 'Double for real!'));
+ $table->addColumn('commented_type_with_comment', 'array', ['comment' => 'Doctrine array type.']);
+ $table->addColumn('comment_with_string_literal_quote_char', 'array', ['comment' => "O'Reilly"]);
+ $table->setPrimaryKey(['id']);
+
+ $tableDiff = new TableDiff('mytable');
+ $tableDiff->fromTable = $table;
+ $tableDiff->addedColumns['added_comment_none'] = new Column('added_comment_none', Type::getType('integer'));
+ $tableDiff->addedColumns['added_comment_null'] = new Column('added_comment_null', Type::getType('integer'), ['comment' => null]);
+ $tableDiff->addedColumns['added_comment_false'] = new Column('added_comment_false', Type::getType('integer'), ['comment' => false]);
+ $tableDiff->addedColumns['added_comment_empty_string'] = new Column('added_comment_empty_string', Type::getType('integer'), ['comment' => '']);
+ $tableDiff->addedColumns['added_comment_integer_0'] = new Column('added_comment_integer_0', Type::getType('integer'), ['comment' => 0]);
+ $tableDiff->addedColumns['added_comment_float_0'] = new Column('added_comment_float_0', Type::getType('integer'), ['comment' => 0.0]);
+ $tableDiff->addedColumns['added_comment_string_0'] = new Column('added_comment_string_0', Type::getType('integer'), ['comment' => '0']);
+ $tableDiff->addedColumns['added_comment'] = new Column('added_comment', Type::getType('integer'), ['comment' => 'Doctrine']);
+ $tableDiff->addedColumns['`added_comment_quoted`'] = new Column('`added_comment_quoted`', Type::getType('integer'), ['comment' => 'rulez']);
+ $tableDiff->addedColumns['select'] = new Column('select', Type::getType('integer'), ['comment' => '666']);
+ $tableDiff->addedColumns['added_commented_type'] = new Column('added_commented_type', Type::getType('object'));
+ $tableDiff->addedColumns['added_commented_type_with_comment'] = new Column('added_commented_type_with_comment', Type::getType('array'), ['comment' => '666']);
+ $tableDiff->addedColumns['added_comment_with_string_literal_char'] = new Column('added_comment_with_string_literal_char', Type::getType('string'), ['comment' => "''"]);
+
+ $tableDiff->renamedColumns['comment_float_0'] = new Column('comment_double_0', Type::getType('decimal'), ['comment' => 'Double for real!']);
// Add comment to non-commented column.
$tableDiff->changedColumns['id'] = new ColumnDiff(
'id',
- new Column('id', Type::getType('integer'), array('autoincrement' => true, 'comment' => 'primary')),
- array('comment'),
- new Column('id', Type::getType('integer'), array('autoincrement' => true))
+ new Column('id', Type::getType('integer'), ['autoincrement' => true, 'comment' => 'primary']),
+ ['comment'],
+ new Column('id', Type::getType('integer'), ['autoincrement' => true])
);
// Remove comment from null-commented column.
$tableDiff->changedColumns['comment_null'] = new ColumnDiff(
'comment_null',
new Column('comment_null', Type::getType('string')),
- array('type'),
- new Column('comment_null', Type::getType('integer'), array('comment' => null))
+ ['type'],
+ new Column('comment_null', Type::getType('integer'), ['comment' => null])
);
// Add comment to false-commented column.
$tableDiff->changedColumns['comment_false'] = new ColumnDiff(
'comment_false',
- new Column('comment_false', Type::getType('integer'), array('comment' => 'false')),
- array('comment'),
- new Column('comment_false', Type::getType('integer'), array('comment' => false))
+ new Column('comment_false', Type::getType('integer'), ['comment' => 'false']),
+ ['comment'],
+ new Column('comment_false', Type::getType('integer'), ['comment' => false])
);
// Change type to custom type from empty string commented column.
$tableDiff->changedColumns['comment_empty_string'] = new ColumnDiff(
'comment_empty_string',
new Column('comment_empty_string', Type::getType('object')),
- array('type'),
- new Column('comment_empty_string', Type::getType('integer'), array('comment' => ''))
+ ['type'],
+ new Column('comment_empty_string', Type::getType('integer'), ['comment' => ''])
);
// Change comment to false-comment from zero-string commented column.
$tableDiff->changedColumns['comment_string_0'] = new ColumnDiff(
'comment_string_0',
- new Column('comment_string_0', Type::getType('integer'), array('comment' => false)),
- array('comment'),
- new Column('comment_string_0', Type::getType('integer'), array('comment' => '0'))
+ new Column('comment_string_0', Type::getType('integer'), ['comment' => false]),
+ ['comment'],
+ new Column('comment_string_0', Type::getType('integer'), ['comment' => '0'])
);
// Remove comment from regular commented column.
$tableDiff->changedColumns['comment'] = new ColumnDiff(
'comment',
new Column('comment', Type::getType('integer')),
- array('comment'),
- new Column('comment', Type::getType('integer'), array('comment' => 'Doctrine 0wnz you!'))
+ ['comment'],
+ new Column('comment', Type::getType('integer'), ['comment' => 'Doctrine 0wnz you!'])
);
// Change comment and change type to custom type from regular commented column.
$tableDiff->changedColumns['`comment_quoted`'] = new ColumnDiff(
'`comment_quoted`',
- new Column('`comment_quoted`', Type::getType('array'), array('comment' => 'Doctrine array.')),
- array('comment', 'type'),
- new Column('`comment_quoted`', Type::getType('integer'), array('comment' => 'Doctrine 0wnz you!'))
+ new Column('`comment_quoted`', Type::getType('array'), ['comment' => 'Doctrine array.']),
+ ['comment', 'type'],
+ new Column('`comment_quoted`', Type::getType('integer'), ['comment' => 'Doctrine 0wnz you!'])
);
// Remove comment and change type to custom type from regular commented column.
$tableDiff->changedColumns['create'] = new ColumnDiff(
'create',
new Column('create', Type::getType('object')),
- array('comment', 'type'),
- new Column('create', Type::getType('integer'), array('comment' => 'Doctrine 0wnz comments for reserved keyword columns!'))
+ ['comment', 'type'],
+ new Column('create', Type::getType('integer'), ['comment' => 'Doctrine 0wnz comments for reserved keyword columns!'])
);
// Add comment and change custom type to regular type from non-commented column.
$tableDiff->changedColumns['commented_type'] = new ColumnDiff(
'commented_type',
- new Column('commented_type', Type::getType('integer'), array('comment' => 'foo')),
- array('comment', 'type'),
+ new Column('commented_type', Type::getType('integer'), ['comment' => 'foo']),
+ ['comment', 'type'],
new Column('commented_type', Type::getType('object'))
);
@@ -823,45 +825,45 @@ public function testGeneratesAlterTableSQLWithColumnComments()
$tableDiff->changedColumns['commented_type_with_comment'] = new ColumnDiff(
'commented_type_with_comment',
new Column('commented_type_with_comment', Type::getType('array')),
- array('comment'),
- new Column('commented_type_with_comment', Type::getType('array'), array('comment' => 'Doctrine array type.'))
+ ['comment'],
+ new Column('commented_type_with_comment', Type::getType('array'), ['comment' => 'Doctrine array type.'])
);
// Change comment from comment with string literal char column.
$tableDiff->changedColumns['comment_with_string_literal_char'] = new ColumnDiff(
'comment_with_string_literal_char',
- new Column('comment_with_string_literal_char', Type::getType('string'), array('comment' => "'")),
- array('comment'),
- new Column('comment_with_string_literal_char', Type::getType('array'), array('comment' => "O'Reilly"))
+ new Column('comment_with_string_literal_char', Type::getType('string'), ['comment' => "'"]),
+ ['comment'],
+ new Column('comment_with_string_literal_char', Type::getType('array'), ['comment' => "O'Reilly"])
);
- $tableDiff->removedColumns['comment_integer_0'] = new Column('comment_integer_0', Type::getType('integer'), array('comment' => 0));
+ $tableDiff->removedColumns['comment_integer_0'] = new Column('comment_integer_0', Type::getType('integer'), ['comment' => 0]);
self::assertEquals(
- array(
+ [
// Renamed columns.
"sp_RENAME 'mytable.comment_float_0', 'comment_double_0', 'COLUMN'",
// Added columns.
- "ALTER TABLE mytable ADD added_comment_none INT NOT NULL",
- "ALTER TABLE mytable ADD added_comment_null INT NOT NULL",
- "ALTER TABLE mytable ADD added_comment_false INT NOT NULL",
- "ALTER TABLE mytable ADD added_comment_empty_string INT NOT NULL",
- "ALTER TABLE mytable ADD added_comment_integer_0 INT NOT NULL",
- "ALTER TABLE mytable ADD added_comment_float_0 INT NOT NULL",
- "ALTER TABLE mytable ADD added_comment_string_0 INT NOT NULL",
- "ALTER TABLE mytable ADD added_comment INT NOT NULL",
- "ALTER TABLE mytable ADD [added_comment_quoted] INT NOT NULL",
- "ALTER TABLE mytable ADD [select] INT NOT NULL",
- "ALTER TABLE mytable ADD added_commented_type VARCHAR(MAX) NOT NULL",
- "ALTER TABLE mytable ADD added_commented_type_with_comment VARCHAR(MAX) NOT NULL",
- "ALTER TABLE mytable ADD added_comment_with_string_literal_char NVARCHAR(255) NOT NULL",
- "ALTER TABLE mytable DROP COLUMN comment_integer_0",
- "ALTER TABLE mytable ALTER COLUMN comment_null NVARCHAR(255) NOT NULL",
- "ALTER TABLE mytable ALTER COLUMN comment_empty_string VARCHAR(MAX) NOT NULL",
- "ALTER TABLE mytable ALTER COLUMN [comment_quoted] VARCHAR(MAX) NOT NULL",
- "ALTER TABLE mytable ALTER COLUMN [create] VARCHAR(MAX) NOT NULL",
- "ALTER TABLE mytable ALTER COLUMN commented_type INT NOT NULL",
+ 'ALTER TABLE mytable ADD added_comment_none INT NOT NULL',
+ 'ALTER TABLE mytable ADD added_comment_null INT NOT NULL',
+ 'ALTER TABLE mytable ADD added_comment_false INT NOT NULL',
+ 'ALTER TABLE mytable ADD added_comment_empty_string INT NOT NULL',
+ 'ALTER TABLE mytable ADD added_comment_integer_0 INT NOT NULL',
+ 'ALTER TABLE mytable ADD added_comment_float_0 INT NOT NULL',
+ 'ALTER TABLE mytable ADD added_comment_string_0 INT NOT NULL',
+ 'ALTER TABLE mytable ADD added_comment INT NOT NULL',
+ 'ALTER TABLE mytable ADD [added_comment_quoted] INT NOT NULL',
+ 'ALTER TABLE mytable ADD [select] INT NOT NULL',
+ 'ALTER TABLE mytable ADD added_commented_type VARCHAR(MAX) NOT NULL',
+ 'ALTER TABLE mytable ADD added_commented_type_with_comment VARCHAR(MAX) NOT NULL',
+ 'ALTER TABLE mytable ADD added_comment_with_string_literal_char NVARCHAR(255) NOT NULL',
+ 'ALTER TABLE mytable DROP COLUMN comment_integer_0',
+ 'ALTER TABLE mytable ALTER COLUMN comment_null NVARCHAR(255) NOT NULL',
+ 'ALTER TABLE mytable ALTER COLUMN comment_empty_string VARCHAR(MAX) NOT NULL',
+ 'ALTER TABLE mytable ALTER COLUMN [comment_quoted] VARCHAR(MAX) NOT NULL',
+ 'ALTER TABLE mytable ALTER COLUMN [create] VARCHAR(MAX) NOT NULL',
+ 'ALTER TABLE mytable ALTER COLUMN commented_type INT NOT NULL',
// Added columns.
"EXEC sp_addextendedproperty N'MS_Description', N'0', N'SCHEMA', 'dbo', N'TABLE', 'mytable', N'COLUMN', added_comment_integer_0",
@@ -885,8 +887,8 @@ public function testGeneratesAlterTableSQLWithColumnComments()
"EXEC sp_updateextendedproperty N'MS_Description', N'foo', N'SCHEMA', 'dbo', N'TABLE', 'mytable', N'COLUMN', commented_type",
"EXEC sp_updateextendedproperty N'MS_Description', N'(DC2Type:array)', N'SCHEMA', 'dbo', N'TABLE', 'mytable', N'COLUMN', commented_type_with_comment",
"EXEC sp_updateextendedproperty N'MS_Description', N'''', N'SCHEMA', 'dbo', N'TABLE', 'mytable', N'COLUMN', comment_with_string_literal_char",
- ),
- $this->_platform->getAlterTableSQL($tableDiff)
+ ],
+ $this->platform->getAlterTableSQL($tableDiff)
);
}
@@ -895,80 +897,80 @@ public function testGeneratesAlterTableSQLWithColumnComments()
*/
public function testInitializesDoctrineTypeMappings()
{
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('bigint'));
- self::assertSame('bigint', $this->_platform->getDoctrineTypeMapping('bigint'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('bigint'));
+ self::assertSame('bigint', $this->platform->getDoctrineTypeMapping('bigint'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('numeric'));
- self::assertSame('decimal', $this->_platform->getDoctrineTypeMapping('numeric'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('numeric'));
+ self::assertSame('decimal', $this->platform->getDoctrineTypeMapping('numeric'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('bit'));
- self::assertSame('boolean', $this->_platform->getDoctrineTypeMapping('bit'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('bit'));
+ self::assertSame('boolean', $this->platform->getDoctrineTypeMapping('bit'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('smallint'));
- self::assertSame('smallint', $this->_platform->getDoctrineTypeMapping('smallint'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('smallint'));
+ self::assertSame('smallint', $this->platform->getDoctrineTypeMapping('smallint'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('decimal'));
- self::assertSame('decimal', $this->_platform->getDoctrineTypeMapping('decimal'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('decimal'));
+ self::assertSame('decimal', $this->platform->getDoctrineTypeMapping('decimal'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('smallmoney'));
- self::assertSame('integer', $this->_platform->getDoctrineTypeMapping('smallmoney'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('smallmoney'));
+ self::assertSame('integer', $this->platform->getDoctrineTypeMapping('smallmoney'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('int'));
- self::assertSame('integer', $this->_platform->getDoctrineTypeMapping('int'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('int'));
+ self::assertSame('integer', $this->platform->getDoctrineTypeMapping('int'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('tinyint'));
- self::assertSame('smallint', $this->_platform->getDoctrineTypeMapping('tinyint'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('tinyint'));
+ self::assertSame('smallint', $this->platform->getDoctrineTypeMapping('tinyint'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('money'));
- self::assertSame('integer', $this->_platform->getDoctrineTypeMapping('money'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('money'));
+ self::assertSame('integer', $this->platform->getDoctrineTypeMapping('money'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('float'));
- self::assertSame('float', $this->_platform->getDoctrineTypeMapping('float'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('float'));
+ self::assertSame('float', $this->platform->getDoctrineTypeMapping('float'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('real'));
- self::assertSame('float', $this->_platform->getDoctrineTypeMapping('real'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('real'));
+ self::assertSame('float', $this->platform->getDoctrineTypeMapping('real'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('double'));
- self::assertSame('float', $this->_platform->getDoctrineTypeMapping('double'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('double'));
+ self::assertSame('float', $this->platform->getDoctrineTypeMapping('double'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('double precision'));
- self::assertSame('float', $this->_platform->getDoctrineTypeMapping('double precision'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('double precision'));
+ self::assertSame('float', $this->platform->getDoctrineTypeMapping('double precision'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('smalldatetime'));
- self::assertSame('datetime', $this->_platform->getDoctrineTypeMapping('smalldatetime'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('smalldatetime'));
+ self::assertSame('datetime', $this->platform->getDoctrineTypeMapping('smalldatetime'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('datetime'));
- self::assertSame('datetime', $this->_platform->getDoctrineTypeMapping('datetime'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('datetime'));
+ self::assertSame('datetime', $this->platform->getDoctrineTypeMapping('datetime'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('char'));
- self::assertSame('string', $this->_platform->getDoctrineTypeMapping('char'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('char'));
+ self::assertSame('string', $this->platform->getDoctrineTypeMapping('char'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('varchar'));
- self::assertSame('string', $this->_platform->getDoctrineTypeMapping('varchar'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('varchar'));
+ self::assertSame('string', $this->platform->getDoctrineTypeMapping('varchar'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('text'));
- self::assertSame('text', $this->_platform->getDoctrineTypeMapping('text'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('text'));
+ self::assertSame('text', $this->platform->getDoctrineTypeMapping('text'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('nchar'));
- self::assertSame('string', $this->_platform->getDoctrineTypeMapping('nchar'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('nchar'));
+ self::assertSame('string', $this->platform->getDoctrineTypeMapping('nchar'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('nvarchar'));
- self::assertSame('string', $this->_platform->getDoctrineTypeMapping('nvarchar'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('nvarchar'));
+ self::assertSame('string', $this->platform->getDoctrineTypeMapping('nvarchar'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('ntext'));
- self::assertSame('text', $this->_platform->getDoctrineTypeMapping('ntext'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('ntext'));
+ self::assertSame('text', $this->platform->getDoctrineTypeMapping('ntext'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('binary'));
- self::assertSame('binary', $this->_platform->getDoctrineTypeMapping('binary'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('binary'));
+ self::assertSame('binary', $this->platform->getDoctrineTypeMapping('binary'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('varbinary'));
- self::assertSame('binary', $this->_platform->getDoctrineTypeMapping('varbinary'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('varbinary'));
+ self::assertSame('binary', $this->platform->getDoctrineTypeMapping('varbinary'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('image'));
- self::assertSame('blob', $this->_platform->getDoctrineTypeMapping('image'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('image'));
+ self::assertSame('blob', $this->platform->getDoctrineTypeMapping('image'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('uniqueidentifier'));
- self::assertSame('guid', $this->_platform->getDoctrineTypeMapping('uniqueidentifier'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('uniqueidentifier'));
+ self::assertSame('guid', $this->platform->getDoctrineTypeMapping('uniqueidentifier'));
}
protected function getBinaryMaxLength()
@@ -978,13 +980,13 @@ protected function getBinaryMaxLength()
public function testReturnsBinaryTypeDeclarationSQL()
{
- self::assertSame('VARBINARY(255)', $this->_platform->getBinaryTypeDeclarationSQL(array()));
- self::assertSame('VARBINARY(255)', $this->_platform->getBinaryTypeDeclarationSQL(array('length' => 0)));
- self::assertSame('VARBINARY(8000)', $this->_platform->getBinaryTypeDeclarationSQL(array('length' => 8000)));
+ self::assertSame('VARBINARY(255)', $this->platform->getBinaryTypeDeclarationSQL([]));
+ self::assertSame('VARBINARY(255)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0]));
+ self::assertSame('VARBINARY(8000)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 8000]));
- self::assertSame('BINARY(255)', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true)));
- self::assertSame('BINARY(255)', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true, 'length' => 0)));
- self::assertSame('BINARY(8000)', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true, 'length' => 8000)));
+ self::assertSame('BINARY(255)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true]));
+ self::assertSame('BINARY(255)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 0]));
+ self::assertSame('BINARY(8000)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 8000]));
}
/**
@@ -993,8 +995,8 @@ public function testReturnsBinaryTypeDeclarationSQL()
*/
public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL()
{
- self::assertSame('VARBINARY(MAX)', $this->_platform->getBinaryTypeDeclarationSQL(['length' => 8001]));
- self::assertSame('VARBINARY(MAX)', $this->_platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 8001]));
+ self::assertSame('VARBINARY(MAX)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 8001]));
+ self::assertSame('VARBINARY(MAX)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 8001]));
}
/**
@@ -1002,9 +1004,7 @@ public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL()
*/
protected function getAlterTableRenameIndexSQL()
{
- return array(
- "EXEC sp_RENAME N'mytable.idx_foo', N'idx_bar', N'INDEX'",
- );
+ return ["EXEC sp_RENAME N'mytable.idx_foo', N'idx_bar', N'INDEX'"];
}
/**
@@ -1012,10 +1012,10 @@ protected function getAlterTableRenameIndexSQL()
*/
protected function getQuotedAlterTableRenameIndexSQL()
{
- return array(
+ return [
"EXEC sp_RENAME N'[table].[create]', N'[select]', N'INDEX'",
"EXEC sp_RENAME N'[table].[foo]', N'[bar]', N'INDEX'",
- );
+ ];
}
/**
@@ -1026,37 +1026,37 @@ public function testChangeColumnsTypeWithDefaultValue()
$tableName = 'column_def_change_type';
$table = new Table($tableName);
- $table->addColumn('col_int', 'smallint', array('default' => 666));
- $table->addColumn('col_string', 'string', array('default' => 'foo'));
+ $table->addColumn('col_int', 'smallint', ['default' => 666]);
+ $table->addColumn('col_string', 'string', ['default' => 'foo']);
- $tableDiff = new TableDiff($tableName);
- $tableDiff->fromTable = $table;
+ $tableDiff = new TableDiff($tableName);
+ $tableDiff->fromTable = $table;
$tableDiff->changedColumns['col_int'] = new ColumnDiff(
'col_int',
- new Column('col_int', Type::getType('integer'), array('default' => 666)),
- array('type'),
- new Column('col_int', Type::getType('smallint'), array('default' => 666))
+ new Column('col_int', Type::getType('integer'), ['default' => 666]),
+ ['type'],
+ new Column('col_int', Type::getType('smallint'), ['default' => 666])
);
$tableDiff->changedColumns['col_string'] = new ColumnDiff(
'col_string',
- new Column('col_string', Type::getType('string'), array('default' => 666, 'fixed' => true)),
- array('fixed'),
- new Column('col_string', Type::getType('string'), array('default' => 666))
+ new Column('col_string', Type::getType('string'), ['default' => 666, 'fixed' => true]),
+ ['fixed'],
+ new Column('col_string', Type::getType('string'), ['default' => 666])
);
- $expected = $this->_platform->getAlterTableSQL($tableDiff);
+ $expected = $this->platform->getAlterTableSQL($tableDiff);
self::assertSame(
$expected,
- array(
+ [
'ALTER TABLE column_def_change_type DROP CONSTRAINT DF_829302E0_FA2CB292',
'ALTER TABLE column_def_change_type ALTER COLUMN col_int INT NOT NULL',
'ALTER TABLE column_def_change_type ADD CONSTRAINT DF_829302E0_FA2CB292 DEFAULT 666 FOR col_int',
'ALTER TABLE column_def_change_type DROP CONSTRAINT DF_829302E0_2725A6D0',
'ALTER TABLE column_def_change_type ALTER COLUMN col_string NCHAR(255) NOT NULL',
"ALTER TABLE column_def_change_type ADD CONSTRAINT DF_829302E0_2725A6D0 DEFAULT '666' FOR col_string",
- )
+ ]
);
}
@@ -1065,7 +1065,7 @@ public function testChangeColumnsTypeWithDefaultValue()
*/
protected function getQuotedAlterTableRenameColumnSQL()
{
- return array(
+ return [
"sp_RENAME 'mytable.unquoted1', 'unquoted', 'COLUMN'",
"sp_RENAME 'mytable.unquoted2', '[where]', 'COLUMN'",
"sp_RENAME 'mytable.unquoted3', '[foo]', 'COLUMN'",
@@ -1075,7 +1075,7 @@ protected function getQuotedAlterTableRenameColumnSQL()
"sp_RENAME 'mytable.quoted1', 'quoted', 'COLUMN'",
"sp_RENAME 'mytable.quoted2', '[and]', 'COLUMN'",
"sp_RENAME 'mytable.quoted3', '[baz]', 'COLUMN'",
- );
+ ];
}
/**
@@ -1091,9 +1091,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL()
*/
protected function getAlterTableRenameIndexInSchemaSQL()
{
- return array(
- "EXEC sp_RENAME N'myschema.mytable.idx_foo', N'idx_bar', N'INDEX'",
- );
+ return ["EXEC sp_RENAME N'myschema.mytable.idx_foo', N'idx_bar', N'INDEX'"];
}
/**
@@ -1101,10 +1099,10 @@ protected function getAlterTableRenameIndexInSchemaSQL()
*/
protected function getQuotedAlterTableRenameIndexInSchemaSQL()
{
- return array(
+ return [
"EXEC sp_RENAME N'[schema].[table].[create]', N'[select]', N'INDEX'",
"EXEC sp_RENAME N'[schema].[table].[foo]', N'[bar]', N'INDEX'",
- );
+ ];
}
protected function getQuotesDropForeignKeySQL()
@@ -1123,21 +1121,21 @@ protected function getQuotesDropConstraintSQL()
*/
public function testGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL($table, $column, $expectedSql)
{
- self::assertSame($expectedSql, $this->_platform->getDefaultConstraintDeclarationSQL($table, $column));
+ self::assertSame($expectedSql, $this->platform->getDefaultConstraintDeclarationSQL($table, $column));
}
public function getGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL()
{
- return array(
+ return [
// Unquoted identifiers non-reserved keywords.
- array('mytable', array('name' => 'mycolumn', 'default' => 'foo'), " CONSTRAINT DF_6B2BD609_9BADD926 DEFAULT 'foo' FOR mycolumn"),
+ ['mytable', ['name' => 'mycolumn', 'default' => 'foo'], " CONSTRAINT DF_6B2BD609_9BADD926 DEFAULT 'foo' FOR mycolumn"],
// Quoted identifiers non-reserved keywords.
- array('`mytable`', array('name' => '`mycolumn`', 'default' => 'foo'), " CONSTRAINT DF_6B2BD609_9BADD926 DEFAULT 'foo' FOR [mycolumn]"),
+ ['`mytable`', ['name' => '`mycolumn`', 'default' => 'foo'], " CONSTRAINT DF_6B2BD609_9BADD926 DEFAULT 'foo' FOR [mycolumn]"],
// Unquoted identifiers reserved keywords.
- array('table', array('name' => 'select', 'default' => 'foo'), " CONSTRAINT DF_F6298F46_4BF2EAC0 DEFAULT 'foo' FOR [select]"),
+ ['table', ['name' => 'select', 'default' => 'foo'], " CONSTRAINT DF_F6298F46_4BF2EAC0 DEFAULT 'foo' FOR [select]"],
// Quoted identifiers reserved keywords.
- array('`table`', array('name' => '`select`', 'default' => 'foo'), " CONSTRAINT DF_F6298F46_4BF2EAC0 DEFAULT 'foo' FOR [select]"),
- );
+ ['`table`', ['name' => '`select`', 'default' => 'foo'], " CONSTRAINT DF_F6298F46_4BF2EAC0 DEFAULT 'foo' FOR [select]"],
+ ];
}
/**
@@ -1146,45 +1144,45 @@ public function getGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL()
*/
public function testGeneratesIdentifierNamesInCreateTableSQL($table, $expectedSql)
{
- self::assertSame($expectedSql, $this->_platform->getCreateTableSQL($table));
+ self::assertSame($expectedSql, $this->platform->getCreateTableSQL($table));
}
public function getGeneratesIdentifierNamesInCreateTableSQL()
{
- return array(
+ return [
// Unquoted identifiers non-reserved keywords.
- array(
- new Table('mytable', array(new Column('mycolumn', Type::getType('string'), array('default' => 'foo')))),
- array(
+ [
+ new Table('mytable', [new Column('mycolumn', Type::getType('string'), ['default' => 'foo'])]),
+ [
'CREATE TABLE mytable (mycolumn NVARCHAR(255) NOT NULL)',
- "ALTER TABLE mytable ADD CONSTRAINT DF_6B2BD609_9BADD926 DEFAULT 'foo' FOR mycolumn"
- )
- ),
+ "ALTER TABLE mytable ADD CONSTRAINT DF_6B2BD609_9BADD926 DEFAULT 'foo' FOR mycolumn",
+ ],
+ ],
// Quoted identifiers reserved keywords.
- array(
- new Table('`mytable`', array(new Column('`mycolumn`', Type::getType('string'), array('default' => 'foo')))),
- array(
+ [
+ new Table('`mytable`', [new Column('`mycolumn`', Type::getType('string'), ['default' => 'foo'])]),
+ [
'CREATE TABLE [mytable] ([mycolumn] NVARCHAR(255) NOT NULL)',
- "ALTER TABLE [mytable] ADD CONSTRAINT DF_6B2BD609_9BADD926 DEFAULT 'foo' FOR [mycolumn]"
- )
- ),
+ "ALTER TABLE [mytable] ADD CONSTRAINT DF_6B2BD609_9BADD926 DEFAULT 'foo' FOR [mycolumn]",
+ ],
+ ],
// Unquoted identifiers reserved keywords.
- array(
- new Table('table', array(new Column('select', Type::getType('string'), array('default' => 'foo')))),
- array(
+ [
+ new Table('table', [new Column('select', Type::getType('string'), ['default' => 'foo'])]),
+ [
'CREATE TABLE [table] ([select] NVARCHAR(255) NOT NULL)',
- "ALTER TABLE [table] ADD CONSTRAINT DF_F6298F46_4BF2EAC0 DEFAULT 'foo' FOR [select]"
- )
- ),
+ "ALTER TABLE [table] ADD CONSTRAINT DF_F6298F46_4BF2EAC0 DEFAULT 'foo' FOR [select]",
+ ],
+ ],
// Quoted identifiers reserved keywords.
- array(
- new Table('`table`', array(new Column('`select`', Type::getType('string'), array('default' => 'foo')))),
- array(
+ [
+ new Table('`table`', [new Column('`select`', Type::getType('string'), ['default' => 'foo'])]),
+ [
'CREATE TABLE [table] ([select] NVARCHAR(255) NOT NULL)',
- "ALTER TABLE [table] ADD CONSTRAINT DF_F6298F46_4BF2EAC0 DEFAULT 'foo' FOR [select]"
- )
- ),
- );
+ "ALTER TABLE [table] ADD CONSTRAINT DF_F6298F46_4BF2EAC0 DEFAULT 'foo' FOR [select]",
+ ],
+ ],
+ ];
}
/**
@@ -1193,109 +1191,109 @@ public function getGeneratesIdentifierNamesInCreateTableSQL()
*/
public function testGeneratesIdentifierNamesInAlterTableSQL($tableDiff, $expectedSql)
{
- self::assertSame($expectedSql, $this->_platform->getAlterTableSQL($tableDiff));
+ self::assertSame($expectedSql, $this->platform->getAlterTableSQL($tableDiff));
}
public function getGeneratesIdentifierNamesInAlterTableSQL()
{
- return array(
+ return [
// Unquoted identifiers non-reserved keywords.
- array(
+ [
new TableDiff(
'mytable',
- array(new Column('addcolumn', Type::getType('string'), array('default' => 'foo'))),
- array(
+ [new Column('addcolumn', Type::getType('string'), ['default' => 'foo'])],
+ [
'mycolumn' => new ColumnDiff(
'mycolumn',
- new Column('mycolumn', Type::getType('string'), array('default' => 'bar')),
- array('default'),
- new Column('mycolumn', Type::getType('string'), array('default' => 'foo'))
- )
- ),
- array(new Column('removecolumn', Type::getType('string'), array('default' => 'foo')))
+ new Column('mycolumn', Type::getType('string'), ['default' => 'bar']),
+ ['default'],
+ new Column('mycolumn', Type::getType('string'), ['default' => 'foo'])
+ ),
+ ],
+ [new Column('removecolumn', Type::getType('string'), ['default' => 'foo'])]
),
- array(
+ [
'ALTER TABLE mytable ADD addcolumn NVARCHAR(255) NOT NULL',
"ALTER TABLE mytable ADD CONSTRAINT DF_6B2BD609_4AD86123 DEFAULT 'foo' FOR addcolumn",
'ALTER TABLE mytable DROP COLUMN removecolumn',
'ALTER TABLE mytable DROP CONSTRAINT DF_6B2BD609_9BADD926',
'ALTER TABLE mytable ALTER COLUMN mycolumn NVARCHAR(255) NOT NULL',
- "ALTER TABLE mytable ADD CONSTRAINT DF_6B2BD609_9BADD926 DEFAULT 'bar' FOR mycolumn"
- )
- ),
+ "ALTER TABLE mytable ADD CONSTRAINT DF_6B2BD609_9BADD926 DEFAULT 'bar' FOR mycolumn",
+ ],
+ ],
// Quoted identifiers non-reserved keywords.
- array(
+ [
new TableDiff(
'`mytable`',
- array(new Column('`addcolumn`', Type::getType('string'), array('default' => 'foo'))),
- array(
+ [new Column('`addcolumn`', Type::getType('string'), ['default' => 'foo'])],
+ [
'mycolumn' => new ColumnDiff(
'`mycolumn`',
- new Column('`mycolumn`', Type::getType('string'), array('default' => 'bar')),
- array('default'),
- new Column('`mycolumn`', Type::getType('string'), array('default' => 'foo'))
- )
- ),
- array(new Column('`removecolumn`', Type::getType('string'), array('default' => 'foo')))
+ new Column('`mycolumn`', Type::getType('string'), ['default' => 'bar']),
+ ['default'],
+ new Column('`mycolumn`', Type::getType('string'), ['default' => 'foo'])
+ ),
+ ],
+ [new Column('`removecolumn`', Type::getType('string'), ['default' => 'foo'])]
),
- array(
+ [
'ALTER TABLE [mytable] ADD [addcolumn] NVARCHAR(255) NOT NULL',
"ALTER TABLE [mytable] ADD CONSTRAINT DF_6B2BD609_4AD86123 DEFAULT 'foo' FOR [addcolumn]",
'ALTER TABLE [mytable] DROP COLUMN [removecolumn]',
'ALTER TABLE [mytable] DROP CONSTRAINT DF_6B2BD609_9BADD926',
'ALTER TABLE [mytable] ALTER COLUMN [mycolumn] NVARCHAR(255) NOT NULL',
- "ALTER TABLE [mytable] ADD CONSTRAINT DF_6B2BD609_9BADD926 DEFAULT 'bar' FOR [mycolumn]"
- )
- ),
+ "ALTER TABLE [mytable] ADD CONSTRAINT DF_6B2BD609_9BADD926 DEFAULT 'bar' FOR [mycolumn]",
+ ],
+ ],
// Unquoted identifiers reserved keywords.
- array(
+ [
new TableDiff(
'table',
- array(new Column('add', Type::getType('string'), array('default' => 'foo'))),
- array(
+ [new Column('add', Type::getType('string'), ['default' => 'foo'])],
+ [
'select' => new ColumnDiff(
'select',
- new Column('select', Type::getType('string'), array('default' => 'bar')),
- array('default'),
- new Column('select', Type::getType('string'), array('default' => 'foo'))
- )
- ),
- array(new Column('drop', Type::getType('string'), array('default' => 'foo')))
+ new Column('select', Type::getType('string'), ['default' => 'bar']),
+ ['default'],
+ new Column('select', Type::getType('string'), ['default' => 'foo'])
+ ),
+ ],
+ [new Column('drop', Type::getType('string'), ['default' => 'foo'])]
),
- array(
+ [
'ALTER TABLE [table] ADD [add] NVARCHAR(255) NOT NULL',
"ALTER TABLE [table] ADD CONSTRAINT DF_F6298F46_FD1A73E7 DEFAULT 'foo' FOR [add]",
'ALTER TABLE [table] DROP COLUMN [drop]',
'ALTER TABLE [table] DROP CONSTRAINT DF_F6298F46_4BF2EAC0',
'ALTER TABLE [table] ALTER COLUMN [select] NVARCHAR(255) NOT NULL',
- "ALTER TABLE [table] ADD CONSTRAINT DF_F6298F46_4BF2EAC0 DEFAULT 'bar' FOR [select]"
- )
- ),
+ "ALTER TABLE [table] ADD CONSTRAINT DF_F6298F46_4BF2EAC0 DEFAULT 'bar' FOR [select]",
+ ],
+ ],
// Quoted identifiers reserved keywords.
- array(
+ [
new TableDiff(
'`table`',
- array(new Column('`add`', Type::getType('string'), array('default' => 'foo'))),
- array(
+ [new Column('`add`', Type::getType('string'), ['default' => 'foo'])],
+ [
'select' => new ColumnDiff(
'`select`',
- new Column('`select`', Type::getType('string'), array('default' => 'bar')),
- array('default'),
- new Column('`select`', Type::getType('string'), array('default' => 'foo'))
- )
- ),
- array(new Column('`drop`', Type::getType('string'), array('default' => 'foo')))
+ new Column('`select`', Type::getType('string'), ['default' => 'bar']),
+ ['default'],
+ new Column('`select`', Type::getType('string'), ['default' => 'foo'])
+ ),
+ ],
+ [new Column('`drop`', Type::getType('string'), ['default' => 'foo'])]
),
- array(
+ [
'ALTER TABLE [table] ADD [add] NVARCHAR(255) NOT NULL',
"ALTER TABLE [table] ADD CONSTRAINT DF_F6298F46_FD1A73E7 DEFAULT 'foo' FOR [add]",
'ALTER TABLE [table] DROP COLUMN [drop]',
'ALTER TABLE [table] DROP CONSTRAINT DF_F6298F46_4BF2EAC0',
'ALTER TABLE [table] ALTER COLUMN [select] NVARCHAR(255) NOT NULL',
- "ALTER TABLE [table] ADD CONSTRAINT DF_F6298F46_4BF2EAC0 DEFAULT 'bar' FOR [select]"
- )
- ),
- );
+ "ALTER TABLE [table] ADD CONSTRAINT DF_F6298F46_4BF2EAC0 DEFAULT 'bar' FOR [select]",
+ ],
+ ],
+ ];
}
/**
@@ -1303,7 +1301,7 @@ public function getGeneratesIdentifierNamesInAlterTableSQL()
*/
public function testReturnsGuidTypeDeclarationSQL()
{
- self::assertSame('UNIQUEIDENTIFIER', $this->_platform->getGuidTypeDeclarationSQL(array()));
+ self::assertSame('UNIQUEIDENTIFIER', $this->platform->getGuidTypeDeclarationSQL([]));
}
/**
@@ -1311,11 +1309,11 @@ public function testReturnsGuidTypeDeclarationSQL()
*/
public function getAlterTableRenameColumnSQL()
{
- return array(
+ return [
"sp_RENAME 'foo.bar', 'baz', 'COLUMN'",
'ALTER TABLE foo DROP CONSTRAINT DF_8C736521_76FF8CAA',
'ALTER TABLE foo ADD CONSTRAINT DF_8C736521_78240498 DEFAULT 666 FOR baz',
- );
+ ];
}
/**
@@ -1323,7 +1321,7 @@ public function getAlterTableRenameColumnSQL()
*/
protected function getQuotesTableIdentifiersInAlterTableSQL()
{
- return array(
+ return [
'ALTER TABLE [foo] DROP CONSTRAINT fk1',
'ALTER TABLE [foo] DROP CONSTRAINT fk2',
"sp_RENAME '[foo].id', 'war', 'COLUMN'",
@@ -1337,7 +1335,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL()
"WHERE tbl.name = 'table';EXEC sp_executesql @sql",
'ALTER TABLE [table] ADD CONSTRAINT fk_add FOREIGN KEY (fk3) REFERENCES fk_table (id)',
'ALTER TABLE [table] ADD CONSTRAINT fk2 FOREIGN KEY (fk2) REFERENCES fk_table2 (id)',
- );
+ ];
}
/**
@@ -1345,11 +1343,11 @@ protected function getQuotesTableIdentifiersInAlterTableSQL()
*/
protected function getCommentOnColumnSQL()
{
- return array(
+ return [
"COMMENT ON COLUMN foo.bar IS 'comment'",
"COMMENT ON COLUMN [Foo].[BAR] IS 'comment'",
"COMMENT ON COLUMN [select].[from] IS 'comment'",
- );
+ ];
}
/**
@@ -1357,14 +1355,14 @@ protected function getCommentOnColumnSQL()
*/
public function getReturnsForeignKeyReferentialActionSQL()
{
- return array(
- array('CASCADE', 'CASCADE'),
- array('SET NULL', 'SET NULL'),
- array('NO ACTION', 'NO ACTION'),
- array('RESTRICT', 'NO ACTION'),
- array('SET DEFAULT', 'SET DEFAULT'),
- array('CaScAdE', 'CASCADE'),
- );
+ return [
+ ['CASCADE', 'CASCADE'],
+ ['SET NULL', 'SET NULL'],
+ ['NO ACTION', 'NO ACTION'],
+ ['RESTRICT', 'NO ACTION'],
+ ['SET DEFAULT', 'SET DEFAULT'],
+ ['CaScAdE', 'CASCADE'],
+ ];
}
/**
@@ -1396,9 +1394,7 @@ protected function getQuotesReservedKeywordInTruncateTableSQL()
*/
protected function getAlterStringToFixedStringSQL()
{
- return array(
- 'ALTER TABLE mytable ALTER COLUMN name NCHAR(2) NOT NULL',
- );
+ return ['ALTER TABLE mytable ALTER COLUMN name NCHAR(2) NOT NULL'];
}
/**
@@ -1406,21 +1402,19 @@ protected function getAlterStringToFixedStringSQL()
*/
protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
{
- return array(
- "EXEC sp_RENAME N'mytable.idx_foo', N'idx_foo_renamed', N'INDEX'",
- );
+ return ["EXEC sp_RENAME N'mytable.idx_foo', N'idx_foo_renamed', N'INDEX'"];
}
public function testModifyLimitQueryWithTopNSubQueryWithOrderBy()
{
- $querySql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC)';
+ $querySql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC)';
$alteredSql = 'SELECT TOP 10 * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC)';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10);
$this->expectCteWithMaxRowNum($alteredSql, 10, $sql);
- $querySql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC) ORDER BY t.data2 DESC';
+ $querySql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC) ORDER BY t.data2 DESC';
$alteredSql = 'SELECT TOP 10 * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC) ORDER BY t.data2 DESC';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10);
$this->expectCteWithMaxRowNum($alteredSql, 10, $sql);
}
@@ -1429,7 +1423,7 @@ public function testModifyLimitQueryWithTopNSubQueryWithOrderBy()
*/
public function testQuotesTableNameInListTableColumnsSQL()
{
- self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableColumnsSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\'", $this->platform->getListTableColumnsSQL("Foo'Bar\\"), '', true);
}
/**
@@ -1439,7 +1433,7 @@ public function testQuotesSchemaNameInListTableColumnsSQL()
{
self::assertContains(
"'Foo''Bar\\'",
- $this->_platform->getListTableColumnsSQL("Foo'Bar\\.baz_table"),
+ $this->platform->getListTableColumnsSQL("Foo'Bar\\.baz_table"),
'',
true
);
@@ -1450,7 +1444,7 @@ public function testQuotesSchemaNameInListTableColumnsSQL()
*/
public function testQuotesTableNameInListTableForeignKeysSQL()
{
- self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\'", $this->platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
}
/**
@@ -1460,7 +1454,7 @@ public function testQuotesSchemaNameInListTableForeignKeysSQL()
{
self::assertContains(
"'Foo''Bar\\'",
- $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\.baz_table"),
+ $this->platform->getListTableForeignKeysSQL("Foo'Bar\\.baz_table"),
'',
true
);
@@ -1471,7 +1465,7 @@ public function testQuotesSchemaNameInListTableForeignKeysSQL()
*/
public function testQuotesTableNameInListTableIndexesSQL()
{
- self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableIndexesSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\'", $this->platform->getListTableIndexesSQL("Foo'Bar\\"), '', true);
}
/**
@@ -1481,7 +1475,7 @@ public function testQuotesSchemaNameInListTableIndexesSQL()
{
self::assertContains(
"'Foo''Bar\\'",
- $this->_platform->getListTableIndexesSQL("Foo'Bar\\.baz_table"),
+ $this->platform->getListTableIndexesSQL("Foo'Bar\\.baz_table"),
'',
true
);
@@ -1492,7 +1486,7 @@ public function testQuotesSchemaNameInListTableIndexesSQL()
*/
public function testGetDefaultValueDeclarationSQLForDateType() : void
{
- $currentDateSql = $this->_platform->getCurrentDateSQL();
+ $currentDateSql = $this->platform->getCurrentDateSQL();
foreach (['date', 'date_immutable'] as $type) {
$field = [
'type' => Type::getType($type),
@@ -1501,21 +1495,21 @@ public function testGetDefaultValueDeclarationSQLForDateType() : void
self::assertSame(
" DEFAULT '" . $currentDateSql . "'",
- $this->_platform->getDefaultValueDeclarationSQL($field)
+ $this->platform->getDefaultValueDeclarationSQL($field)
);
}
}
public function testSupportsColumnCollation() : void
{
- self::assertTrue($this->_platform->supportsColumnCollation());
+ self::assertTrue($this->platform->supportsColumnCollation());
}
public function testColumnCollationDeclarationSQL() : void
{
self::assertSame(
'COLLATE Latin1_General_CS_AS_KS_WS',
- $this->_platform->getColumnCollationDeclarationSQL('Latin1_General_CS_AS_KS_WS')
+ $this->platform->getColumnCollationDeclarationSQL('Latin1_General_CS_AS_KS_WS')
);
}
@@ -1527,7 +1521,7 @@ public function testGetCreateTableSQLWithColumnCollation() : void
self::assertSame(
['CREATE TABLE foo (no_collation NVARCHAR(255) NOT NULL, column_collation NVARCHAR(255) COLLATE Latin1_General_CS_AS_KS_WS NOT NULL)'],
- $this->_platform->getCreateTableSQL($table),
+ $this->platform->getCreateTableSQL($table),
'Column "no_collation" will use the default collation from the table/database and "column_collation" overwrites the collation on this column'
);
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php
index 5373b3f640d..ce2b7df42a8 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php
@@ -13,10 +13,8 @@
class DB2PlatformTest extends AbstractPlatformTestCase
{
- /**
- * @var \Doctrine\DBAL\Platforms\DB2Platform
- */
- protected $_platform;
+ /** @var DB2Platform */
+ protected $platform;
public function createPlatform()
{
@@ -25,19 +23,19 @@ public function createPlatform()
public function getGenerateAlterTableSql()
{
- return array(
- "ALTER TABLE mytable ALTER COLUMN baz SET DATA TYPE VARCHAR(255)",
- "ALTER TABLE mytable ALTER COLUMN baz SET NOT NULL",
+ return [
+ 'ALTER TABLE mytable ALTER COLUMN baz SET DATA TYPE VARCHAR(255)',
+ 'ALTER TABLE mytable ALTER COLUMN baz SET NOT NULL',
"ALTER TABLE mytable ALTER COLUMN baz SET DEFAULT 'def'",
- "ALTER TABLE mytable ALTER COLUMN bloo SET DATA TYPE SMALLINT",
- "ALTER TABLE mytable ALTER COLUMN bloo SET NOT NULL",
+ 'ALTER TABLE mytable ALTER COLUMN bloo SET DATA TYPE SMALLINT',
+ 'ALTER TABLE mytable ALTER COLUMN bloo SET NOT NULL',
"ALTER TABLE mytable ALTER COLUMN bloo SET DEFAULT '0'",
- "ALTER TABLE mytable " .
- "ADD COLUMN quota INTEGER DEFAULT NULL " .
- "DROP COLUMN foo",
+ 'ALTER TABLE mytable ' .
+ 'ADD COLUMN quota INTEGER DEFAULT NULL ' .
+ 'DROP COLUMN foo',
"CALL SYSPROC.ADMIN_CMD ('REORG TABLE mytable')",
'RENAME TABLE mytable TO userlist',
- );
+ ];
}
public function getGenerateForeignKeySql()
@@ -57,10 +55,10 @@ public function getGenerateTableSql()
public function getGenerateTableWithMultiColumnUniqueIndexSql()
{
- return array(
+ return [
'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)',
- 'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)'
- );
+ 'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)',
+ ];
}
public function getGenerateUniqueIndexSql()
@@ -70,35 +68,33 @@ public function getGenerateUniqueIndexSql()
protected function getQuotedColumnInForeignKeySQL()
{
- return array(
+ return [
'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, "bar" VARCHAR(255) NOT NULL)',
'ALTER TABLE "quoted" ADD CONSTRAINT FK_WITH_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES "foreign" ("create", bar, "foo-bar")',
'ALTER TABLE "quoted" ADD CONSTRAINT FK_WITH_NON_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES foo ("create", bar, "foo-bar")',
'ALTER TABLE "quoted" ADD CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY ("create", foo, "bar") REFERENCES "foo-bar" ("create", bar, "foo-bar")',
- );
+ ];
}
protected function getQuotedColumnInIndexSQL()
{
- return array(
+ return [
'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)',
- 'CREATE INDEX IDX_22660D028FD6E0FB ON "quoted" ("create")'
- );
+ 'CREATE INDEX IDX_22660D028FD6E0FB ON "quoted" ("create")',
+ ];
}
protected function getQuotedNameInIndexSQL()
{
- return array(
+ return [
'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)',
'CREATE INDEX "key" ON test (column1)',
- );
+ ];
}
protected function getQuotedColumnInPrimaryKeySQL()
{
- return array(
- 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY("create"))'
- );
+ return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY("create"))'];
}
protected function getBitAndComparisonExpressionSql($value1, $value2)
@@ -106,60 +102,60 @@ protected function getBitAndComparisonExpressionSql($value1, $value2)
return 'BITAND(' . $value1 . ', ' . $value2 . ')';
}
- protected function getBitOrComparisonExpressionSql($value1, $value2)
+ protected function getBitOrComparisonExpressionSql($value1, $value2)
{
return 'BITOR(' . $value1 . ', ' . $value2 . ')';
}
public function getCreateTableColumnCommentsSQL()
{
- return array(
- "CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))",
+ return [
+ 'CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))',
"COMMENT ON COLUMN test.id IS 'This is a comment'",
- );
+ ];
}
public function getAlterTableColumnCommentsSQL()
{
- return array(
- "ALTER TABLE mytable " .
- "ADD COLUMN quota INTEGER NOT NULL WITH DEFAULT",
+ return [
+ 'ALTER TABLE mytable ' .
+ 'ADD COLUMN quota INTEGER NOT NULL WITH DEFAULT',
"CALL SYSPROC.ADMIN_CMD ('REORG TABLE mytable')",
"COMMENT ON COLUMN mytable.quota IS 'A comment'",
"COMMENT ON COLUMN mytable.foo IS ''",
"COMMENT ON COLUMN mytable.baz IS 'B comment'",
- );
+ ];
}
public function getCreateTableColumnTypeCommentsSQL()
{
- return array(
+ return [
'CREATE TABLE test (id INTEGER NOT NULL, "data" CLOB(1M) NOT NULL, PRIMARY KEY(id))',
'COMMENT ON COLUMN test."data" IS \'(DC2Type:array)\'',
- );
+ ];
}
public function testHasCorrectPlatformName()
{
- self::assertEquals('db2', $this->_platform->getName());
+ self::assertEquals('db2', $this->platform->getName());
}
public function testGeneratesCreateTableSQLWithCommonIndexes()
{
$table = new Table('test');
$table->addColumn('id', 'integer');
- $table->addColumn('name', 'string', array('length' => 50));
- $table->setPrimaryKey(array('id'));
- $table->addIndex(array('name'));
- $table->addIndex(array('id', 'name'), 'composite_idx');
+ $table->addColumn('name', 'string', ['length' => 50]);
+ $table->setPrimaryKey(['id']);
+ $table->addIndex(['name']);
+ $table->addIndex(['id', 'name'], 'composite_idx');
self::assertEquals(
- array(
+ [
'CREATE TABLE test (id INTEGER NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY(id))',
'CREATE INDEX IDX_D87F7E0C5E237E06 ON test (name)',
- 'CREATE INDEX composite_idx ON test (id, name)'
- ),
- $this->_platform->getCreateTableSQL($table)
+ 'CREATE INDEX composite_idx ON test (id, name)',
+ ],
+ $this->platform->getCreateTableSQL($table)
);
}
@@ -169,23 +165,23 @@ public function testGeneratesCreateTableSQLWithForeignKeyConstraints()
$table->addColumn('id', 'integer');
$table->addColumn('fk_1', 'integer');
$table->addColumn('fk_2', 'integer');
- $table->setPrimaryKey(array('id'));
- $table->addForeignKeyConstraint('foreign_table', array('fk_1', 'fk_2'), array('pk_1', 'pk_2'));
+ $table->setPrimaryKey(['id']);
+ $table->addForeignKeyConstraint('foreign_table', ['fk_1', 'fk_2'], ['pk_1', 'pk_2']);
$table->addForeignKeyConstraint(
'foreign_table2',
- array('fk_1', 'fk_2'),
- array('pk_1', 'pk_2'),
- array(),
+ ['fk_1', 'fk_2'],
+ ['pk_1', 'pk_2'],
+ [],
'named_fk'
);
self::assertEquals(
- array(
+ [
'CREATE TABLE test (id INTEGER NOT NULL, fk_1 INTEGER NOT NULL, fk_2 INTEGER NOT NULL)',
'ALTER TABLE test ADD CONSTRAINT FK_D87F7E0C177612A38E7F4319 FOREIGN KEY (fk_1, fk_2) REFERENCES foreign_table (pk_1, pk_2)',
'ALTER TABLE test ADD CONSTRAINT named_fk FOREIGN KEY (fk_1, fk_2) REFERENCES foreign_table2 (pk_1, pk_2)',
- ),
- $this->_platform->getCreateTableSQL($table, AbstractPlatform::CREATE_FOREIGNKEYS)
+ ],
+ $this->platform->getCreateTableSQL($table, AbstractPlatform::CREATE_FOREIGNKEYS)
);
}
@@ -193,128 +189,120 @@ public function testGeneratesCreateTableSQLWithCheckConstraints()
{
$table = new Table('test');
$table->addColumn('id', 'integer');
- $table->addColumn('check_max', 'integer', array('platformOptions' => array('max' => 10)));
- $table->addColumn('check_min', 'integer', array('platformOptions' => array('min' => 10)));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('check_max', 'integer', ['platformOptions' => ['max' => 10]]);
+ $table->addColumn('check_min', 'integer', ['platformOptions' => ['min' => 10]]);
+ $table->setPrimaryKey(['id']);
self::assertEquals(
- array(
- 'CREATE TABLE test (id INTEGER NOT NULL, check_max INTEGER NOT NULL, check_min INTEGER NOT NULL, PRIMARY KEY(id), CHECK (check_max <= 10), CHECK (check_min >= 10))'
- ),
- $this->_platform->getCreateTableSQL($table)
+ ['CREATE TABLE test (id INTEGER NOT NULL, check_max INTEGER NOT NULL, check_min INTEGER NOT NULL, PRIMARY KEY(id), CHECK (check_max <= 10), CHECK (check_min >= 10))'],
+ $this->platform->getCreateTableSQL($table)
);
}
public function testGeneratesColumnTypesDeclarationSQL()
{
- $fullColumnDef = array(
+ $fullColumnDef = [
'length' => 10,
'fixed' => true,
'unsigned' => true,
- 'autoincrement' => true
- );
-
- self::assertEquals('VARCHAR(255)', $this->_platform->getVarcharTypeDeclarationSQL(array()));
- self::assertEquals('VARCHAR(10)', $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 10)));
- self::assertEquals('CHAR(254)', $this->_platform->getVarcharTypeDeclarationSQL(['fixed' => true]));
- self::assertEquals('CHAR(10)', $this->_platform->getVarcharTypeDeclarationSQL($fullColumnDef));
-
- self::assertEquals('SMALLINT', $this->_platform->getSmallIntTypeDeclarationSQL(array()));
- self::assertEquals('SMALLINT', $this->_platform->getSmallIntTypeDeclarationSQL(array(
- 'unsigned' => true
- )));
- self::assertEquals('SMALLINT GENERATED BY DEFAULT AS IDENTITY', $this->_platform->getSmallIntTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('INTEGER', $this->_platform->getIntegerTypeDeclarationSQL(array()));
- self::assertEquals('INTEGER', $this->_platform->getIntegerTypeDeclarationSQL(array(
- 'unsigned' => true
- )));
- self::assertEquals('INTEGER GENERATED BY DEFAULT AS IDENTITY', $this->_platform->getIntegerTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('BIGINT', $this->_platform->getBigIntTypeDeclarationSQL(array()));
- self::assertEquals('BIGINT', $this->_platform->getBigIntTypeDeclarationSQL(array(
- 'unsigned' => true
- )));
- self::assertEquals('BIGINT GENERATED BY DEFAULT AS IDENTITY', $this->_platform->getBigIntTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('BLOB(1M)', $this->_platform->getBlobTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('SMALLINT', $this->_platform->getBooleanTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('CLOB(1M)', $this->_platform->getClobTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('DATE', $this->_platform->getDateTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('TIMESTAMP(0) WITH DEFAULT', $this->_platform->getDateTimeTypeDeclarationSQL(array('version' => true)));
- self::assertEquals('TIMESTAMP(0)', $this->_platform->getDateTimeTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('TIME', $this->_platform->getTimeTypeDeclarationSQL($fullColumnDef));
+ 'autoincrement' => true,
+ ];
+
+ self::assertEquals('VARCHAR(255)', $this->platform->getVarcharTypeDeclarationSQL([]));
+ self::assertEquals('VARCHAR(10)', $this->platform->getVarcharTypeDeclarationSQL(['length' => 10]));
+ self::assertEquals('CHAR(254)', $this->platform->getVarcharTypeDeclarationSQL(['fixed' => true]));
+ self::assertEquals('CHAR(10)', $this->platform->getVarcharTypeDeclarationSQL($fullColumnDef));
+
+ self::assertEquals('SMALLINT', $this->platform->getSmallIntTypeDeclarationSQL([]));
+ self::assertEquals('SMALLINT', $this->platform->getSmallIntTypeDeclarationSQL(['unsigned' => true]));
+ self::assertEquals('SMALLINT GENERATED BY DEFAULT AS IDENTITY', $this->platform->getSmallIntTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('INTEGER', $this->platform->getIntegerTypeDeclarationSQL([]));
+ self::assertEquals('INTEGER', $this->platform->getIntegerTypeDeclarationSQL(['unsigned' => true]));
+ self::assertEquals('INTEGER GENERATED BY DEFAULT AS IDENTITY', $this->platform->getIntegerTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('BIGINT', $this->platform->getBigIntTypeDeclarationSQL([]));
+ self::assertEquals('BIGINT', $this->platform->getBigIntTypeDeclarationSQL(['unsigned' => true]));
+ self::assertEquals('BIGINT GENERATED BY DEFAULT AS IDENTITY', $this->platform->getBigIntTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('BLOB(1M)', $this->platform->getBlobTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('SMALLINT', $this->platform->getBooleanTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('CLOB(1M)', $this->platform->getClobTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('DATE', $this->platform->getDateTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('TIMESTAMP(0) WITH DEFAULT', $this->platform->getDateTimeTypeDeclarationSQL(['version' => true]));
+ self::assertEquals('TIMESTAMP(0)', $this->platform->getDateTimeTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('TIME', $this->platform->getTimeTypeDeclarationSQL($fullColumnDef));
}
public function testInitializesDoctrineTypeMappings()
{
- $this->_platform->initializeDoctrineTypeMappings();
+ $this->platform->initializeDoctrineTypeMappings();
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('smallint'));
- self::assertSame('smallint', $this->_platform->getDoctrineTypeMapping('smallint'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('smallint'));
+ self::assertSame('smallint', $this->platform->getDoctrineTypeMapping('smallint'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('bigint'));
- self::assertSame('bigint', $this->_platform->getDoctrineTypeMapping('bigint'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('bigint'));
+ self::assertSame('bigint', $this->platform->getDoctrineTypeMapping('bigint'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('integer'));
- self::assertSame('integer', $this->_platform->getDoctrineTypeMapping('integer'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('integer'));
+ self::assertSame('integer', $this->platform->getDoctrineTypeMapping('integer'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('time'));
- self::assertSame('time', $this->_platform->getDoctrineTypeMapping('time'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('time'));
+ self::assertSame('time', $this->platform->getDoctrineTypeMapping('time'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('date'));
- self::assertSame('date', $this->_platform->getDoctrineTypeMapping('date'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('date'));
+ self::assertSame('date', $this->platform->getDoctrineTypeMapping('date'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('varchar'));
- self::assertSame('string', $this->_platform->getDoctrineTypeMapping('varchar'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('varchar'));
+ self::assertSame('string', $this->platform->getDoctrineTypeMapping('varchar'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('character'));
- self::assertSame('string', $this->_platform->getDoctrineTypeMapping('character'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('character'));
+ self::assertSame('string', $this->platform->getDoctrineTypeMapping('character'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('clob'));
- self::assertSame('text', $this->_platform->getDoctrineTypeMapping('clob'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('clob'));
+ self::assertSame('text', $this->platform->getDoctrineTypeMapping('clob'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('blob'));
- self::assertSame('blob', $this->_platform->getDoctrineTypeMapping('blob'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('blob'));
+ self::assertSame('blob', $this->platform->getDoctrineTypeMapping('blob'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('decimal'));
- self::assertSame('decimal', $this->_platform->getDoctrineTypeMapping('decimal'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('decimal'));
+ self::assertSame('decimal', $this->platform->getDoctrineTypeMapping('decimal'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('double'));
- self::assertSame('float', $this->_platform->getDoctrineTypeMapping('double'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('double'));
+ self::assertSame('float', $this->platform->getDoctrineTypeMapping('double'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('real'));
- self::assertSame('float', $this->_platform->getDoctrineTypeMapping('real'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('real'));
+ self::assertSame('float', $this->platform->getDoctrineTypeMapping('real'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('timestamp'));
- self::assertSame('datetime', $this->_platform->getDoctrineTypeMapping('timestamp'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('timestamp'));
+ self::assertSame('datetime', $this->platform->getDoctrineTypeMapping('timestamp'));
}
public function getIsCommentedDoctrineType()
{
$data = parent::getIsCommentedDoctrineType();
- $data[Type::BOOLEAN] = array(Type::getType(Type::BOOLEAN), true);
+ $data[Type::BOOLEAN] = [Type::getType(Type::BOOLEAN), true];
return $data;
}
public function testGeneratesDDLSnippets()
{
- self::assertEquals("CREATE DATABASE foobar", $this->_platform->getCreateDatabaseSQL('foobar'));
- self::assertEquals("DROP DATABASE foobar", $this->_platform->getDropDatabaseSQL('foobar'));
- self::assertEquals('DECLARE GLOBAL TEMPORARY TABLE', $this->_platform->getCreateTemporaryTableSnippetSQL());
- self::assertEquals('TRUNCATE foobar IMMEDIATE', $this->_platform->getTruncateTableSQL('foobar'));
- self::assertEquals('TRUNCATE foobar IMMEDIATE', $this->_platform->getTruncateTableSQL('foobar'), true);
+ self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar'));
+ self::assertEquals('DROP DATABASE foobar', $this->platform->getDropDatabaseSQL('foobar'));
+ self::assertEquals('DECLARE GLOBAL TEMPORARY TABLE', $this->platform->getCreateTemporaryTableSnippetSQL());
+ self::assertEquals('TRUNCATE foobar IMMEDIATE', $this->platform->getTruncateTableSQL('foobar'));
+ self::assertEquals('TRUNCATE foobar IMMEDIATE', $this->platform->getTruncateTableSQL('foobar'), true);
$viewSql = 'SELECT * FROM footable';
- self::assertEquals('CREATE VIEW fooview AS ' . $viewSql, $this->_platform->getCreateViewSQL('fooview', $viewSql));
- self::assertEquals('DROP VIEW fooview', $this->_platform->getDropViewSQL('fooview'));
+ self::assertEquals('CREATE VIEW fooview AS ' . $viewSql, $this->platform->getCreateViewSQL('fooview', $viewSql));
+ self::assertEquals('DROP VIEW fooview', $this->platform->getDropViewSQL('fooview'));
}
public function testGeneratesCreateUnnamedPrimaryKeySQL()
{
self::assertEquals(
'ALTER TABLE foo ADD PRIMARY KEY (a, b)',
- $this->_platform->getCreatePrimaryKeySQL(
- new Index('any_pk_name', array('a', 'b'), true, true),
+ $this->platform->getCreatePrimaryKeySQL(
+ new Index('any_pk_name', ['a', 'b'], true, true),
'foo'
)
);
@@ -322,89 +310,89 @@ public function testGeneratesCreateUnnamedPrimaryKeySQL()
public function testGeneratesSQLSnippets()
{
- self::assertEquals('CURRENT DATE', $this->_platform->getCurrentDateSQL());
- self::assertEquals('CURRENT TIME', $this->_platform->getCurrentTimeSQL());
- self::assertEquals('CURRENT TIMESTAMP', $this->_platform->getCurrentTimestampSQL());
- self::assertEquals("'1987/05/02' + 4 DAY", $this->_platform->getDateAddDaysExpression("'1987/05/02'", 4));
- self::assertEquals("'1987/05/02' + 12 HOUR", $this->_platform->getDateAddHourExpression("'1987/05/02'", 12));
- self::assertEquals("'1987/05/02' + 2 MINUTE", $this->_platform->getDateAddMinutesExpression("'1987/05/02'", 2));
- self::assertEquals("'1987/05/02' + 102 MONTH", $this->_platform->getDateAddMonthExpression("'1987/05/02'", 102));
- self::assertEquals("'1987/05/02' + 15 MONTH", $this->_platform->getDateAddQuartersExpression("'1987/05/02'", 5));
- self::assertEquals("'1987/05/02' + 1 SECOND", $this->_platform->getDateAddSecondsExpression("'1987/05/02'", 1));
- self::assertEquals("'1987/05/02' + 21 DAY", $this->_platform->getDateAddWeeksExpression("'1987/05/02'", 3));
- self::assertEquals("'1987/05/02' + 10 YEAR", $this->_platform->getDateAddYearsExpression("'1987/05/02'", 10));
- self::assertEquals("DAYS('1987/05/02') - DAYS('1987/04/01')", $this->_platform->getDateDiffExpression("'1987/05/02'", "'1987/04/01'"));
- self::assertEquals("'1987/05/02' - 4 DAY", $this->_platform->getDateSubDaysExpression("'1987/05/02'", 4));
- self::assertEquals("'1987/05/02' - 12 HOUR", $this->_platform->getDateSubHourExpression("'1987/05/02'", 12));
- self::assertEquals("'1987/05/02' - 2 MINUTE", $this->_platform->getDateSubMinutesExpression("'1987/05/02'", 2));
- self::assertEquals("'1987/05/02' - 102 MONTH", $this->_platform->getDateSubMonthExpression("'1987/05/02'", 102));
- self::assertEquals("'1987/05/02' - 15 MONTH", $this->_platform->getDateSubQuartersExpression("'1987/05/02'", 5));
- self::assertEquals("'1987/05/02' - 1 SECOND", $this->_platform->getDateSubSecondsExpression("'1987/05/02'", 1));
- self::assertEquals("'1987/05/02' - 21 DAY", $this->_platform->getDateSubWeeksExpression("'1987/05/02'", 3));
- self::assertEquals("'1987/05/02' - 10 YEAR", $this->_platform->getDateSubYearsExpression("'1987/05/02'", 10));
- self::assertEquals(' WITH RR USE AND KEEP UPDATE LOCKS', $this->_platform->getForUpdateSQL());
- self::assertEquals('LOCATE(substring_column, string_column)', $this->_platform->getLocateExpression('string_column', 'substring_column'));
- self::assertEquals('LOCATE(substring_column, string_column)', $this->_platform->getLocateExpression('string_column', 'substring_column'));
- self::assertEquals('LOCATE(substring_column, string_column, 1)', $this->_platform->getLocateExpression('string_column', 'substring_column', 1));
- self::assertEquals('SUBSTR(column, 5)', $this->_platform->getSubstringExpression('column', 5));
- self::assertEquals('SUBSTR(column, 5, 2)', $this->_platform->getSubstringExpression('column', 5, 2));
+ self::assertEquals('CURRENT DATE', $this->platform->getCurrentDateSQL());
+ self::assertEquals('CURRENT TIME', $this->platform->getCurrentTimeSQL());
+ self::assertEquals('CURRENT TIMESTAMP', $this->platform->getCurrentTimestampSQL());
+ self::assertEquals("'1987/05/02' + 4 DAY", $this->platform->getDateAddDaysExpression("'1987/05/02'", 4));
+ self::assertEquals("'1987/05/02' + 12 HOUR", $this->platform->getDateAddHourExpression("'1987/05/02'", 12));
+ self::assertEquals("'1987/05/02' + 2 MINUTE", $this->platform->getDateAddMinutesExpression("'1987/05/02'", 2));
+ self::assertEquals("'1987/05/02' + 102 MONTH", $this->platform->getDateAddMonthExpression("'1987/05/02'", 102));
+ self::assertEquals("'1987/05/02' + 15 MONTH", $this->platform->getDateAddQuartersExpression("'1987/05/02'", 5));
+ self::assertEquals("'1987/05/02' + 1 SECOND", $this->platform->getDateAddSecondsExpression("'1987/05/02'", 1));
+ self::assertEquals("'1987/05/02' + 21 DAY", $this->platform->getDateAddWeeksExpression("'1987/05/02'", 3));
+ self::assertEquals("'1987/05/02' + 10 YEAR", $this->platform->getDateAddYearsExpression("'1987/05/02'", 10));
+ self::assertEquals("DAYS('1987/05/02') - DAYS('1987/04/01')", $this->platform->getDateDiffExpression("'1987/05/02'", "'1987/04/01'"));
+ self::assertEquals("'1987/05/02' - 4 DAY", $this->platform->getDateSubDaysExpression("'1987/05/02'", 4));
+ self::assertEquals("'1987/05/02' - 12 HOUR", $this->platform->getDateSubHourExpression("'1987/05/02'", 12));
+ self::assertEquals("'1987/05/02' - 2 MINUTE", $this->platform->getDateSubMinutesExpression("'1987/05/02'", 2));
+ self::assertEquals("'1987/05/02' - 102 MONTH", $this->platform->getDateSubMonthExpression("'1987/05/02'", 102));
+ self::assertEquals("'1987/05/02' - 15 MONTH", $this->platform->getDateSubQuartersExpression("'1987/05/02'", 5));
+ self::assertEquals("'1987/05/02' - 1 SECOND", $this->platform->getDateSubSecondsExpression("'1987/05/02'", 1));
+ self::assertEquals("'1987/05/02' - 21 DAY", $this->platform->getDateSubWeeksExpression("'1987/05/02'", 3));
+ self::assertEquals("'1987/05/02' - 10 YEAR", $this->platform->getDateSubYearsExpression("'1987/05/02'", 10));
+ self::assertEquals(' WITH RR USE AND KEEP UPDATE LOCKS', $this->platform->getForUpdateSQL());
+ self::assertEquals('LOCATE(substring_column, string_column)', $this->platform->getLocateExpression('string_column', 'substring_column'));
+ self::assertEquals('LOCATE(substring_column, string_column)', $this->platform->getLocateExpression('string_column', 'substring_column'));
+ self::assertEquals('LOCATE(substring_column, string_column, 1)', $this->platform->getLocateExpression('string_column', 'substring_column', 1));
+ self::assertEquals('SUBSTR(column, 5)', $this->platform->getSubstringExpression('column', 5));
+ self::assertEquals('SUBSTR(column, 5, 2)', $this->platform->getSubstringExpression('column', 5, 2));
}
public function testModifiesLimitQuery()
{
self::assertEquals(
'SELECT * FROM user',
- $this->_platform->modifyLimitQuery('SELECT * FROM user', null, null)
+ $this->platform->modifyLimitQuery('SELECT * FROM user', null, null)
);
self::assertEquals(
'SELECT db22.* FROM (SELECT db21.*, ROW_NUMBER() OVER() AS DC_ROWNUM FROM (SELECT * FROM user) db21) db22 WHERE db22.DC_ROWNUM <= 10',
- $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0)
+ $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0)
);
self::assertEquals(
'SELECT db22.* FROM (SELECT db21.*, ROW_NUMBER() OVER() AS DC_ROWNUM FROM (SELECT * FROM user) db21) db22 WHERE db22.DC_ROWNUM <= 10',
- $this->_platform->modifyLimitQuery('SELECT * FROM user', 10)
+ $this->platform->modifyLimitQuery('SELECT * FROM user', 10)
);
self::assertEquals(
'SELECT db22.* FROM (SELECT db21.*, ROW_NUMBER() OVER() AS DC_ROWNUM FROM (SELECT * FROM user) db21) db22 WHERE db22.DC_ROWNUM >= 6 AND db22.DC_ROWNUM <= 15',
- $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 5)
+ $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 5)
);
self::assertEquals(
'SELECT db22.* FROM (SELECT db21.*, ROW_NUMBER() OVER() AS DC_ROWNUM FROM (SELECT * FROM user) db21) db22 WHERE db22.DC_ROWNUM >= 6 AND db22.DC_ROWNUM <= 5',
- $this->_platform->modifyLimitQuery('SELECT * FROM user', 0, 5)
+ $this->platform->modifyLimitQuery('SELECT * FROM user', 0, 5)
);
}
public function testPrefersIdentityColumns()
{
- self::assertTrue($this->_platform->prefersIdentityColumns());
+ self::assertTrue($this->platform->prefersIdentityColumns());
}
public function testSupportsIdentityColumns()
{
- self::assertTrue($this->_platform->supportsIdentityColumns());
+ self::assertTrue($this->platform->supportsIdentityColumns());
}
public function testDoesNotSupportSavePoints()
{
- self::assertFalse($this->_platform->supportsSavepoints());
+ self::assertFalse($this->platform->supportsSavepoints());
}
public function testDoesNotSupportReleasePoints()
{
- self::assertFalse($this->_platform->supportsReleaseSavepoints());
+ self::assertFalse($this->platform->supportsReleaseSavepoints());
}
public function testDoesNotSupportCreateDropDatabase()
{
- self::assertFalse($this->_platform->supportsCreateDropDatabase());
+ self::assertFalse($this->platform->supportsCreateDropDatabase());
}
public function testReturnsSQLResultCasing()
{
- self::assertSame('COL', $this->_platform->getSQLResultCasing('cOl'));
+ self::assertSame('COL', $this->platform->getSQLResultCasing('cOl'));
}
protected function getBinaryDefaultLength()
@@ -419,12 +407,12 @@ protected function getBinaryMaxLength()
public function testReturnsBinaryTypeDeclarationSQL()
{
- self::assertSame('VARCHAR(1) FOR BIT DATA', $this->_platform->getBinaryTypeDeclarationSQL([]));
- self::assertSame('VARCHAR(255) FOR BIT DATA', $this->_platform->getBinaryTypeDeclarationSQL(['length' => 0]));
- self::assertSame('VARCHAR(32704) FOR BIT DATA', $this->_platform->getBinaryTypeDeclarationSQL(['length' => 32704]));
+ self::assertSame('VARCHAR(1) FOR BIT DATA', $this->platform->getBinaryTypeDeclarationSQL([]));
+ self::assertSame('VARCHAR(255) FOR BIT DATA', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0]));
+ self::assertSame('VARCHAR(32704) FOR BIT DATA', $this->platform->getBinaryTypeDeclarationSQL(['length' => 32704]));
- self::assertSame('CHAR(1) FOR BIT DATA', $this->_platform->getBinaryTypeDeclarationSQL(['fixed' => true]));
- self::assertSame('CHAR(254) FOR BIT DATA', $this->_platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 0]));
+ self::assertSame('CHAR(1) FOR BIT DATA', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true]));
+ self::assertSame('CHAR(254) FOR BIT DATA', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 0]));
}
/**
@@ -433,8 +421,8 @@ public function testReturnsBinaryTypeDeclarationSQL()
*/
public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL()
{
- self::assertSame('BLOB(1M)', $this->_platform->getBinaryTypeDeclarationSQL(['length' => 32705]));
- self::assertSame('BLOB(1M)', $this->_platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 32705]));
+ self::assertSame('BLOB(1M)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 32705]));
+ self::assertSame('BLOB(1M)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 32705]));
}
/**
@@ -442,9 +430,7 @@ public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL()
*/
protected function getAlterTableRenameIndexSQL()
{
- return array(
- 'RENAME INDEX idx_foo TO idx_bar',
- );
+ return ['RENAME INDEX idx_foo TO idx_bar'];
}
/**
@@ -452,10 +438,10 @@ protected function getAlterTableRenameIndexSQL()
*/
protected function getQuotedAlterTableRenameIndexSQL()
{
- return array(
+ return [
'RENAME INDEX "create" TO "select"',
'RENAME INDEX "foo" TO "bar"',
- );
+ ];
}
/**
@@ -463,8 +449,7 @@ protected function getQuotedAlterTableRenameIndexSQL()
*/
protected function getQuotedAlterTableRenameColumnSQL()
{
- return array(
- 'ALTER TABLE mytable ' .
+ return ['ALTER TABLE mytable ' .
'RENAME COLUMN unquoted1 TO unquoted ' .
'RENAME COLUMN unquoted2 TO "where" ' .
'RENAME COLUMN unquoted3 TO "foo" ' .
@@ -473,8 +458,8 @@ protected function getQuotedAlterTableRenameColumnSQL()
'RENAME COLUMN "select" TO "bar" ' .
'RENAME COLUMN quoted1 TO quoted ' .
'RENAME COLUMN quoted2 TO "and" ' .
- 'RENAME COLUMN quoted3 TO "baz"'
- );
+ 'RENAME COLUMN quoted3 TO "baz"',
+ ];
}
/**
@@ -490,9 +475,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL()
*/
protected function getAlterTableRenameIndexInSchemaSQL()
{
- return array(
- 'RENAME INDEX myschema.idx_foo TO idx_bar',
- );
+ return ['RENAME INDEX myschema.idx_foo TO idx_bar'];
}
/**
@@ -500,10 +483,10 @@ protected function getAlterTableRenameIndexInSchemaSQL()
*/
protected function getQuotedAlterTableRenameIndexInSchemaSQL()
{
- return array(
+ return [
'RENAME INDEX "schema"."create" TO "select"',
'RENAME INDEX "schema"."foo" TO "bar"',
- );
+ ];
}
/**
@@ -511,7 +494,7 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL()
*/
public function testReturnsGuidTypeDeclarationSQL()
{
- self::assertSame('CHAR(36)', $this->_platform->getGuidTypeDeclarationSQL(array()));
+ self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([]));
}
/**
@@ -519,9 +502,7 @@ public function testReturnsGuidTypeDeclarationSQL()
*/
public function getAlterTableRenameColumnSQL()
{
- return array(
- 'ALTER TABLE foo RENAME COLUMN bar TO baz',
- );
+ return ['ALTER TABLE foo RENAME COLUMN bar TO baz'];
}
/**
@@ -529,7 +510,7 @@ public function getAlterTableRenameColumnSQL()
*/
protected function getQuotesTableIdentifiersInAlterTableSQL()
{
- return array(
+ return [
'ALTER TABLE "foo" DROP FOREIGN KEY fk1',
'ALTER TABLE "foo" DROP FOREIGN KEY fk2',
'ALTER TABLE "foo" ' .
@@ -541,7 +522,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL()
'RENAME TABLE "foo" TO "table"',
'ALTER TABLE "table" ADD CONSTRAINT fk_add FOREIGN KEY (fk3) REFERENCES fk_table (id)',
'ALTER TABLE "table" ADD CONSTRAINT fk2 FOREIGN KEY (fk2) REFERENCES fk_table2 (id)',
- );
+ ];
}
/**
@@ -549,97 +530,96 @@ protected function getQuotesTableIdentifiersInAlterTableSQL()
*/
protected function getCommentOnColumnSQL()
{
- return array(
+ return [
'COMMENT ON COLUMN foo.bar IS \'comment\'',
'COMMENT ON COLUMN "Foo"."BAR" IS \'comment\'',
'COMMENT ON COLUMN "select"."from" IS \'comment\'',
- );
+ ];
}
/**
* @group DBAL-944
- *
* @dataProvider getGeneratesAlterColumnSQL
*/
public function testGeneratesAlterColumnSQL($changedProperty, Column $column, $expectedSQLClause = null)
{
- $tableDiff = new TableDiff('foo');
- $tableDiff->fromTable = new Table('foo');
- $tableDiff->changedColumns['bar'] = new ColumnDiff('bar', $column, array($changedProperty));
+ $tableDiff = new TableDiff('foo');
+ $tableDiff->fromTable = new Table('foo');
+ $tableDiff->changedColumns['bar'] = new ColumnDiff('bar', $column, [$changedProperty]);
- $expectedSQL = array();
+ $expectedSQL = [];
- if (null !== $expectedSQLClause) {
+ if ($expectedSQLClause !== null) {
$expectedSQL[] = 'ALTER TABLE foo ALTER COLUMN bar ' . $expectedSQLClause;
}
$expectedSQL[] = "CALL SYSPROC.ADMIN_CMD ('REORG TABLE foo')";
- self::assertSame($expectedSQL, $this->_platform->getAlterTableSQL($tableDiff));
+ self::assertSame($expectedSQL, $this->platform->getAlterTableSQL($tableDiff));
}
/**
- * @return array
+ * @return mixed[]
*/
public function getGeneratesAlterColumnSQL()
{
- return array(
- array(
+ return [
+ [
'columnDefinition',
- new Column('bar', Type::getType('decimal'), array('columnDefinition' => 'MONEY NOT NULL')),
- 'MONEY NOT NULL'
- ),
- array(
+ new Column('bar', Type::getType('decimal'), ['columnDefinition' => 'MONEY NOT NULL']),
+ 'MONEY NOT NULL',
+ ],
+ [
'type',
new Column('bar', Type::getType('integer')),
- 'SET DATA TYPE INTEGER'
- ),
- array(
+ 'SET DATA TYPE INTEGER',
+ ],
+ [
'length',
- new Column('bar', Type::getType('string'), array('length' => 100)),
- 'SET DATA TYPE VARCHAR(100)'
- ),
- array(
+ new Column('bar', Type::getType('string'), ['length' => 100]),
+ 'SET DATA TYPE VARCHAR(100)',
+ ],
+ [
'precision',
- new Column('bar', Type::getType('decimal'), array('precision' => 10, 'scale' => 2)),
- 'SET DATA TYPE NUMERIC(10, 2)'
- ),
- array(
+ new Column('bar', Type::getType('decimal'), ['precision' => 10, 'scale' => 2]),
+ 'SET DATA TYPE NUMERIC(10, 2)',
+ ],
+ [
'scale',
- new Column('bar', Type::getType('decimal'), array('precision' => 5, 'scale' => 4)),
- 'SET DATA TYPE NUMERIC(5, 4)'
- ),
- array(
+ new Column('bar', Type::getType('decimal'), ['precision' => 5, 'scale' => 4]),
+ 'SET DATA TYPE NUMERIC(5, 4)',
+ ],
+ [
'fixed',
- new Column('bar', Type::getType('string'), array('length' => 20, 'fixed' => true)),
- 'SET DATA TYPE CHAR(20)'
- ),
- array(
+ new Column('bar', Type::getType('string'), ['length' => 20, 'fixed' => true]),
+ 'SET DATA TYPE CHAR(20)',
+ ],
+ [
'notnull',
- new Column('bar', Type::getType('string'), array('notnull' => true)),
- 'SET NOT NULL'
- ),
- array(
+ new Column('bar', Type::getType('string'), ['notnull' => true]),
+ 'SET NOT NULL',
+ ],
+ [
'notnull',
- new Column('bar', Type::getType('string'), array('notnull' => false)),
- 'DROP NOT NULL'
- ),
- array(
+ new Column('bar', Type::getType('string'), ['notnull' => false]),
+ 'DROP NOT NULL',
+ ],
+ [
'default',
- new Column('bar', Type::getType('string'), array('default' => 'foo')),
- "SET DEFAULT 'foo'"
- ),
- array(
+ new Column('bar', Type::getType('string'), ['default' => 'foo']),
+ "SET DEFAULT 'foo'",
+ ],
+ [
'default',
- new Column('bar', Type::getType('integer'), array('autoincrement' => true, 'default' => 666)),
- null
- ),
- array(
+ new Column('bar', Type::getType('integer'), ['autoincrement' => true, 'default' => 666]),
+ null,
+ ],
+ [
'default',
new Column('bar', Type::getType('string')),
- "DROP DEFAULT"
- ),
- );
+ 'DROP DEFAULT',
+ ],
+ ];
}
/**
@@ -687,10 +667,10 @@ protected function supportsCommentOnStatement()
*/
protected function getAlterStringToFixedStringSQL()
{
- return array(
+ return [
'ALTER TABLE mytable ALTER COLUMN name SET DATA TYPE CHAR(2)',
'CALL SYSPROC.ADMIN_CMD (\'REORG TABLE mytable\')',
- );
+ ];
}
/**
@@ -698,9 +678,7 @@ protected function getAlterStringToFixedStringSQL()
*/
protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
{
- return array(
- 'RENAME INDEX idx_foo TO idx_foo_renamed',
- );
+ return ['RENAME INDEX idx_foo TO idx_foo_renamed'];
}
/**
@@ -708,7 +686,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
*/
public function testQuotesTableNameInListTableColumnsSQL()
{
- self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableColumnsSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\'", $this->platform->getListTableColumnsSQL("Foo'Bar\\"), '', true);
}
/**
@@ -716,7 +694,7 @@ public function testQuotesTableNameInListTableColumnsSQL()
*/
public function testQuotesTableNameInListTableIndexesSQL()
{
- self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableIndexesSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\'", $this->platform->getListTableIndexesSQL("Foo'Bar\\"), '', true);
}
/**
@@ -724,6 +702,6 @@ public function testQuotesTableNameInListTableIndexesSQL()
*/
public function testQuotesTableNameInListTableForeignKeysSQL()
{
- self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\'", $this->platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php
index 138a55ef714..7171ad714d6 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php
@@ -17,22 +17,23 @@ public function createPlatform() : MariaDb1027Platform
public function testHasNativeJsonType() : void
{
- self::assertFalse($this->_platform->hasNativeJsonType());
+ self::assertFalse($this->platform->hasNativeJsonType());
}
/**
* From MariaDB 10.2.7, JSON type is an alias to LONGTEXT
+ *
* @link https://mariadb.com/kb/en/library/json-data-type/
*/
public function testReturnsJsonTypeDeclarationSQL() : void
{
- self::assertSame('LONGTEXT', $this->_platform->getJsonTypeDeclarationSQL([]));
+ self::assertSame('LONGTEXT', $this->platform->getJsonTypeDeclarationSQL([]));
}
public function testInitializesJsonTypeMapping() : void
{
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('json'));
- self::assertSame(Type::JSON, $this->_platform->getDoctrineTypeMapping('json'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json'));
+ self::assertSame(Type::JSON, $this->platform->getDoctrineTypeMapping('json'));
}
/**
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php
index 2ea04fe75a8..52d7ca0708b 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php
@@ -17,18 +17,18 @@ public function createPlatform()
public function testHasNativeJsonType()
{
- self::assertTrue($this->_platform->hasNativeJsonType());
+ self::assertTrue($this->platform->hasNativeJsonType());
}
public function testReturnsJsonTypeDeclarationSQL()
{
- self::assertSame('JSON', $this->_platform->getJsonTypeDeclarationSQL(array()));
+ self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL([]));
}
public function testInitializesJsonTypeMapping()
{
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('json'));
- self::assertSame(Type::JSON, $this->_platform->getDoctrineTypeMapping('json'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json'));
+ self::assertSame(Type::JSON, $this->platform->getDoctrineTypeMapping('json'));
}
/**
@@ -36,9 +36,7 @@ public function testInitializesJsonTypeMapping()
*/
protected function getAlterTableRenameIndexSQL()
{
- return array(
- 'ALTER TABLE mytable RENAME INDEX idx_foo TO idx_bar',
- );
+ return ['ALTER TABLE mytable RENAME INDEX idx_foo TO idx_bar'];
}
/**
@@ -46,10 +44,10 @@ protected function getAlterTableRenameIndexSQL()
*/
protected function getQuotedAlterTableRenameIndexSQL()
{
- return array(
+ return [
'ALTER TABLE `table` RENAME INDEX `create` TO `select`',
'ALTER TABLE `table` RENAME INDEX `foo` TO `bar`',
- );
+ ];
}
/**
@@ -57,9 +55,7 @@ protected function getQuotedAlterTableRenameIndexSQL()
*/
protected function getAlterTableRenameIndexInSchemaSQL()
{
- return array(
- 'ALTER TABLE myschema.mytable RENAME INDEX idx_foo TO idx_bar',
- );
+ return ['ALTER TABLE myschema.mytable RENAME INDEX idx_foo TO idx_bar'];
}
/**
@@ -67,10 +63,10 @@ protected function getAlterTableRenameIndexInSchemaSQL()
*/
protected function getQuotedAlterTableRenameIndexInSchemaSQL()
{
- return array(
+ return [
'ALTER TABLE `schema`.`table` RENAME INDEX `create` TO `select`',
'ALTER TABLE `schema`.`table` RENAME INDEX `foo` TO `bar`',
- );
+ ];
}
/**
@@ -78,8 +74,6 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL()
*/
protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
{
- return array(
- 'ALTER TABLE mytable RENAME INDEX idx_foo TO idx_foo_renamed',
- );
+ return ['ALTER TABLE mytable RENAME INDEX idx_foo TO idx_foo_renamed'];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
index 2dc3a7ce28e..ec1f3181581 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
@@ -9,14 +9,14 @@ class MySqlPlatformTest extends AbstractMySQLPlatformTestCase
{
public function createPlatform()
{
- return new MysqlPlatform;
+ return new MySqlPlatform();
}
public function testHasCorrectDefaultTransactionIsolationLevel()
{
self::assertEquals(
TransactionIsolationLevel::REPEATABLE_READ,
- $this->_platform->getDefaultTransactionIsolationLevel()
+ $this->platform->getDefaultTransactionIsolationLevel()
);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
index 5e270b4a1e7..5af2b0cf571 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
@@ -5,13 +5,17 @@
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Schema\Column;
+use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
+use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
+use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\Type;
use function array_walk;
use function preg_replace;
+use function sprintf;
use function strtoupper;
use function uniqid;
@@ -67,7 +71,7 @@ public function testInvalidIdentifiers($identifier)
public function createPlatform()
{
- return new OraclePlatform;
+ return new OraclePlatform();
}
public function getGenerateTableSql()
@@ -77,20 +81,20 @@ public function getGenerateTableSql()
public function getGenerateTableWithMultiColumnUniqueIndexSql()
{
- return array(
+ return [
'CREATE TABLE test (foo VARCHAR2(255) DEFAULT NULL NULL, bar VARCHAR2(255) DEFAULT NULL NULL)',
'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)',
- );
+ ];
}
public function getGenerateAlterTableSql()
{
- return array(
+ return [
'ALTER TABLE mytable ADD (quota NUMBER(10) DEFAULT NULL NULL)',
"ALTER TABLE mytable MODIFY (baz VARCHAR2(255) DEFAULT 'def' NOT NULL, bloo NUMBER(1) DEFAULT '0' NOT NULL)",
- "ALTER TABLE mytable DROP (foo)",
- "ALTER TABLE mytable RENAME TO userlist",
- );
+ 'ALTER TABLE mytable DROP (foo)',
+ 'ALTER TABLE mytable RENAME TO userlist',
+ ];
}
/**
@@ -98,32 +102,32 @@ public function getGenerateAlterTableSql()
*/
public function testRLike()
{
- self::assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct');
+ self::assertEquals('RLIKE', $this->platform->getRegexpExpression(), 'Regular expression operator is not correct');
}
public function testGeneratesSqlSnippets()
{
- self::assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
- self::assertEquals('column1 || column2 || column3', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
+ self::assertEquals('"', $this->platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
+ self::assertEquals('column1 || column2 || column3', $this->platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
}
public function testGeneratesTransactionsCommands()
{
self::assertEquals(
'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_UNCOMMITTED)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_UNCOMMITTED)
);
self::assertEquals(
'SET TRANSACTION ISOLATION LEVEL READ COMMITTED',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_COMMITTED)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_COMMITTED)
);
self::assertEquals(
'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::REPEATABLE_READ)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::REPEATABLE_READ)
);
self::assertEquals(
'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::SERIALIZABLE)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::SERIALIZABLE)
);
}
@@ -132,68 +136,70 @@ public function testGeneratesTransactionsCommands()
*/
public function testCreateDatabaseThrowsException()
{
- self::assertEquals('CREATE DATABASE foobar', $this->_platform->getCreateDatabaseSQL('foobar'));
+ self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar'));
}
public function testDropDatabaseThrowsException()
{
- self::assertEquals('DROP USER foobar CASCADE', $this->_platform->getDropDatabaseSQL('foobar'));
+ self::assertEquals('DROP USER foobar CASCADE', $this->platform->getDropDatabaseSQL('foobar'));
}
public function testDropTable()
{
- self::assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));
+ self::assertEquals('DROP TABLE foobar', $this->platform->getDropTableSQL('foobar'));
}
public function testGeneratesTypeDeclarationForIntegers()
{
self::assertEquals(
'NUMBER(10)',
- $this->_platform->getIntegerTypeDeclarationSQL(array())
+ $this->platform->getIntegerTypeDeclarationSQL([])
);
self::assertEquals(
'NUMBER(10)',
- $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)
- ));
+ $this->platform->getIntegerTypeDeclarationSQL(['autoincrement' => true])
+ );
self::assertEquals(
'NUMBER(10)',
- $this->_platform->getIntegerTypeDeclarationSQL(
- array('autoincrement' => true, 'primary' => true)
- ));
+ $this->platform->getIntegerTypeDeclarationSQL(
+ ['autoincrement' => true, 'primary' => true]
+ )
+ );
}
public function testGeneratesTypeDeclarationsForStrings()
{
self::assertEquals(
'CHAR(10)',
- $this->_platform->getVarcharTypeDeclarationSQL(
- array('length' => 10, 'fixed' => true)
- ));
+ $this->platform->getVarcharTypeDeclarationSQL(
+ ['length' => 10, 'fixed' => true]
+ )
+ );
self::assertEquals(
'VARCHAR2(50)',
- $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
+ $this->platform->getVarcharTypeDeclarationSQL(['length' => 50]),
'Variable string declaration is not correct'
);
self::assertEquals(
'VARCHAR2(255)',
- $this->_platform->getVarcharTypeDeclarationSQL(array()),
+ $this->platform->getVarcharTypeDeclarationSQL([]),
'Long string declaration is not correct'
);
}
public function testPrefersIdentityColumns()
{
- self::assertFalse($this->_platform->prefersIdentityColumns());
+ self::assertFalse($this->platform->prefersIdentityColumns());
}
public function testSupportsIdentityColumns()
{
- self::assertFalse($this->_platform->supportsIdentityColumns());
+ self::assertFalse($this->platform->supportsIdentityColumns());
}
public function testSupportsSavePoints()
{
- self::assertTrue($this->_platform->supportsSavepoints());
+ self::assertTrue($this->platform->supportsSavepoints());
}
/**
@@ -220,30 +226,31 @@ public function getGenerateForeignKeySql()
}
/**
- * @group DBAL-1097
+ * @param mixed[] $options
*
+ * @group DBAL-1097
* @dataProvider getGeneratesAdvancedForeignKeyOptionsSQLData
*/
public function testGeneratesAdvancedForeignKeyOptionsSQL(array $options, $expectedSql)
{
- $foreignKey = new ForeignKeyConstraint(array('foo'), 'foreign_table', array('bar'), null, $options);
+ $foreignKey = new ForeignKeyConstraint(['foo'], 'foreign_table', ['bar'], null, $options);
- self::assertSame($expectedSql, $this->_platform->getAdvancedForeignKeyOptionsSQL($foreignKey));
+ self::assertSame($expectedSql, $this->platform->getAdvancedForeignKeyOptionsSQL($foreignKey));
}
/**
- * @return array
+ * @return mixed[]
*/
public function getGeneratesAdvancedForeignKeyOptionsSQLData()
{
- return array(
- array(array(), ''),
- array(array('onUpdate' => 'CASCADE'), ''),
- array(array('onDelete' => 'CASCADE'), ' ON DELETE CASCADE'),
- array(array('onDelete' => 'NO ACTION'), ''),
- array(array('onDelete' => 'RESTRICT'), ''),
- array(array('onUpdate' => 'SET NULL', 'onDelete' => 'SET NULL'), ' ON DELETE SET NULL'),
- );
+ return [
+ [[], ''],
+ [['onUpdate' => 'CASCADE'], ''],
+ [['onDelete' => 'CASCADE'], ' ON DELETE CASCADE'],
+ [['onDelete' => 'NO ACTION'], ''],
+ [['onDelete' => 'RESTRICT'], ''],
+ [['onUpdate' => 'SET NULL', 'onDelete' => 'SET NULL'], ' ON DELETE SET NULL'],
+ ];
}
/**
@@ -251,104 +258,123 @@ public function getGeneratesAdvancedForeignKeyOptionsSQLData()
*/
public function getReturnsForeignKeyReferentialActionSQL()
{
- return array(
- array('CASCADE', 'CASCADE'),
- array('SET NULL', 'SET NULL'),
- array('NO ACTION', ''),
- array('RESTRICT', ''),
- array('CaScAdE', 'CASCADE'),
- );
+ return [
+ ['CASCADE', 'CASCADE'],
+ ['SET NULL', 'SET NULL'],
+ ['NO ACTION', ''],
+ ['RESTRICT', ''],
+ ['CaScAdE', 'CASCADE'],
+ ];
}
public function testModifyLimitQuery()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
self::assertEquals('SELECT a.* FROM (SELECT * FROM user) a WHERE ROWNUM <= 10', $sql);
}
public function testModifyLimitQueryWithEmptyOffset()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10);
self::assertEquals('SELECT a.* FROM (SELECT * FROM user) a WHERE ROWNUM <= 10', $sql);
}
public function testModifyLimitQueryWithNonEmptyOffset()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 10);
self::assertEquals('SELECT * FROM (SELECT a.*, ROWNUM AS doctrine_rownum FROM (SELECT * FROM user) a WHERE ROWNUM <= 20) WHERE doctrine_rownum >= 11', $sql);
}
public function testModifyLimitQueryWithEmptyLimit()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', null, 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', null, 10);
self::assertEquals('SELECT * FROM (SELECT a.*, ROWNUM AS doctrine_rownum FROM (SELECT * FROM user) a) WHERE doctrine_rownum >= 11', $sql);
}
public function testModifyLimitQueryWithAscOrderBy()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10);
self::assertEquals('SELECT a.* FROM (SELECT * FROM user ORDER BY username ASC) a WHERE ROWNUM <= 10', $sql);
}
public function testModifyLimitQueryWithDescOrderBy()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10);
self::assertEquals('SELECT a.* FROM (SELECT * FROM user ORDER BY username DESC) a WHERE ROWNUM <= 10', $sql);
}
public function testGenerateTableWithAutoincrement()
{
$columnName = strtoupper('id' . uniqid());
- $tableName = strtoupper('table' . uniqid());
- $table = new \Doctrine\DBAL\Schema\Table($tableName);
- $column = $table->addColumn($columnName, 'integer');
+ $tableName = strtoupper('table' . uniqid());
+ $table = new Table($tableName);
+ $column = $table->addColumn($columnName, 'integer');
$column->setAutoincrement(true);
- $targets = array(
- "CREATE TABLE {$tableName} ({$columnName} NUMBER(10) NOT NULL)",
- "DECLARE constraints_Count NUMBER; BEGIN SELECT COUNT(CONSTRAINT_NAME) INTO constraints_Count FROM USER_CONSTRAINTS WHERE TABLE_NAME = '{$tableName}' AND CONSTRAINT_TYPE = 'P'; IF constraints_Count = 0 OR constraints_Count = '' THEN EXECUTE IMMEDIATE 'ALTER TABLE {$tableName} ADD CONSTRAINT {$tableName}_AI_PK PRIMARY KEY ({$columnName})'; END IF; END;",
- "CREATE SEQUENCE {$tableName}_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1",
- "CREATE TRIGGER {$tableName}_AI_PK BEFORE INSERT ON {$tableName} FOR EACH ROW DECLARE last_Sequence NUMBER; last_InsertID NUMBER; BEGIN SELECT {$tableName}_SEQ.NEXTVAL INTO :NEW.{$columnName} FROM DUAL; IF (:NEW.{$columnName} IS NULL OR :NEW.{$columnName} = 0) THEN SELECT {$tableName}_SEQ.NEXTVAL INTO :NEW.{$columnName} FROM DUAL; ELSE SELECT NVL(Last_Number, 0) INTO last_Sequence FROM User_Sequences WHERE Sequence_Name = '{$tableName}_SEQ'; SELECT :NEW.{$columnName} INTO last_InsertID FROM DUAL; WHILE (last_InsertID > last_Sequence) LOOP SELECT {$tableName}_SEQ.NEXTVAL INTO last_Sequence FROM DUAL; END LOOP; END IF; END;"
- );
- $statements = $this->_platform->getCreateTableSQL($table);
+ $targets = [
+ sprintf('CREATE TABLE %s (%s NUMBER(10) NOT NULL)', $tableName, $columnName),
+ sprintf(
+ "DECLARE constraints_Count NUMBER; BEGIN SELECT COUNT(CONSTRAINT_NAME) INTO constraints_Count FROM USER_CONSTRAINTS WHERE TABLE_NAME = '%s' AND CONSTRAINT_TYPE = 'P'; IF constraints_Count = 0 OR constraints_Count = '' THEN EXECUTE IMMEDIATE 'ALTER TABLE %s ADD CONSTRAINT %s_AI_PK PRIMARY KEY (%s)'; END IF; END;",
+ $tableName,
+ $tableName,
+ $tableName,
+ $columnName
+ ),
+ sprintf('CREATE SEQUENCE %s_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1', $tableName),
+ sprintf(
+ "CREATE TRIGGER %s_AI_PK BEFORE INSERT ON %s FOR EACH ROW DECLARE last_Sequence NUMBER; last_InsertID NUMBER; BEGIN SELECT %s_SEQ.NEXTVAL INTO :NEW.%s FROM DUAL; IF (:NEW.%s IS NULL OR :NEW.%s = 0) THEN SELECT %s_SEQ.NEXTVAL INTO :NEW.%s FROM DUAL; ELSE SELECT NVL(Last_Number, 0) INTO last_Sequence FROM User_Sequences WHERE Sequence_Name = '%s_SEQ'; SELECT :NEW.%s INTO last_InsertID FROM DUAL; WHILE (last_InsertID > last_Sequence) LOOP SELECT %s_SEQ.NEXTVAL INTO last_Sequence FROM DUAL; END LOOP; END IF; END;",
+ $tableName,
+ $tableName,
+ $tableName,
+ $columnName,
+ $columnName,
+ $columnName,
+ $tableName,
+ $columnName,
+ $tableName,
+ $columnName,
+ $tableName
+ ),
+ ];
+ $statements = $this->platform->getCreateTableSQL($table);
//strip all the whitespace from the statements
- array_walk($statements, function(&$value){
- $value = preg_replace('/\s+/', ' ',$value);
+ array_walk($statements, static function (&$value) {
+ $value = preg_replace('/\s+/', ' ', $value);
});
- foreach($targets as $key => $sql){
- self::assertArrayHasKey($key,$statements);
+ foreach ($targets as $key => $sql) {
+ self::assertArrayHasKey($key, $statements);
self::assertEquals($sql, $statements[$key]);
}
}
public function getCreateTableColumnCommentsSQL()
{
- return array(
- "CREATE TABLE test (id NUMBER(10) NOT NULL, PRIMARY KEY(id))",
+ return [
+ 'CREATE TABLE test (id NUMBER(10) NOT NULL, PRIMARY KEY(id))',
"COMMENT ON COLUMN test.id IS 'This is a comment'",
- );
+ ];
}
public function getCreateTableColumnTypeCommentsSQL()
{
- return array(
- "CREATE TABLE test (id NUMBER(10) NOT NULL, data CLOB NOT NULL, PRIMARY KEY(id))",
- "COMMENT ON COLUMN test.data IS '(DC2Type:array)'"
- );
+ return [
+ 'CREATE TABLE test (id NUMBER(10) NOT NULL, data CLOB NOT NULL, PRIMARY KEY(id))',
+ "COMMENT ON COLUMN test.data IS '(DC2Type:array)'",
+ ];
}
public function getAlterTableColumnCommentsSQL()
{
- return array(
- "ALTER TABLE mytable ADD (quota NUMBER(10) NOT NULL)",
+ return [
+ 'ALTER TABLE mytable ADD (quota NUMBER(10) NOT NULL)',
"COMMENT ON COLUMN mytable.quota IS 'A comment'",
"COMMENT ON COLUMN mytable.foo IS ''",
"COMMENT ON COLUMN mytable.baz IS 'B comment'",
- );
+ ];
}
public function getBitAndComparisonExpressionSql($value1, $value2)
{
- return 'BITAND('.$value1 . ', ' . $value2 . ')';
+ return 'BITAND(' . $value1 . ', ' . $value2 . ')';
}
public function getBitOrComparisonExpressionSql($value1, $value2)
@@ -360,33 +386,33 @@ public function getBitOrComparisonExpressionSql($value1, $value2)
protected function getQuotedColumnInPrimaryKeySQL()
{
- return array('CREATE TABLE "quoted" ("create" VARCHAR2(255) NOT NULL, PRIMARY KEY("create"))');
+ return ['CREATE TABLE "quoted" ("create" VARCHAR2(255) NOT NULL, PRIMARY KEY("create"))'];
}
protected function getQuotedColumnInIndexSQL()
{
- return array(
+ return [
'CREATE TABLE "quoted" ("create" VARCHAR2(255) NOT NULL)',
'CREATE INDEX IDX_22660D028FD6E0FB ON "quoted" ("create")',
- );
+ ];
}
protected function getQuotedNameInIndexSQL()
{
- return array(
+ return [
'CREATE TABLE test (column1 VARCHAR2(255) NOT NULL)',
'CREATE INDEX "key" ON test (column1)',
- );
+ ];
}
protected function getQuotedColumnInForeignKeySQL()
{
- return array(
+ return [
'CREATE TABLE "quoted" ("create" VARCHAR2(255) NOT NULL, foo VARCHAR2(255) NOT NULL, "bar" VARCHAR2(255) NOT NULL)',
'ALTER TABLE "quoted" ADD CONSTRAINT FK_WITH_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES foreign ("create", bar, "foo-bar")',
'ALTER TABLE "quoted" ADD CONSTRAINT FK_WITH_NON_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES foo ("create", bar, "foo-bar")',
'ALTER TABLE "quoted" ADD CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY ("create", foo, "bar") REFERENCES "foo-bar" ("create", bar, "foo-bar")',
- );
+ ];
}
/**
@@ -395,30 +421,37 @@ protected function getQuotedColumnInForeignKeySQL()
*/
public function testAlterTableNotNULL()
{
- $tableDiff = new \Doctrine\DBAL\Schema\TableDiff('mytable');
- $tableDiff->changedColumns['foo'] = new \Doctrine\DBAL\Schema\ColumnDiff(
- 'foo', new \Doctrine\DBAL\Schema\Column(
- 'foo', \Doctrine\DBAL\Types\Type::getType('string'), array('default' => 'bla', 'notnull' => true)
+ $tableDiff = new TableDiff('mytable');
+ $tableDiff->changedColumns['foo'] = new ColumnDiff(
+ 'foo',
+ new Column(
+ 'foo',
+ Type::getType('string'),
+ ['default' => 'bla', 'notnull' => true]
),
- array('type')
- );
- $tableDiff->changedColumns['bar'] = new \Doctrine\DBAL\Schema\ColumnDiff(
- 'bar', new \Doctrine\DBAL\Schema\Column(
- 'baz', \Doctrine\DBAL\Types\Type::getType('string'), array('default' => 'bla', 'notnull' => true)
+ ['type']
+ );
+ $tableDiff->changedColumns['bar'] = new ColumnDiff(
+ 'bar',
+ new Column(
+ 'baz',
+ Type::getType('string'),
+ ['default' => 'bla', 'notnull' => true]
),
- array('type', 'notnull')
- );
- $tableDiff->changedColumns['metar'] = new \Doctrine\DBAL\Schema\ColumnDiff(
- 'metar', new \Doctrine\DBAL\Schema\Column(
- 'metar', \Doctrine\DBAL\Types\Type::getType('string'), array('length' => 2000, 'notnull' => false)
+ ['type', 'notnull']
+ );
+ $tableDiff->changedColumns['metar'] = new ColumnDiff(
+ 'metar',
+ new Column(
+ 'metar',
+ Type::getType('string'),
+ ['length' => 2000, 'notnull' => false]
),
- array('notnull')
+ ['notnull']
);
- $expectedSql = array(
- "ALTER TABLE mytable MODIFY (foo VARCHAR2(255) DEFAULT 'bla', baz VARCHAR2(255) DEFAULT 'bla' NOT NULL, metar VARCHAR2(2000) DEFAULT NULL NULL)",
- );
- self::assertEquals($expectedSql, $this->_platform->getAlterTableSQL($tableDiff));
+ $expectedSql = ["ALTER TABLE mytable MODIFY (foo VARCHAR2(255) DEFAULT 'bla', baz VARCHAR2(255) DEFAULT 'bla' NOT NULL, metar VARCHAR2(2000) DEFAULT NULL NULL)"];
+ self::assertEquals($expectedSql, $this->platform->getAlterTableSQL($tableDiff));
}
/**
@@ -426,14 +459,14 @@ public function testAlterTableNotNULL()
*/
public function testInitializesDoctrineTypeMappings()
{
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('long raw'));
- self::assertSame('blob', $this->_platform->getDoctrineTypeMapping('long raw'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('long raw'));
+ self::assertSame('blob', $this->platform->getDoctrineTypeMapping('long raw'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('raw'));
- self::assertSame('binary', $this->_platform->getDoctrineTypeMapping('raw'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('raw'));
+ self::assertSame('binary', $this->platform->getDoctrineTypeMapping('raw'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('date'));
- self::assertSame('date', $this->_platform->getDoctrineTypeMapping('date'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('date'));
+ self::assertSame('date', $this->platform->getDoctrineTypeMapping('date'));
}
protected function getBinaryMaxLength()
@@ -443,13 +476,13 @@ protected function getBinaryMaxLength()
public function testReturnsBinaryTypeDeclarationSQL()
{
- self::assertSame('RAW(255)', $this->_platform->getBinaryTypeDeclarationSQL(array()));
- self::assertSame('RAW(2000)', $this->_platform->getBinaryTypeDeclarationSQL(array('length' => 0)));
- self::assertSame('RAW(2000)', $this->_platform->getBinaryTypeDeclarationSQL(array('length' => 2000)));
+ self::assertSame('RAW(255)', $this->platform->getBinaryTypeDeclarationSQL([]));
+ self::assertSame('RAW(2000)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0]));
+ self::assertSame('RAW(2000)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 2000]));
- self::assertSame('RAW(255)', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true)));
- self::assertSame('RAW(2000)', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true, 'length' => 0)));
- self::assertSame('RAW(2000)', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true, 'length' => 2000)));
+ self::assertSame('RAW(255)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true]));
+ self::assertSame('RAW(2000)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 0]));
+ self::assertSame('RAW(2000)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 2000]));
}
/**
@@ -458,25 +491,25 @@ public function testReturnsBinaryTypeDeclarationSQL()
*/
public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL()
{
- self::assertSame('BLOB', $this->_platform->getBinaryTypeDeclarationSQL(['length' => 2001]));
- self::assertSame('BLOB', $this->_platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 2001]));
+ self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL(['length' => 2001]));
+ self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 2001]));
}
public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType()
{
$table1 = new Table('mytable');
$table1->addColumn('column_varbinary', 'binary');
- $table1->addColumn('column_binary', 'binary', array('fixed' => true));
+ $table1->addColumn('column_binary', 'binary', ['fixed' => true]);
$table2 = new Table('mytable');
- $table2->addColumn('column_varbinary', 'binary', array('fixed' => true));
+ $table2->addColumn('column_varbinary', 'binary', ['fixed' => true]);
$table2->addColumn('column_binary', 'binary');
$comparator = new Comparator();
// VARBINARY -> BINARY
// BINARY -> VARBINARY
- self::assertEmpty($this->_platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
+ self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
}
/**
@@ -484,7 +517,7 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType()
*/
public function testUsesSequenceEmulatedIdentityColumns()
{
- self::assertTrue($this->_platform->usesSequenceEmulatedIdentityColumns());
+ self::assertTrue($this->platform->usesSequenceEmulatedIdentityColumns());
}
/**
@@ -493,10 +526,10 @@ public function testUsesSequenceEmulatedIdentityColumns()
*/
public function testReturnsIdentitySequenceName()
{
- self::assertSame('MYTABLE_SEQ', $this->_platform->getIdentitySequenceName('mytable', 'mycolumn'));
- self::assertSame('"mytable_SEQ"', $this->_platform->getIdentitySequenceName('"mytable"', 'mycolumn'));
- self::assertSame('MYTABLE_SEQ', $this->_platform->getIdentitySequenceName('mytable', '"mycolumn"'));
- self::assertSame('"mytable_SEQ"', $this->_platform->getIdentitySequenceName('"mytable"', '"mycolumn"'));
+ self::assertSame('MYTABLE_SEQ', $this->platform->getIdentitySequenceName('mytable', 'mycolumn'));
+ self::assertSame('"mytable_SEQ"', $this->platform->getIdentitySequenceName('"mytable"', 'mycolumn'));
+ self::assertSame('MYTABLE_SEQ', $this->platform->getIdentitySequenceName('mytable', '"mycolumn"'));
+ self::assertSame('"mytable_SEQ"', $this->platform->getIdentitySequenceName('"mytable"', '"mycolumn"'));
}
/**
@@ -505,17 +538,17 @@ public function testReturnsIdentitySequenceName()
*/
public function testCreateSequenceWithCache($cacheSize, $expectedSql)
{
- $sequence = new \Doctrine\DBAL\Schema\Sequence('foo', 1, 1, $cacheSize);
- self::assertContains($expectedSql, $this->_platform->getCreateSequenceSQL($sequence));
+ $sequence = new Sequence('foo', 1, 1, $cacheSize);
+ self::assertContains($expectedSql, $this->platform->getCreateSequenceSQL($sequence));
}
public function dataCreateSequenceWithCache()
{
- return array(
- array(1, 'NOCACHE'),
- array(0, 'NOCACHE'),
- array(3, 'CACHE 3')
- );
+ return [
+ [1, 'NOCACHE'],
+ [0, 'NOCACHE'],
+ [3, 'CACHE 3'],
+ ];
}
/**
@@ -523,9 +556,7 @@ public function dataCreateSequenceWithCache()
*/
protected function getAlterTableRenameIndexSQL()
{
- return array(
- 'ALTER INDEX idx_foo RENAME TO idx_bar',
- );
+ return ['ALTER INDEX idx_foo RENAME TO idx_bar'];
}
/**
@@ -533,10 +564,10 @@ protected function getAlterTableRenameIndexSQL()
*/
protected function getQuotedAlterTableRenameIndexSQL()
{
- return array(
+ return [
'ALTER INDEX "create" RENAME TO "select"',
'ALTER INDEX "foo" RENAME TO "bar"',
- );
+ ];
}
/**
@@ -544,7 +575,7 @@ protected function getQuotedAlterTableRenameIndexSQL()
*/
protected function getQuotedAlterTableRenameColumnSQL()
{
- return array(
+ return [
'ALTER TABLE mytable RENAME COLUMN unquoted1 TO unquoted',
'ALTER TABLE mytable RENAME COLUMN unquoted2 TO "where"',
'ALTER TABLE mytable RENAME COLUMN unquoted3 TO "foo"',
@@ -554,7 +585,7 @@ protected function getQuotedAlterTableRenameColumnSQL()
'ALTER TABLE mytable RENAME COLUMN quoted1 TO quoted',
'ALTER TABLE mytable RENAME COLUMN quoted2 TO "and"',
'ALTER TABLE mytable RENAME COLUMN quoted3 TO "baz"',
- );
+ ];
}
/**
@@ -570,9 +601,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL()
*/
protected function getAlterTableRenameIndexInSchemaSQL()
{
- return array(
- 'ALTER INDEX myschema.idx_foo RENAME TO idx_bar',
- );
+ return ['ALTER INDEX myschema.idx_foo RENAME TO idx_bar'];
}
/**
@@ -580,10 +609,10 @@ protected function getAlterTableRenameIndexInSchemaSQL()
*/
protected function getQuotedAlterTableRenameIndexInSchemaSQL()
{
- return array(
+ return [
'ALTER INDEX "schema"."create" RENAME TO "select"',
'ALTER INDEX "schema"."foo" RENAME TO "bar"',
- );
+ ];
}
protected function getQuotesDropForeignKeySQL()
@@ -596,7 +625,7 @@ protected function getQuotesDropForeignKeySQL()
*/
public function testReturnsGuidTypeDeclarationSQL()
{
- self::assertSame('CHAR(36)', $this->_platform->getGuidTypeDeclarationSQL(array()));
+ self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([]));
}
/**
@@ -604,9 +633,7 @@ public function testReturnsGuidTypeDeclarationSQL()
*/
public function getAlterTableRenameColumnSQL()
{
- return array(
- 'ALTER TABLE foo RENAME COLUMN bar TO baz',
- );
+ return ['ALTER TABLE foo RENAME COLUMN bar TO baz'];
}
/**
@@ -615,37 +642,37 @@ public function getAlterTableRenameColumnSQL()
*/
public function testReturnsDropAutoincrementSQL($table, $expectedSql)
{
- self::assertSame($expectedSql, $this->_platform->getDropAutoincrementSql($table));
+ self::assertSame($expectedSql, $this->platform->getDropAutoincrementSql($table));
}
public function getReturnsDropAutoincrementSQL()
{
- return array(
- array(
+ return [
+ [
'myTable',
- array(
+ [
'DROP TRIGGER MYTABLE_AI_PK',
'DROP SEQUENCE MYTABLE_SEQ',
'ALTER TABLE MYTABLE DROP CONSTRAINT MYTABLE_AI_PK',
- )
- ),
- array(
+ ],
+ ],
+ [
'"myTable"',
- array(
+ [
'DROP TRIGGER "myTable_AI_PK"',
'DROP SEQUENCE "myTable_SEQ"',
'ALTER TABLE "myTable" DROP CONSTRAINT "myTable_AI_PK"',
- )
- ),
- array(
+ ],
+ ],
+ [
'table',
- array(
+ [
'DROP TRIGGER TABLE_AI_PK',
'DROP SEQUENCE TABLE_SEQ',
'ALTER TABLE "TABLE" DROP CONSTRAINT TABLE_AI_PK',
- )
- ),
- );
+ ],
+ ],
+ ];
}
/**
@@ -653,7 +680,7 @@ public function getReturnsDropAutoincrementSQL()
*/
protected function getQuotesTableIdentifiersInAlterTableSQL()
{
- return array(
+ return [
'ALTER TABLE "foo" DROP CONSTRAINT fk1',
'ALTER TABLE "foo" DROP CONSTRAINT fk2',
'ALTER TABLE "foo" ADD (bloo NUMBER(10) NOT NULL)',
@@ -663,7 +690,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL()
'ALTER TABLE "foo" RENAME TO "table"',
'ALTER TABLE "table" ADD CONSTRAINT fk_add FOREIGN KEY (fk3) REFERENCES fk_table (id)',
'ALTER TABLE "table" ADD CONSTRAINT fk2 FOREIGN KEY (fk2) REFERENCES fk_table2 (id)',
- );
+ ];
}
/**
@@ -671,11 +698,11 @@ protected function getQuotesTableIdentifiersInAlterTableSQL()
*/
protected function getCommentOnColumnSQL()
{
- return array(
+ return [
'COMMENT ON COLUMN foo.bar IS \'comment\'',
'COMMENT ON COLUMN "Foo"."BAR" IS \'comment\'',
'COMMENT ON COLUMN "select"."from" IS \'comment\'',
- );
+ ];
}
/**
@@ -683,33 +710,31 @@ protected function getCommentOnColumnSQL()
*/
public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers()
{
- $table1 = new Table('"foo"', array(new Column('"bar"', Type::getType('integer'))));
- $table2 = new Table('"foo"', array(new Column('"bar"', Type::getType('integer'), array('comment' => 'baz'))));
+ $table1 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'))]);
+ $table2 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'), ['comment' => 'baz'])]);
$comparator = new Comparator();
$tableDiff = $comparator->diffTable($table1, $table2);
- self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
+ self::assertInstanceOf(TableDiff::class, $tableDiff);
self::assertSame(
- array(
- 'COMMENT ON COLUMN "foo"."bar" IS \'baz\'',
- ),
- $this->_platform->getAlterTableSQL($tableDiff)
+ ['COMMENT ON COLUMN "foo"."bar" IS \'baz\''],
+ $this->platform->getAlterTableSQL($tableDiff)
);
}
public function testQuotedTableNames()
{
$table = new Table('"test"');
- $table->addColumn('"id"', 'integer', array('autoincrement' => true));
+ $table->addColumn('"id"', 'integer', ['autoincrement' => true]);
// assert tabel
self::assertTrue($table->isQuoted());
self::assertEquals('test', $table->getName());
- self::assertEquals('"test"', $table->getQuotedName($this->_platform));
+ self::assertEquals('"test"', $table->getQuotedName($this->platform));
- $sql = $this->_platform->getCreateTableSQL($table);
+ $sql = $this->platform->getCreateTableSQL($table);
self::assertEquals('CREATE TABLE "test" ("id" NUMBER(10) NOT NULL)', $sql[0]);
self::assertEquals('CREATE SEQUENCE "test_SEQ" START WITH 1 MINVALUE 1 INCREMENT BY 1', $sql[2]);
$createTriggerStatement = <<_platform->getListTableColumnsSQL('"test"', $database));
+ self::assertEquals($expectedSql, $this->platform->getListTableColumnsSQL('"test"', $database));
}
public function getReturnsGetListTableColumnsSQL()
{
- return array(
- array(
+ return [
+ [
null,
"SELECT c.*,
(
@@ -765,9 +790,9 @@ public function getReturnsGetListTableColumnsSQL()
) AS comments
FROM user_tab_columns c
WHERE c.table_name = 'test'
- ORDER BY c.column_id"
- ),
- array(
+ ORDER BY c.column_id",
+ ],
+ [
'/',
"SELECT c.*,
(
@@ -778,9 +803,9 @@ public function getReturnsGetListTableColumnsSQL()
) AS comments
FROM user_tab_columns c
WHERE c.table_name = 'test'
- ORDER BY c.column_id"
- ),
- array(
+ ORDER BY c.column_id",
+ ],
+ [
'scott',
"SELECT c.*,
(
@@ -791,9 +816,9 @@ public function getReturnsGetListTableColumnsSQL()
) AS comments
FROM all_tab_columns c
WHERE c.table_name = 'test' AND c.owner = 'SCOTT'
- ORDER BY c.column_id"
- ),
- );
+ ORDER BY c.column_id",
+ ],
+ ];
}
/**
@@ -825,9 +850,7 @@ protected function getQuotesReservedKeywordInTruncateTableSQL()
*/
protected function getAlterStringToFixedStringSQL()
{
- return array(
- 'ALTER TABLE mytable MODIFY (name CHAR(2) DEFAULT NULL)',
- );
+ return ['ALTER TABLE mytable MODIFY (name CHAR(2) DEFAULT NULL)'];
}
/**
@@ -835,9 +858,7 @@ protected function getAlterStringToFixedStringSQL()
*/
protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
{
- return array(
- 'ALTER INDEX idx_foo RENAME TO idx_foo_renamed',
- );
+ return ['ALTER INDEX idx_foo RENAME TO idx_foo_renamed'];
}
/**
@@ -845,7 +866,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
*/
public function testQuotesDatabaseNameInListSequencesSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListSequencesSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListSequencesSQL("Foo'Bar\\"), '', true);
}
/**
@@ -853,7 +874,7 @@ public function testQuotesDatabaseNameInListSequencesSQL()
*/
public function testQuotesTableNameInListTableIndexesSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableIndexesSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableIndexesSQL("Foo'Bar\\"), '', true);
}
/**
@@ -861,7 +882,7 @@ public function testQuotesTableNameInListTableIndexesSQL()
*/
public function testQuotesTableNameInListTableForeignKeysSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
}
/**
@@ -869,7 +890,7 @@ public function testQuotesTableNameInListTableForeignKeysSQL()
*/
public function testQuotesTableNameInListTableConstraintsSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true);
}
/**
@@ -877,7 +898,7 @@ public function testQuotesTableNameInListTableConstraintsSQL()
*/
public function testQuotesTableNameInListTableColumnsSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableColumnsSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableColumnsSQL("Foo'Bar\\"), '', true);
}
/**
@@ -885,6 +906,6 @@ public function testQuotesTableNameInListTableColumnsSQL()
*/
public function testQuotesDatabaseNameInListTableColumnsSQL()
{
- self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableColumnsSQL('foo_table', "Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableColumnsSQL('foo_table', "Foo'Bar\\"), '', true);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php
index 987628de218..df30fc471f0 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php
@@ -27,7 +27,7 @@ public function testGetListSequencesSQL() : void
WHERE sequence_catalog = 'test_db'
AND sequence_schema NOT LIKE 'pg\_%'
AND sequence_schema != 'information_schema'",
- $this->_platform->getListSequencesSQL('test_db')
+ $this->platform->getListSequencesSQL('test_db')
);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php
index 0fc2403af79..ec62ac8b026 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php
@@ -14,14 +14,14 @@ public function createPlatform()
public function testSupportsColumnCollation() : void
{
- self::assertTrue($this->_platform->supportsColumnCollation());
+ self::assertTrue($this->platform->supportsColumnCollation());
}
public function testColumnCollationDeclarationSQL() : void
{
self::assertSame(
'COLLATE "en_US.UTF-8"',
- $this->_platform->getColumnCollationDeclarationSQL('en_US.UTF-8')
+ $this->platform->getColumnCollationDeclarationSQL('en_US.UTF-8')
);
}
@@ -33,7 +33,7 @@ public function testGetCreateTableSQLWithColumnCollation() : void
self::assertSame(
['CREATE TABLE foo (no_collation VARCHAR(255) NOT NULL, column_collation VARCHAR(255) NOT NULL COLLATE "en_US.UTF-8")'],
- $this->_platform->getCreateTableSQL($table),
+ $this->platform->getCreateTableSQL($table),
'Column "no_collation" will use the default collation from the table/database and "column_collation" overwrites the collation on this column'
);
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php
index 0189dbdfe36..fb36beb334a 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php
@@ -20,7 +20,7 @@ public function createPlatform()
*/
public function testHasNativeJsonType()
{
- self::assertTrue($this->_platform->hasNativeJsonType());
+ self::assertTrue($this->platform->hasNativeJsonType());
}
/**
@@ -28,24 +28,24 @@ public function testHasNativeJsonType()
*/
public function testReturnsJsonTypeDeclarationSQL()
{
- self::assertSame('JSON', $this->_platform->getJsonTypeDeclarationSQL(array()));
+ self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL([]));
}
public function testReturnsSmallIntTypeDeclarationSQL()
{
self::assertSame(
'SMALLSERIAL',
- $this->_platform->getSmallIntTypeDeclarationSQL(array('autoincrement' => true))
+ $this->platform->getSmallIntTypeDeclarationSQL(['autoincrement' => true])
);
self::assertSame(
'SMALLINT',
- $this->_platform->getSmallIntTypeDeclarationSQL(array('autoincrement' => false))
+ $this->platform->getSmallIntTypeDeclarationSQL(['autoincrement' => false])
);
self::assertSame(
'SMALLINT',
- $this->_platform->getSmallIntTypeDeclarationSQL(array())
+ $this->platform->getSmallIntTypeDeclarationSQL([])
);
}
@@ -54,8 +54,8 @@ public function testReturnsSmallIntTypeDeclarationSQL()
*/
public function testInitializesJsonTypeMapping()
{
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('json'));
- self::assertEquals(Type::JSON, $this->_platform->getDoctrineTypeMapping('json'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json'));
+ self::assertEquals(Type::JSON, $this->platform->getDoctrineTypeMapping('json'));
}
/**
@@ -65,7 +65,7 @@ public function testReturnsCloseActiveDatabaseConnectionsSQL()
{
self::assertSame(
"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'foo'",
- $this->_platform->getCloseActiveDatabaseConnectionsSQL('foo')
+ $this->platform->getCloseActiveDatabaseConnectionsSQL('foo')
);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php
index d566007afc2..ed118aec406 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php
@@ -18,14 +18,14 @@ public function createPlatform()
public function testReturnsJsonTypeDeclarationSQL()
{
parent::testReturnsJsonTypeDeclarationSQL();
- self::assertSame('JSON', $this->_platform->getJsonTypeDeclarationSQL(array('jsonb' => false)));
- self::assertSame('JSONB', $this->_platform->getJsonTypeDeclarationSQL(array('jsonb' => true)));
+ self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL(['jsonb' => false]));
+ self::assertSame('JSONB', $this->platform->getJsonTypeDeclarationSQL(['jsonb' => true]));
}
public function testInitializesJsonTypeMapping()
{
parent::testInitializesJsonTypeMapping();
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('jsonb'));
- self::assertEquals(Type::JSON, $this->_platform->getDoctrineTypeMapping('jsonb'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('jsonb'));
+ self::assertEquals(Type::JSON, $this->platform->getDoctrineTypeMapping('jsonb'));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
index 6db159df48e..b45a152ab0a 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
@@ -8,11 +8,11 @@ class PostgreSqlPlatformTest extends AbstractPostgreSqlPlatformTestCase
{
public function createPlatform()
{
- return new PostgreSqlPlatform;
+ return new PostgreSqlPlatform();
}
public function testSupportsPartialIndexes()
{
- self::assertTrue($this->_platform->supportsPartialIndexes());
+ self::assertTrue($this->platform->supportsPartialIndexes());
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php b/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php
index bf1ad773238..22ab967fd7e 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php
@@ -2,43 +2,41 @@
namespace Doctrine\Tests\DBAL\Platforms;
+use Doctrine\DBAL\Platforms\Keywords\MySQLKeywords;
use Doctrine\DBAL\Platforms\Keywords\ReservedKeywordsValidator;
use Doctrine\DBAL\Schema\Table;
+use Doctrine\Tests\DbalTestCase;
-class ReservedKeywordsValidatorTest extends \Doctrine\Tests\DbalTestCase
+class ReservedKeywordsValidatorTest extends DbalTestCase
{
- /**
- * @var ReservedKeywordsValidator
- */
+ /** @var ReservedKeywordsValidator */
private $validator;
protected function setUp()
{
- $this->validator = new ReservedKeywordsValidator(array(
- new \Doctrine\DBAL\Platforms\Keywords\MySQLKeywords()
- ));
+ $this->validator = new ReservedKeywordsValidator([new MySQLKeywords()]);
}
public function testReservedTableName()
{
- $table = new Table("TABLE");
+ $table = new Table('TABLE');
$this->validator->acceptTable($table);
self::assertEquals(
- array('Table TABLE keyword violations: MySQL'),
+ ['Table TABLE keyword violations: MySQL'],
$this->validator->getViolations()
);
}
public function testReservedColumnName()
{
- $table = new Table("TABLE");
+ $table = new Table('TABLE');
$column = $table->addColumn('table', 'string');
$this->validator->acceptColumn($table, $column);
self::assertEquals(
- array('Table TABLE column table keyword violations: MySQL'),
+ ['Table TABLE column table keyword violations: MySQL'],
$this->validator->getViolations()
);
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php
index c59a9b1ac12..7e91777d6ef 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php
@@ -6,14 +6,12 @@
class SQLAnywhere11PlatformTest extends SQLAnywherePlatformTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\SQLAnywhere11Platform
- */
- protected $_platform;
+ /** @var SQLAnywhere11Platform */
+ protected $platform;
public function createPlatform()
{
- return new SQLAnywhere11Platform;
+ return new SQLAnywhere11Platform();
}
public function testDoesNotSupportRegexp()
@@ -23,6 +21,6 @@ public function testDoesNotSupportRegexp()
public function testGeneratesRegularExpressionSQLSnippet()
{
- self::assertEquals('REGEXP', $this->_platform->getRegexpExpression());
+ self::assertEquals('REGEXP', $this->platform->getRegexpExpression());
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php
index 4c6763ae124..7cbb2c69bb8 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php
@@ -8,14 +8,12 @@
class SQLAnywhere12PlatformTest extends SQLAnywhere11PlatformTest
{
- /**
- * @var \Doctrine\DBAL\Platforms\SQLAnywhere12Platform
- */
- protected $_platform;
+ /** @var SQLAnywhere12Platform */
+ protected $platform;
public function createPlatform()
{
- return new SQLAnywhere12Platform;
+ return new SQLAnywhere12Platform();
}
public function testDoesNotSupportSequences()
@@ -25,7 +23,7 @@ public function testDoesNotSupportSequences()
public function testSupportsSequences()
{
- self::assertTrue($this->_platform->supportsSequences());
+ self::assertTrue($this->platform->supportsSequences());
}
public function testGeneratesSequenceSqlCommands()
@@ -33,27 +31,27 @@ public function testGeneratesSequenceSqlCommands()
$sequence = new Sequence('myseq', 20, 1);
self::assertEquals(
'CREATE SEQUENCE myseq INCREMENT BY 20 START WITH 1 MINVALUE 1',
- $this->_platform->getCreateSequenceSQL($sequence)
+ $this->platform->getCreateSequenceSQL($sequence)
);
self::assertEquals(
'ALTER SEQUENCE myseq INCREMENT BY 20',
- $this->_platform->getAlterSequenceSQL($sequence)
+ $this->platform->getAlterSequenceSQL($sequence)
);
self::assertEquals(
'DROP SEQUENCE myseq',
- $this->_platform->getDropSequenceSQL('myseq')
+ $this->platform->getDropSequenceSQL('myseq')
);
self::assertEquals(
'DROP SEQUENCE myseq',
- $this->_platform->getDropSequenceSQL($sequence)
+ $this->platform->getDropSequenceSQL($sequence)
);
self::assertEquals(
- "SELECT myseq.NEXTVAL",
- $this->_platform->getSequenceNextValSQL('myseq')
+ 'SELECT myseq.NEXTVAL',
+ $this->platform->getSequenceNextValSQL('myseq')
);
self::assertEquals(
'SELECT sequence_name, increment_by, start_with, min_value FROM SYS.SYSSEQUENCE',
- $this->_platform->getListSequencesSQL(null)
+ $this->platform->getListSequencesSQL(null)
);
}
@@ -61,50 +59,50 @@ public function testGeneratesDateTimeTzColumnTypeDeclarationSQL()
{
self::assertEquals(
'TIMESTAMP WITH TIME ZONE',
- $this->_platform->getDateTimeTzTypeDeclarationSQL(array(
+ $this->platform->getDateTimeTzTypeDeclarationSQL([
'length' => 10,
'fixed' => true,
'unsigned' => true,
- 'autoincrement' => true
- ))
+ 'autoincrement' => true,
+ ])
);
}
public function testHasCorrectDateTimeTzFormatString()
{
- self::assertEquals('Y-m-d H:i:s.uP', $this->_platform->getDateTimeTzFormatString());
+ self::assertEquals('Y-m-d H:i:s.uP', $this->platform->getDateTimeTzFormatString());
}
public function testInitializesDateTimeTzTypeMapping()
{
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('timestamp with time zone'));
- self::assertEquals('datetime', $this->_platform->getDoctrineTypeMapping('timestamp with time zone'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('timestamp with time zone'));
+ self::assertEquals('datetime', $this->platform->getDoctrineTypeMapping('timestamp with time zone'));
}
public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL()
{
self::assertEquals(
'CREATE VIRTUAL UNIQUE CLUSTERED INDEX fooindex ON footable (a, b) WITH NULLS NOT DISTINCT FOR OLAP WORKLOAD',
- $this->_platform->getCreateIndexSQL(
+ $this->platform->getCreateIndexSQL(
new Index(
'fooindex',
- array('a', 'b'),
+ ['a', 'b'],
true,
false,
- array('virtual', 'clustered', 'with_nulls_not_distinct', 'for_olap_workload')
+ ['virtual', 'clustered', 'with_nulls_not_distinct', 'for_olap_workload']
),
'footable'
)
);
self::assertEquals(
'CREATE VIRTUAL CLUSTERED INDEX fooindex ON footable (a, b) FOR OLAP WORKLOAD',
- $this->_platform->getCreateIndexSQL(
+ $this->platform->getCreateIndexSQL(
new Index(
'fooindex',
- array('a', 'b'),
+ ['a', 'b'],
false,
false,
- array('virtual', 'clustered', 'with_nulls_not_distinct', 'for_olap_workload')
+ ['virtual', 'clustered', 'with_nulls_not_distinct', 'for_olap_workload']
),
'footable'
)
@@ -113,13 +111,13 @@ public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL()
// WITH NULLS NOT DISTINCT clause not available on primary indexes.
self::assertEquals(
'ALTER TABLE footable ADD PRIMARY KEY (a, b)',
- $this->_platform->getCreateIndexSQL(
+ $this->platform->getCreateIndexSQL(
new Index(
'fooindex',
- array('a', 'b'),
+ ['a', 'b'],
false,
true,
- array('with_nulls_not_distinct')
+ ['with_nulls_not_distinct']
),
'footable'
)
@@ -128,13 +126,13 @@ public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL()
// WITH NULLS NOT DISTINCT clause not available on non-unique indexes.
self::assertEquals(
'CREATE INDEX fooindex ON footable (a, b)',
- $this->_platform->getCreateIndexSQL(
+ $this->platform->getCreateIndexSQL(
new Index(
'fooindex',
- array('a', 'b'),
+ ['a', 'b'],
false,
false,
- array('with_nulls_not_distinct')
+ ['with_nulls_not_distinct']
),
'footable'
)
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php
index c66bb5177ab..9692ffb1f76 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php
@@ -9,20 +9,20 @@ class SQLAnywhere16PlatformTest extends SQLAnywhere12PlatformTest
{
public function createPlatform()
{
- return new SQLAnywhere16Platform;
+ return new SQLAnywhere16Platform();
}
public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL()
{
self::assertEquals(
'CREATE UNIQUE INDEX fooindex ON footable (a, b) WITH NULLS DISTINCT',
- $this->_platform->getCreateIndexSQL(
+ $this->platform->getCreateIndexSQL(
new Index(
'fooindex',
- array('a', 'b'),
+ ['a', 'b'],
true,
false,
- array('with_nulls_distinct')
+ ['with_nulls_distinct']
),
'footable'
)
@@ -31,13 +31,13 @@ public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL()
// WITH NULLS DISTINCT clause not available on primary indexes.
self::assertEquals(
'ALTER TABLE footable ADD PRIMARY KEY (a, b)',
- $this->_platform->getCreateIndexSQL(
+ $this->platform->getCreateIndexSQL(
new Index(
'fooindex',
- array('a', 'b'),
+ ['a', 'b'],
false,
true,
- array('with_nulls_distinct')
+ ['with_nulls_distinct']
),
'footable'
)
@@ -46,13 +46,13 @@ public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL()
// WITH NULLS DISTINCT clause not available on non-unique indexes.
self::assertEquals(
'CREATE INDEX fooindex ON footable (a, b)',
- $this->_platform->getCreateIndexSQL(
+ $this->platform->getCreateIndexSQL(
new Index(
'fooindex',
- array('a', 'b'),
+ ['a', 'b'],
false,
false,
- array('with_nulls_distinct')
+ ['with_nulls_distinct']
),
'footable'
)
@@ -65,13 +65,13 @@ public function testThrowsExceptionOnInvalidWithNullsNotDistinctIndexOptions()
{
$this->expectException('UnexpectedValueException');
- $this->_platform->getCreateIndexSQL(
+ $this->platform->getCreateIndexSQL(
new Index(
'fooindex',
- array('a', 'b'),
+ ['a', 'b'],
false,
false,
- array('with_nulls_distinct', 'with_nulls_not_distinct')
+ ['with_nulls_distinct', 'with_nulls_not_distinct']
),
'footable'
);
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
index 6c514b55f53..294b9836e2e 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
@@ -2,7 +2,7 @@
namespace Doctrine\Tests\DBAL\Platforms;
-use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\LockMode;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SQLAnywherePlatform;
@@ -10,34 +10,34 @@
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Comparator;
+use Doctrine\DBAL\Schema\Constraint;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\Type;
+use InvalidArgumentException;
use function mt_rand;
use function strlen;
use function substr;
class SQLAnywherePlatformTest extends AbstractPlatformTestCase
{
- /**
- * @var \Doctrine\DBAL\Platforms\SQLAnywherePlatform
- */
- protected $_platform;
+ /** @var SQLAnywherePlatform */
+ protected $platform;
public function createPlatform()
{
- return new SQLAnywherePlatform;
+ return new SQLAnywherePlatform();
}
public function getGenerateAlterTableSql()
{
- return array(
+ return [
"ALTER TABLE mytable ADD quota INT DEFAULT NULL, DROP foo, ALTER baz VARCHAR(1) DEFAULT 'def' NOT NULL, ALTER bloo BIT DEFAULT '0' NOT NULL",
- 'ALTER TABLE mytable RENAME userlist'
- );
+ 'ALTER TABLE mytable RENAME userlist',
+ ];
}
public function getGenerateForeignKeySql()
@@ -57,10 +57,10 @@ public function getGenerateTableSql()
public function getGenerateTableWithMultiColumnUniqueIndexSql()
{
- return array(
+ return [
'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)',
- 'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)'
- );
+ 'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)',
+ ];
}
public function getGenerateUniqueIndexSql()
@@ -70,81 +70,77 @@ public function getGenerateUniqueIndexSql()
protected function getQuotedColumnInForeignKeySQL()
{
- return array(
- 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, "bar" VARCHAR(255) NOT NULL, CONSTRAINT FK_WITH_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES "foreign" ("create", bar, "foo-bar"), CONSTRAINT FK_WITH_NON_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES foo ("create", bar, "foo-bar"), CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY ("create", foo, "bar") REFERENCES "foo-bar" ("create", bar, "foo-bar"))',
- );
+ return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, "bar" VARCHAR(255) NOT NULL, CONSTRAINT FK_WITH_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES "foreign" ("create", bar, "foo-bar"), CONSTRAINT FK_WITH_NON_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES foo ("create", bar, "foo-bar"), CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY ("create", foo, "bar") REFERENCES "foo-bar" ("create", bar, "foo-bar"))'];
}
protected function getQuotedColumnInIndexSQL()
{
- return array(
+ return [
'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)',
- 'CREATE INDEX IDX_22660D028FD6E0FB ON "quoted" ("create")'
- );
+ 'CREATE INDEX IDX_22660D028FD6E0FB ON "quoted" ("create")',
+ ];
}
protected function getQuotedNameInIndexSQL()
{
- return array(
+ return [
'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)',
'CREATE INDEX "key" ON test (column1)',
- );
+ ];
}
protected function getQuotedColumnInPrimaryKeySQL()
{
- return array(
- 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY ("create"))'
- );
+ return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY ("create"))'];
}
public function getCreateTableColumnCommentsSQL()
{
- return array(
- "CREATE TABLE test (id INT NOT NULL, PRIMARY KEY (id))",
+ return [
+ 'CREATE TABLE test (id INT NOT NULL, PRIMARY KEY (id))',
"COMMENT ON COLUMN test.id IS 'This is a comment'",
- );
+ ];
}
public function getAlterTableColumnCommentsSQL()
{
- return array(
- "ALTER TABLE mytable ADD quota INT NOT NULL",
+ return [
+ 'ALTER TABLE mytable ADD quota INT NOT NULL',
"COMMENT ON COLUMN mytable.quota IS 'A comment'",
- "COMMENT ON COLUMN mytable.foo IS NULL",
+ 'COMMENT ON COLUMN mytable.foo IS NULL',
"COMMENT ON COLUMN mytable.baz IS 'B comment'",
- );
+ ];
}
public function getCreateTableColumnTypeCommentsSQL()
{
- return array(
- "CREATE TABLE test (id INT NOT NULL, data TEXT NOT NULL, PRIMARY KEY (id))",
- "COMMENT ON COLUMN test.data IS '(DC2Type:array)'"
- );
+ return [
+ 'CREATE TABLE test (id INT NOT NULL, data TEXT NOT NULL, PRIMARY KEY (id))',
+ "COMMENT ON COLUMN test.data IS '(DC2Type:array)'",
+ ];
}
public function testHasCorrectPlatformName()
{
- self::assertEquals('sqlanywhere', $this->_platform->getName());
+ self::assertEquals('sqlanywhere', $this->platform->getName());
}
public function testGeneratesCreateTableSQLWithCommonIndexes()
{
$table = new Table('test');
$table->addColumn('id', 'integer');
- $table->addColumn('name', 'string', array('length' => 50));
- $table->setPrimaryKey(array('id'));
- $table->addIndex(array('name'));
- $table->addIndex(array('id', 'name'), 'composite_idx');
+ $table->addColumn('name', 'string', ['length' => 50]);
+ $table->setPrimaryKey(['id']);
+ $table->addIndex(['name']);
+ $table->addIndex(['id', 'name'], 'composite_idx');
self::assertEquals(
- array(
+ [
'CREATE TABLE test (id INT NOT NULL, name VARCHAR(50) NOT NULL, PRIMARY KEY (id))',
'CREATE INDEX IDX_D87F7E0C5E237E06 ON test (name)',
- 'CREATE INDEX composite_idx ON test (id, name)'
- ),
- $this->_platform->getCreateTableSQL($table)
+ 'CREATE INDEX composite_idx ON test (id, name)',
+ ],
+ $this->platform->getCreateTableSQL($table)
);
}
@@ -154,23 +150,22 @@ public function testGeneratesCreateTableSQLWithForeignKeyConstraints()
$table->addColumn('id', 'integer');
$table->addColumn('fk_1', 'integer');
$table->addColumn('fk_2', 'integer');
- $table->setPrimaryKey(array('id'));
- $table->addForeignKeyConstraint('foreign_table', array('fk_1', 'fk_2'), array('pk_1', 'pk_2'));
+ $table->setPrimaryKey(['id']);
+ $table->addForeignKeyConstraint('foreign_table', ['fk_1', 'fk_2'], ['pk_1', 'pk_2']);
$table->addForeignKeyConstraint(
'foreign_table2',
- array('fk_1', 'fk_2'),
- array('pk_1', 'pk_2'),
- array(),
+ ['fk_1', 'fk_2'],
+ ['pk_1', 'pk_2'],
+ [],
'named_fk'
);
self::assertEquals(
- array(
- 'CREATE TABLE test (id INT NOT NULL, fk_1 INT NOT NULL, fk_2 INT NOT NULL, ' .
+ ['CREATE TABLE test (id INT NOT NULL, fk_1 INT NOT NULL, fk_2 INT NOT NULL, ' .
'CONSTRAINT FK_D87F7E0C177612A38E7F4319 FOREIGN KEY (fk_1, fk_2) REFERENCES foreign_table (pk_1, pk_2), ' .
- 'CONSTRAINT named_fk FOREIGN KEY (fk_1, fk_2) REFERENCES foreign_table2 (pk_1, pk_2))'
- ),
- $this->_platform->getCreateTableSQL($table, AbstractPlatform::CREATE_FOREIGNKEYS)
+ 'CONSTRAINT named_fk FOREIGN KEY (fk_1, fk_2) REFERENCES foreign_table2 (pk_1, pk_2))',
+ ],
+ $this->platform->getCreateTableSQL($table, AbstractPlatform::CREATE_FOREIGNKEYS)
);
}
@@ -178,36 +173,32 @@ public function testGeneratesCreateTableSQLWithCheckConstraints()
{
$table = new Table('test');
$table->addColumn('id', 'integer');
- $table->addColumn('check_max', 'integer', array('platformOptions' => array('max' => 10)));
- $table->addColumn('check_min', 'integer', array('platformOptions' => array('min' => 10)));
- $table->setPrimaryKey(array('id'));
+ $table->addColumn('check_max', 'integer', ['platformOptions' => ['max' => 10]]);
+ $table->addColumn('check_min', 'integer', ['platformOptions' => ['min' => 10]]);
+ $table->setPrimaryKey(['id']);
self::assertEquals(
- array(
- 'CREATE TABLE test (id INT NOT NULL, check_max INT NOT NULL, check_min INT NOT NULL, PRIMARY KEY (id), CHECK (check_max <= 10), CHECK (check_min >= 10))'
- ),
- $this->_platform->getCreateTableSQL($table)
+ ['CREATE TABLE test (id INT NOT NULL, check_max INT NOT NULL, check_min INT NOT NULL, PRIMARY KEY (id), CHECK (check_max <= 10), CHECK (check_min >= 10))'],
+ $this->platform->getCreateTableSQL($table)
);
}
public function testGeneratesTableAlterationWithRemovedColumnCommentSql()
{
$table = new Table('mytable');
- $table->addColumn('foo', 'string', array('comment' => 'foo comment'));
+ $table->addColumn('foo', 'string', ['comment' => 'foo comment']);
- $tableDiff = new TableDiff('mytable');
- $tableDiff->fromTable = $table;
+ $tableDiff = new TableDiff('mytable');
+ $tableDiff->fromTable = $table;
$tableDiff->changedColumns['foo'] = new ColumnDiff(
'foo',
new Column('foo', Type::getType('string')),
- array('comment')
+ ['comment']
);
self::assertEquals(
- array(
- "COMMENT ON COLUMN mytable.foo IS NULL"
- ),
- $this->_platform->getAlterTableSQL($tableDiff)
+ ['COMMENT ON COLUMN mytable.foo IS NULL'],
+ $this->platform->getAlterTableSQL($tableDiff)
);
}
@@ -216,35 +207,35 @@ public function testGeneratesTableAlterationWithRemovedColumnCommentSql()
*/
public function testAppendsLockHint($lockMode, $lockHint)
{
- $fromClause = 'FROM users';
+ $fromClause = 'FROM users';
$expectedResult = $fromClause . $lockHint;
- self::assertSame($expectedResult, $this->_platform->appendLockHint($fromClause, $lockMode));
+ self::assertSame($expectedResult, $this->platform->appendLockHint($fromClause, $lockMode));
}
public function getLockHints()
{
- return array(
- array(null, ''),
- array(false, ''),
- array(true, ''),
- array(LockMode::NONE, ' WITH (NOLOCK)'),
- array(LockMode::OPTIMISTIC, ''),
- array(LockMode::PESSIMISTIC_READ, ' WITH (UPDLOCK)'),
- array(LockMode::PESSIMISTIC_WRITE, ' WITH (XLOCK)'),
- );
+ return [
+ [null, ''],
+ [false, ''],
+ [true, ''],
+ [LockMode::NONE, ' WITH (NOLOCK)'],
+ [LockMode::OPTIMISTIC, ''],
+ [LockMode::PESSIMISTIC_READ, ' WITH (UPDLOCK)'],
+ [LockMode::PESSIMISTIC_WRITE, ' WITH (XLOCK)'],
+ ];
}
public function testHasCorrectMaxIdentifierLength()
{
- self::assertEquals(128, $this->_platform->getMaxIdentifierLength());
+ self::assertEquals(128, $this->platform->getMaxIdentifierLength());
}
public function testFixesSchemaElementNames()
{
- $maxIdentifierLength = $this->_platform->getMaxIdentifierLength();
- $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $schemaElementName = '';
+ $maxIdentifierLength = $this->platform->getMaxIdentifierLength();
+ $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ $schemaElementName = '';
for ($i = 0; $i < $maxIdentifierLength + 100; $i++) {
$schemaElementName .= $characters[mt_rand(0, strlen($characters) - 1)];
@@ -254,115 +245,109 @@ public function testFixesSchemaElementNames()
self::assertEquals(
$fixedSchemaElementName,
- $this->_platform->fixSchemaElementName($schemaElementName)
+ $this->platform->fixSchemaElementName($schemaElementName)
);
self::assertEquals(
$fixedSchemaElementName,
- $this->_platform->fixSchemaElementName($fixedSchemaElementName)
+ $this->platform->fixSchemaElementName($fixedSchemaElementName)
);
}
public function testGeneratesColumnTypesDeclarationSQL()
{
- $fullColumnDef = array(
+ $fullColumnDef = [
'length' => 10,
'fixed' => true,
'unsigned' => true,
- 'autoincrement' => true
- );
-
- self::assertEquals('SMALLINT', $this->_platform->getSmallIntTypeDeclarationSQL(array()));
- self::assertEquals('UNSIGNED SMALLINT', $this->_platform->getSmallIntTypeDeclarationSQL(array(
- 'unsigned' => true
- )));
- self::assertEquals('UNSIGNED SMALLINT IDENTITY', $this->_platform->getSmallIntTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('INT', $this->_platform->getIntegerTypeDeclarationSQL(array()));
- self::assertEquals('UNSIGNED INT', $this->_platform->getIntegerTypeDeclarationSQL(array(
- 'unsigned' => true
- )));
- self::assertEquals('UNSIGNED INT IDENTITY', $this->_platform->getIntegerTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('BIGINT', $this->_platform->getBigIntTypeDeclarationSQL(array()));
- self::assertEquals('UNSIGNED BIGINT', $this->_platform->getBigIntTypeDeclarationSQL(array(
- 'unsigned' => true
- )));
- self::assertEquals('UNSIGNED BIGINT IDENTITY', $this->_platform->getBigIntTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('LONG BINARY', $this->_platform->getBlobTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('BIT', $this->_platform->getBooleanTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('TEXT', $this->_platform->getClobTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('DATE', $this->_platform->getDateTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('DATETIME', $this->_platform->getDateTimeTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('TIME', $this->_platform->getTimeTypeDeclarationSQL($fullColumnDef));
- self::assertEquals('UNIQUEIDENTIFIER', $this->_platform->getGuidTypeDeclarationSQL($fullColumnDef));
-
- self::assertEquals(1, $this->_platform->getVarcharDefaultLength());
- self::assertEquals(32767, $this->_platform->getVarcharMaxLength());
+ 'autoincrement' => true,
+ ];
+
+ self::assertEquals('SMALLINT', $this->platform->getSmallIntTypeDeclarationSQL([]));
+ self::assertEquals('UNSIGNED SMALLINT', $this->platform->getSmallIntTypeDeclarationSQL(['unsigned' => true]));
+ self::assertEquals('UNSIGNED SMALLINT IDENTITY', $this->platform->getSmallIntTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('INT', $this->platform->getIntegerTypeDeclarationSQL([]));
+ self::assertEquals('UNSIGNED INT', $this->platform->getIntegerTypeDeclarationSQL(['unsigned' => true]));
+ self::assertEquals('UNSIGNED INT IDENTITY', $this->platform->getIntegerTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('BIGINT', $this->platform->getBigIntTypeDeclarationSQL([]));
+ self::assertEquals('UNSIGNED BIGINT', $this->platform->getBigIntTypeDeclarationSQL(['unsigned' => true]));
+ self::assertEquals('UNSIGNED BIGINT IDENTITY', $this->platform->getBigIntTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('LONG BINARY', $this->platform->getBlobTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('BIT', $this->platform->getBooleanTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('TEXT', $this->platform->getClobTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('DATE', $this->platform->getDateTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('DATETIME', $this->platform->getDateTimeTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('TIME', $this->platform->getTimeTypeDeclarationSQL($fullColumnDef));
+ self::assertEquals('UNIQUEIDENTIFIER', $this->platform->getGuidTypeDeclarationSQL($fullColumnDef));
+
+ self::assertEquals(1, $this->platform->getVarcharDefaultLength());
+ self::assertEquals(32767, $this->platform->getVarcharMaxLength());
}
public function testHasNativeGuidType()
{
- self::assertTrue($this->_platform->hasNativeGuidType());
+ self::assertTrue($this->platform->hasNativeGuidType());
}
public function testGeneratesDDLSnippets()
{
- self::assertEquals("CREATE DATABASE 'foobar'", $this->_platform->getCreateDatabaseSQL('foobar'));
- self::assertEquals("CREATE DATABASE 'foobar'", $this->_platform->getCreateDatabaseSQL('"foobar"'));
- self::assertEquals("CREATE DATABASE 'create'", $this->_platform->getCreateDatabaseSQL('create'));
- self::assertEquals("DROP DATABASE 'foobar'", $this->_platform->getDropDatabaseSQL('foobar'));
- self::assertEquals("DROP DATABASE 'foobar'", $this->_platform->getDropDatabaseSQL('"foobar"'));
- self::assertEquals("DROP DATABASE 'create'", $this->_platform->getDropDatabaseSQL('create'));
- self::assertEquals('CREATE GLOBAL TEMPORARY TABLE', $this->_platform->getCreateTemporaryTableSnippetSQL());
- self::assertEquals("START DATABASE 'foobar' AUTOSTOP OFF", $this->_platform->getStartDatabaseSQL('foobar'));
- self::assertEquals("START DATABASE 'foobar' AUTOSTOP OFF", $this->_platform->getStartDatabaseSQL('"foobar"'));
- self::assertEquals("START DATABASE 'create' AUTOSTOP OFF", $this->_platform->getStartDatabaseSQL('create'));
- self::assertEquals('STOP DATABASE "foobar" UNCONDITIONALLY', $this->_platform->getStopDatabaseSQL('foobar'));
- self::assertEquals('STOP DATABASE "foobar" UNCONDITIONALLY', $this->_platform->getStopDatabaseSQL('"foobar"'));
- self::assertEquals('STOP DATABASE "create" UNCONDITIONALLY', $this->_platform->getStopDatabaseSQL('create'));
- self::assertEquals('TRUNCATE TABLE foobar', $this->_platform->getTruncateTableSQL('foobar'));
- self::assertEquals('TRUNCATE TABLE foobar', $this->_platform->getTruncateTableSQL('foobar'), true);
+ self::assertEquals("CREATE DATABASE 'foobar'", $this->platform->getCreateDatabaseSQL('foobar'));
+ self::assertEquals("CREATE DATABASE 'foobar'", $this->platform->getCreateDatabaseSQL('"foobar"'));
+ self::assertEquals("CREATE DATABASE 'create'", $this->platform->getCreateDatabaseSQL('create'));
+ self::assertEquals("DROP DATABASE 'foobar'", $this->platform->getDropDatabaseSQL('foobar'));
+ self::assertEquals("DROP DATABASE 'foobar'", $this->platform->getDropDatabaseSQL('"foobar"'));
+ self::assertEquals("DROP DATABASE 'create'", $this->platform->getDropDatabaseSQL('create'));
+ self::assertEquals('CREATE GLOBAL TEMPORARY TABLE', $this->platform->getCreateTemporaryTableSnippetSQL());
+ self::assertEquals("START DATABASE 'foobar' AUTOSTOP OFF", $this->platform->getStartDatabaseSQL('foobar'));
+ self::assertEquals("START DATABASE 'foobar' AUTOSTOP OFF", $this->platform->getStartDatabaseSQL('"foobar"'));
+ self::assertEquals("START DATABASE 'create' AUTOSTOP OFF", $this->platform->getStartDatabaseSQL('create'));
+ self::assertEquals('STOP DATABASE "foobar" UNCONDITIONALLY', $this->platform->getStopDatabaseSQL('foobar'));
+ self::assertEquals('STOP DATABASE "foobar" UNCONDITIONALLY', $this->platform->getStopDatabaseSQL('"foobar"'));
+ self::assertEquals('STOP DATABASE "create" UNCONDITIONALLY', $this->platform->getStopDatabaseSQL('create'));
+ self::assertEquals('TRUNCATE TABLE foobar', $this->platform->getTruncateTableSQL('foobar'));
+ self::assertEquals('TRUNCATE TABLE foobar', $this->platform->getTruncateTableSQL('foobar'), true);
$viewSql = 'SELECT * FROM footable';
- self::assertEquals('CREATE VIEW fooview AS ' . $viewSql, $this->_platform->getCreateViewSQL('fooview', $viewSql));
- self::assertEquals('DROP VIEW fooview', $this->_platform->getDropViewSQL('fooview'));
+ self::assertEquals('CREATE VIEW fooview AS ' . $viewSql, $this->platform->getCreateViewSQL('fooview', $viewSql));
+ self::assertEquals('DROP VIEW fooview', $this->platform->getDropViewSQL('fooview'));
}
public function testGeneratesPrimaryKeyDeclarationSQL()
{
self::assertEquals(
'CONSTRAINT pk PRIMARY KEY CLUSTERED (a, b)',
- $this->_platform->getPrimaryKeyDeclarationSQL(
- new Index(null, array('a', 'b'), true, true, array('clustered')),
+ $this->platform->getPrimaryKeyDeclarationSQL(
+ new Index(null, ['a', 'b'], true, true, ['clustered']),
'pk'
)
);
self::assertEquals(
'PRIMARY KEY (a, b)',
- $this->_platform->getPrimaryKeyDeclarationSQL(
- new Index(null, array('a', 'b'), true, true)
+ $this->platform->getPrimaryKeyDeclarationSQL(
+ new Index(null, ['a', 'b'], true, true)
)
);
}
public function testCannotGeneratePrimaryKeyDeclarationSQLWithEmptyColumns()
{
- $this->expectException('\InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
- $this->_platform->getPrimaryKeyDeclarationSQL(new Index('pk', array(), true, true));
+ $this->platform->getPrimaryKeyDeclarationSQL(new Index('pk', [], true, true));
}
public function testGeneratesCreateUnnamedPrimaryKeySQL()
{
self::assertEquals(
'ALTER TABLE foo ADD PRIMARY KEY CLUSTERED (a, b)',
- $this->_platform->getCreatePrimaryKeySQL(
- new Index('pk', array('a', 'b'), true, true, array('clustered')),
+ $this->platform->getCreatePrimaryKeySQL(
+ new Index('pk', ['a', 'b'], true, true, ['clustered']),
'foo'
)
);
self::assertEquals(
'ALTER TABLE foo ADD PRIMARY KEY (a, b)',
- $this->_platform->getCreatePrimaryKeySQL(
- new Index('any_pk_name', array('a', 'b'), true, true),
+ $this->platform->getCreatePrimaryKeySQL(
+ new Index('any_pk_name', ['a', 'b'], true, true),
new Table('foo')
)
);
@@ -372,22 +357,22 @@ public function testGeneratesUniqueConstraintDeclarationSQL()
{
self::assertEquals(
'CONSTRAINT unique_constraint UNIQUE CLUSTERED (a, b)',
- $this->_platform->getUniqueConstraintDeclarationSQL(
+ $this->platform->getUniqueConstraintDeclarationSQL(
'unique_constraint',
- new Index(null, array('a', 'b'), true, false, array('clustered'))
+ new Index(null, ['a', 'b'], true, false, ['clustered'])
)
);
self::assertEquals(
'UNIQUE (a, b)',
- $this->_platform->getUniqueConstraintDeclarationSQL(null, new Index(null, array('a', 'b'), true, false))
+ $this->platform->getUniqueConstraintDeclarationSQL(null, new Index(null, ['a', 'b'], true, false))
);
}
public function testCannotGenerateUniqueConstraintDeclarationSQLWithEmptyColumns()
{
- $this->expectException('\InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
- $this->_platform->getUniqueConstraintDeclarationSQL('constr', new Index('constr', array(), true));
+ $this->platform->getUniqueConstraintDeclarationSQL('constr', new Index('constr', [], true));
}
public function testGeneratesForeignKeyConstraintsWithAdvancedPlatformOptionsSQL()
@@ -397,84 +382,84 @@ public function testGeneratesForeignKeyConstraintsWithAdvancedPlatformOptionsSQL
'NOT NULL FOREIGN KEY (a, b) ' .
'REFERENCES foreign_table (c, d) ' .
'MATCH UNIQUE SIMPLE ON UPDATE CASCADE ON DELETE SET NULL CHECK ON COMMIT CLUSTERED FOR OLAP WORKLOAD',
- $this->_platform->getForeignKeyDeclarationSQL(
- new ForeignKeyConstraint(array('a', 'b'), 'foreign_table', array('c', 'd'), 'fk', array(
+ $this->platform->getForeignKeyDeclarationSQL(
+ new ForeignKeyConstraint(['a', 'b'], 'foreign_table', ['c', 'd'], 'fk', [
'notnull' => true,
'match' => SQLAnywherePlatform::FOREIGN_KEY_MATCH_SIMPLE_UNIQUE,
'onUpdate' => 'CASCADE',
'onDelete' => 'SET NULL',
'check_on_commit' => true,
'clustered' => true,
- 'for_olap_workload' => true
- ))
+ 'for_olap_workload' => true,
+ ])
)
);
self::assertEquals(
'FOREIGN KEY (a, b) REFERENCES foreign_table (c, d)',
- $this->_platform->getForeignKeyDeclarationSQL(
- new ForeignKeyConstraint(array('a', 'b'), 'foreign_table', array('c', 'd'))
+ $this->platform->getForeignKeyDeclarationSQL(
+ new ForeignKeyConstraint(['a', 'b'], 'foreign_table', ['c', 'd'])
)
);
}
public function testGeneratesForeignKeyMatchClausesSQL()
{
- self::assertEquals('SIMPLE', $this->_platform->getForeignKeyMatchClauseSQL(1));
- self::assertEquals('FULL', $this->_platform->getForeignKeyMatchClauseSQL(2));
- self::assertEquals('UNIQUE SIMPLE', $this->_platform->getForeignKeyMatchClauseSQL(129));
- self::assertEquals('UNIQUE FULL', $this->_platform->getForeignKeyMatchClauseSQL(130));
+ self::assertEquals('SIMPLE', $this->platform->getForeignKeyMatchClauseSQL(1));
+ self::assertEquals('FULL', $this->platform->getForeignKeyMatchClauseSQL(2));
+ self::assertEquals('UNIQUE SIMPLE', $this->platform->getForeignKeyMatchClauseSQL(129));
+ self::assertEquals('UNIQUE FULL', $this->platform->getForeignKeyMatchClauseSQL(130));
}
public function testCannotGenerateInvalidForeignKeyMatchClauseSQL()
{
- $this->expectException('\InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
- $this->_platform->getForeignKeyMatchCLauseSQL(3);
+ $this->platform->getForeignKeyMatchCLauseSQL(3);
}
public function testCannotGenerateForeignKeyConstraintSQLWithEmptyLocalColumns()
{
- $this->expectException('\InvalidArgumentException');
- $this->_platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint(array(), 'foreign_tbl', array('c', 'd')));
+ $this->expectException(InvalidArgumentException::class);
+ $this->platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint([], 'foreign_tbl', ['c', 'd']));
}
public function testCannotGenerateForeignKeyConstraintSQLWithEmptyForeignColumns()
{
- $this->expectException('\InvalidArgumentException');
- $this->_platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint(array('a', 'b'), 'foreign_tbl', array()));
+ $this->expectException(InvalidArgumentException::class);
+ $this->platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint(['a', 'b'], 'foreign_tbl', []));
}
public function testCannotGenerateForeignKeyConstraintSQLWithEmptyForeignTableName()
{
- $this->expectException('\InvalidArgumentException');
- $this->_platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint(array('a', 'b'), '', array('c', 'd')));
+ $this->expectException(InvalidArgumentException::class);
+ $this->platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint(['a', 'b'], '', ['c', 'd']));
}
public function testCannotGenerateCommonIndexWithCreateConstraintSQL()
{
- $this->expectException('\InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
- $this->_platform->getCreateConstraintSQL(new Index('fooindex', array()), new Table('footable'));
+ $this->platform->getCreateConstraintSQL(new Index('fooindex', []), new Table('footable'));
}
public function testCannotGenerateCustomConstraintWithCreateConstraintSQL()
{
- $this->expectException('\InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
- $this->_platform->getCreateConstraintSQL($this->createMock('\Doctrine\DBAL\Schema\Constraint'), 'footable');
+ $this->platform->getCreateConstraintSQL($this->createMock(Constraint::class), 'footable');
}
public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL()
{
self::assertEquals(
'CREATE VIRTUAL UNIQUE CLUSTERED INDEX fooindex ON footable (a, b) FOR OLAP WORKLOAD',
- $this->_platform->getCreateIndexSQL(
+ $this->platform->getCreateIndexSQL(
new Index(
'fooindex',
- array('a', 'b'),
+ ['a', 'b'],
true,
false,
- array('virtual', 'clustered', 'for_olap_workload')
+ ['virtual', 'clustered', 'for_olap_workload']
),
'footable'
)
@@ -483,18 +468,18 @@ public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL()
public function testDoesNotSupportIndexDeclarationInCreateAlterTableStatements()
{
- $this->expectException('\Doctrine\DBAL\DBALException');
+ $this->expectException(DBALException::class);
- $this->_platform->getIndexDeclarationSQL('index', new Index('index', array()));
+ $this->platform->getIndexDeclarationSQL('index', new Index('index', []));
}
public function testGeneratesDropIndexSQL()
{
- $index = new Index('fooindex', array());
+ $index = new Index('fooindex', []);
- self::assertEquals('DROP INDEX fooindex', $this->_platform->getDropIndexSQL($index));
- self::assertEquals('DROP INDEX footable.fooindex', $this->_platform->getDropIndexSQL($index, 'footable'));
- self::assertEquals('DROP INDEX footable.fooindex', $this->_platform->getDropIndexSQL(
+ self::assertEquals('DROP INDEX fooindex', $this->platform->getDropIndexSQL($index));
+ self::assertEquals('DROP INDEX footable.fooindex', $this->platform->getDropIndexSQL($index, 'footable'));
+ self::assertEquals('DROP INDEX footable.fooindex', $this->platform->getDropIndexSQL(
$index,
new Table('footable')
));
@@ -502,97 +487,97 @@ public function testGeneratesDropIndexSQL()
public function testCannotGenerateDropIndexSQLWithInvalidIndexParameter()
{
- $this->expectException('\InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
- $this->_platform->getDropIndexSQL(array('index'), 'table');
+ $this->platform->getDropIndexSQL(['index'], 'table');
}
public function testCannotGenerateDropIndexSQLWithInvalidTableParameter()
{
- $this->expectException('\InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
- $this->_platform->getDropIndexSQL('index', array('table'));
+ $this->platform->getDropIndexSQL('index', ['table']);
}
public function testGeneratesSQLSnippets()
{
- self::assertEquals('STRING(column1, "string1", column2, "string2")', $this->_platform->getConcatExpression(
+ self::assertEquals('STRING(column1, "string1", column2, "string2")', $this->platform->getConcatExpression(
'column1',
'"string1"',
'column2',
'"string2"'
));
- self::assertEquals('CURRENT DATE', $this->_platform->getCurrentDateSQL());
- self::assertEquals('CURRENT TIME', $this->_platform->getCurrentTimeSQL());
- self::assertEquals('CURRENT TIMESTAMP', $this->_platform->getCurrentTimestampSQL());
- self::assertEquals("DATEADD(DAY, 4, '1987/05/02')", $this->_platform->getDateAddDaysExpression("'1987/05/02'", 4));
- self::assertEquals("DATEADD(HOUR, 12, '1987/05/02')", $this->_platform->getDateAddHourExpression("'1987/05/02'", 12));
- self::assertEquals("DATEADD(MINUTE, 2, '1987/05/02')", $this->_platform->getDateAddMinutesExpression("'1987/05/02'", 2));
- self::assertEquals("DATEADD(MONTH, 102, '1987/05/02')", $this->_platform->getDateAddMonthExpression("'1987/05/02'", 102));
- self::assertEquals("DATEADD(QUARTER, 5, '1987/05/02')", $this->_platform->getDateAddQuartersExpression("'1987/05/02'", 5));
- self::assertEquals("DATEADD(SECOND, 1, '1987/05/02')", $this->_platform->getDateAddSecondsExpression("'1987/05/02'", 1));
- self::assertEquals("DATEADD(WEEK, 3, '1987/05/02')", $this->_platform->getDateAddWeeksExpression("'1987/05/02'", 3));
- self::assertEquals("DATEADD(YEAR, 10, '1987/05/02')", $this->_platform->getDateAddYearsExpression("'1987/05/02'", 10));
- self::assertEquals("DATEDIFF(day, '1987/04/01', '1987/05/02')", $this->_platform->getDateDiffExpression("'1987/05/02'", "'1987/04/01'"));
- self::assertEquals("DATEADD(DAY, -1 * 4, '1987/05/02')", $this->_platform->getDateSubDaysExpression("'1987/05/02'", 4));
- self::assertEquals("DATEADD(HOUR, -1 * 12, '1987/05/02')", $this->_platform->getDateSubHourExpression("'1987/05/02'", 12));
- self::assertEquals("DATEADD(MINUTE, -1 * 2, '1987/05/02')", $this->_platform->getDateSubMinutesExpression("'1987/05/02'", 2));
- self::assertEquals("DATEADD(MONTH, -1 * 102, '1987/05/02')", $this->_platform->getDateSubMonthExpression("'1987/05/02'", 102));
- self::assertEquals("DATEADD(QUARTER, -1 * 5, '1987/05/02')", $this->_platform->getDateSubQuartersExpression("'1987/05/02'", 5));
- self::assertEquals("DATEADD(SECOND, -1 * 1, '1987/05/02')", $this->_platform->getDateSubSecondsExpression("'1987/05/02'", 1));
- self::assertEquals("DATEADD(WEEK, -1 * 3, '1987/05/02')", $this->_platform->getDateSubWeeksExpression("'1987/05/02'", 3));
- self::assertEquals("DATEADD(YEAR, -1 * 10, '1987/05/02')", $this->_platform->getDateSubYearsExpression("'1987/05/02'", 10));
- self::assertEquals("Y-m-d H:i:s.u", $this->_platform->getDateTimeFormatString());
- self::assertEquals("H:i:s.u", $this->_platform->getTimeFormatString());
- self::assertEquals('', $this->_platform->getForUpdateSQL());
- self::assertEquals('NEWID()', $this->_platform->getGuidExpression());
- self::assertEquals('LOCATE(string_column, substring_column)', $this->_platform->getLocateExpression('string_column', 'substring_column'));
- self::assertEquals('LOCATE(string_column, substring_column, 1)', $this->_platform->getLocateExpression('string_column', 'substring_column', 1));
- self::assertEquals("HASH(column, 'MD5')", $this->_platform->getMd5Expression('column'));
- self::assertEquals('SUBSTRING(column, 5)', $this->_platform->getSubstringExpression('column', 5));
- self::assertEquals('SUBSTRING(column, 5, 2)', $this->_platform->getSubstringExpression('column', 5, 2));
- self::assertEquals('GLOBAL TEMPORARY', $this->_platform->getTemporaryTableSQL());
+ self::assertEquals('CURRENT DATE', $this->platform->getCurrentDateSQL());
+ self::assertEquals('CURRENT TIME', $this->platform->getCurrentTimeSQL());
+ self::assertEquals('CURRENT TIMESTAMP', $this->platform->getCurrentTimestampSQL());
+ self::assertEquals("DATEADD(DAY, 4, '1987/05/02')", $this->platform->getDateAddDaysExpression("'1987/05/02'", 4));
+ self::assertEquals("DATEADD(HOUR, 12, '1987/05/02')", $this->platform->getDateAddHourExpression("'1987/05/02'", 12));
+ self::assertEquals("DATEADD(MINUTE, 2, '1987/05/02')", $this->platform->getDateAddMinutesExpression("'1987/05/02'", 2));
+ self::assertEquals("DATEADD(MONTH, 102, '1987/05/02')", $this->platform->getDateAddMonthExpression("'1987/05/02'", 102));
+ self::assertEquals("DATEADD(QUARTER, 5, '1987/05/02')", $this->platform->getDateAddQuartersExpression("'1987/05/02'", 5));
+ self::assertEquals("DATEADD(SECOND, 1, '1987/05/02')", $this->platform->getDateAddSecondsExpression("'1987/05/02'", 1));
+ self::assertEquals("DATEADD(WEEK, 3, '1987/05/02')", $this->platform->getDateAddWeeksExpression("'1987/05/02'", 3));
+ self::assertEquals("DATEADD(YEAR, 10, '1987/05/02')", $this->platform->getDateAddYearsExpression("'1987/05/02'", 10));
+ self::assertEquals("DATEDIFF(day, '1987/04/01', '1987/05/02')", $this->platform->getDateDiffExpression("'1987/05/02'", "'1987/04/01'"));
+ self::assertEquals("DATEADD(DAY, -1 * 4, '1987/05/02')", $this->platform->getDateSubDaysExpression("'1987/05/02'", 4));
+ self::assertEquals("DATEADD(HOUR, -1 * 12, '1987/05/02')", $this->platform->getDateSubHourExpression("'1987/05/02'", 12));
+ self::assertEquals("DATEADD(MINUTE, -1 * 2, '1987/05/02')", $this->platform->getDateSubMinutesExpression("'1987/05/02'", 2));
+ self::assertEquals("DATEADD(MONTH, -1 * 102, '1987/05/02')", $this->platform->getDateSubMonthExpression("'1987/05/02'", 102));
+ self::assertEquals("DATEADD(QUARTER, -1 * 5, '1987/05/02')", $this->platform->getDateSubQuartersExpression("'1987/05/02'", 5));
+ self::assertEquals("DATEADD(SECOND, -1 * 1, '1987/05/02')", $this->platform->getDateSubSecondsExpression("'1987/05/02'", 1));
+ self::assertEquals("DATEADD(WEEK, -1 * 3, '1987/05/02')", $this->platform->getDateSubWeeksExpression("'1987/05/02'", 3));
+ self::assertEquals("DATEADD(YEAR, -1 * 10, '1987/05/02')", $this->platform->getDateSubYearsExpression("'1987/05/02'", 10));
+ self::assertEquals('Y-m-d H:i:s.u', $this->platform->getDateTimeFormatString());
+ self::assertEquals('H:i:s.u', $this->platform->getTimeFormatString());
+ self::assertEquals('', $this->platform->getForUpdateSQL());
+ self::assertEquals('NEWID()', $this->platform->getGuidExpression());
+ self::assertEquals('LOCATE(string_column, substring_column)', $this->platform->getLocateExpression('string_column', 'substring_column'));
+ self::assertEquals('LOCATE(string_column, substring_column, 1)', $this->platform->getLocateExpression('string_column', 'substring_column', 1));
+ self::assertEquals("HASH(column, 'MD5')", $this->platform->getMd5Expression('column'));
+ self::assertEquals('SUBSTRING(column, 5)', $this->platform->getSubstringExpression('column', 5));
+ self::assertEquals('SUBSTRING(column, 5, 2)', $this->platform->getSubstringExpression('column', 5, 2));
+ self::assertEquals('GLOBAL TEMPORARY', $this->platform->getTemporaryTableSQL());
self::assertEquals(
'LTRIM(column)',
- $this->_platform->getTrimExpression('column', TrimMode::LEADING)
+ $this->platform->getTrimExpression('column', TrimMode::LEADING)
);
self::assertEquals(
'RTRIM(column)',
- $this->_platform->getTrimExpression('column', TrimMode::TRAILING)
+ $this->platform->getTrimExpression('column', TrimMode::TRAILING)
);
self::assertEquals(
'TRIM(column)',
- $this->_platform->getTrimExpression('column')
+ $this->platform->getTrimExpression('column')
);
self::assertEquals(
'TRIM(column)',
- $this->_platform->getTrimExpression('column', TrimMode::UNSPECIFIED)
+ $this->platform->getTrimExpression('column', TrimMode::UNSPECIFIED)
);
self::assertEquals(
"SUBSTR(column, PATINDEX('%[^' + c + ']%', column))",
- $this->_platform->getTrimExpression('column', TrimMode::LEADING, 'c')
+ $this->platform->getTrimExpression('column', TrimMode::LEADING, 'c')
);
self::assertEquals(
"REVERSE(SUBSTR(REVERSE(column), PATINDEX('%[^' + c + ']%', REVERSE(column))))",
- $this->_platform->getTrimExpression('column', TrimMode::TRAILING, 'c')
+ $this->platform->getTrimExpression('column', TrimMode::TRAILING, 'c')
);
self::assertEquals(
"REVERSE(SUBSTR(REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))), PATINDEX('%[^' + c + ']%', " .
"REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))))))",
- $this->_platform->getTrimExpression('column', null, 'c')
+ $this->platform->getTrimExpression('column', null, 'c')
);
self::assertEquals(
"REVERSE(SUBSTR(REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))), PATINDEX('%[^' + c + ']%', " .
"REVERSE(SUBSTR(column, PATINDEX('%[^' + c + ']%', column))))))",
- $this->_platform->getTrimExpression('column', TrimMode::UNSPECIFIED, 'c')
+ $this->platform->getTrimExpression('column', TrimMode::UNSPECIFIED, 'c')
);
}
public function testDoesNotSupportRegexp()
{
- $this->expectException('\Doctrine\DBAL\DBALException');
+ $this->expectException(DBALException::class);
- $this->_platform->getRegexpExpression();
+ $this->platform->getRegexpExpression();
}
public function testHasCorrectDateTimeTzFormatString()
@@ -600,14 +585,14 @@ public function testHasCorrectDateTimeTzFormatString()
// Date time type with timezone is not supported before version 12.
// For versions before we have to ensure that the date time with timezone format
// equals the normal date time format so that it corresponds to the declaration SQL equality (datetimetz -> datetime).
- self::assertEquals($this->_platform->getDateTimeFormatString(), $this->_platform->getDateTimeTzFormatString());
+ self::assertEquals($this->platform->getDateTimeFormatString(), $this->platform->getDateTimeTzFormatString());
}
public function testHasCorrectDefaultTransactionIsolationLevel()
{
self::assertEquals(
TransactionIsolationLevel::READ_UNCOMMITTED,
- $this->_platform->getDefaultTransactionIsolationLevel()
+ $this->platform->getDefaultTransactionIsolationLevel()
);
}
@@ -615,34 +600,34 @@ public function testGeneratesTransactionsCommands()
{
self::assertEquals(
'SET TEMPORARY OPTION isolation_level = 0',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_UNCOMMITTED)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_UNCOMMITTED)
);
self::assertEquals(
'SET TEMPORARY OPTION isolation_level = 1',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_COMMITTED)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_COMMITTED)
);
self::assertEquals(
'SET TEMPORARY OPTION isolation_level = 2',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::REPEATABLE_READ)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::REPEATABLE_READ)
);
self::assertEquals(
'SET TEMPORARY OPTION isolation_level = 3',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::SERIALIZABLE)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::SERIALIZABLE)
);
}
public function testCannotGenerateTransactionCommandWithInvalidIsolationLevel()
{
- $this->expectException('\InvalidArgumentException');
+ $this->expectException(InvalidArgumentException::class);
- $this->_platform->getSetTransactionIsolationSQL('invalid_transaction_isolation_level');
+ $this->platform->getSetTransactionIsolationSQL('invalid_transaction_isolation_level');
}
public function testModifiesLimitQuery()
{
self::assertEquals(
'SELECT TOP 10 * FROM user',
- $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0)
+ $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0)
);
}
@@ -650,7 +635,7 @@ public function testModifiesLimitQueryWithEmptyOffset()
{
self::assertEquals(
'SELECT TOP 10 * FROM user',
- $this->_platform->modifyLimitQuery('SELECT * FROM user', 10)
+ $this->platform->modifyLimitQuery('SELECT * FROM user', 10)
);
}
@@ -658,11 +643,11 @@ public function testModifiesLimitQueryWithOffset()
{
self::assertEquals(
'SELECT TOP 10 START AT 6 * FROM user',
- $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 5)
+ $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 5)
);
self::assertEquals(
'SELECT TOP ALL START AT 6 * FROM user',
- $this->_platform->modifyLimitQuery('SELECT * FROM user', 0, 5)
+ $this->platform->modifyLimitQuery('SELECT * FROM user', 0, 5)
);
}
@@ -670,110 +655,110 @@ public function testModifiesLimitQueryWithSubSelect()
{
self::assertEquals(
'SELECT TOP 10 * FROM (SELECT u.id as uid, u.name as uname FROM user) AS doctrine_tbl',
- $this->_platform->modifyLimitQuery('SELECT * FROM (SELECT u.id as uid, u.name as uname FROM user) AS doctrine_tbl', 10)
+ $this->platform->modifyLimitQuery('SELECT * FROM (SELECT u.id as uid, u.name as uname FROM user) AS doctrine_tbl', 10)
);
}
public function testPrefersIdentityColumns()
{
- self::assertTrue($this->_platform->prefersIdentityColumns());
+ self::assertTrue($this->platform->prefersIdentityColumns());
}
public function testDoesNotPreferSequences()
{
- self::assertFalse($this->_platform->prefersSequences());
+ self::assertFalse($this->platform->prefersSequences());
}
public function testSupportsIdentityColumns()
{
- self::assertTrue($this->_platform->supportsIdentityColumns());
+ self::assertTrue($this->platform->supportsIdentityColumns());
}
public function testSupportsPrimaryConstraints()
{
- self::assertTrue($this->_platform->supportsPrimaryConstraints());
+ self::assertTrue($this->platform->supportsPrimaryConstraints());
}
public function testSupportsForeignKeyConstraints()
{
- self::assertTrue($this->_platform->supportsForeignKeyConstraints());
+ self::assertTrue($this->platform->supportsForeignKeyConstraints());
}
public function testSupportsForeignKeyOnUpdate()
{
- self::assertTrue($this->_platform->supportsForeignKeyOnUpdate());
+ self::assertTrue($this->platform->supportsForeignKeyOnUpdate());
}
public function testSupportsAlterTable()
{
- self::assertTrue($this->_platform->supportsAlterTable());
+ self::assertTrue($this->platform->supportsAlterTable());
}
public function testSupportsTransactions()
{
- self::assertTrue($this->_platform->supportsTransactions());
+ self::assertTrue($this->platform->supportsTransactions());
}
public function testSupportsSchemas()
{
- self::assertFalse($this->_platform->supportsSchemas());
+ self::assertFalse($this->platform->supportsSchemas());
}
public function testSupportsIndexes()
{
- self::assertTrue($this->_platform->supportsIndexes());
+ self::assertTrue($this->platform->supportsIndexes());
}
public function testSupportsCommentOnStatement()
{
- self::assertTrue($this->_platform->supportsCommentOnStatement());
+ self::assertTrue($this->platform->supportsCommentOnStatement());
}
public function testSupportsSavePoints()
{
- self::assertTrue($this->_platform->supportsSavepoints());
+ self::assertTrue($this->platform->supportsSavepoints());
}
public function testSupportsReleasePoints()
{
- self::assertTrue($this->_platform->supportsReleaseSavepoints());
+ self::assertTrue($this->platform->supportsReleaseSavepoints());
}
public function testSupportsCreateDropDatabase()
{
- self::assertTrue($this->_platform->supportsCreateDropDatabase());
+ self::assertTrue($this->platform->supportsCreateDropDatabase());
}
public function testSupportsGettingAffectedRows()
{
- self::assertTrue($this->_platform->supportsGettingAffectedRows());
+ self::assertTrue($this->platform->supportsGettingAffectedRows());
}
public function testDoesNotSupportSequences()
{
- self::assertFalse($this->_platform->supportsSequences());
+ self::assertFalse($this->platform->supportsSequences());
}
public function testDoesNotSupportInlineColumnComments()
{
- self::assertFalse($this->_platform->supportsInlineColumnComments());
+ self::assertFalse($this->platform->supportsInlineColumnComments());
}
public function testCannotEmulateSchemas()
{
- self::assertFalse($this->_platform->canEmulateSchemas());
+ self::assertFalse($this->platform->canEmulateSchemas());
}
public function testInitializesDoctrineTypeMappings()
{
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('integer'));
- self::assertSame('integer', $this->_platform->getDoctrineTypeMapping('integer'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('integer'));
+ self::assertSame('integer', $this->platform->getDoctrineTypeMapping('integer'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('binary'));
- self::assertSame('binary', $this->_platform->getDoctrineTypeMapping('binary'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('binary'));
+ self::assertSame('binary', $this->platform->getDoctrineTypeMapping('binary'));
- self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('varbinary'));
- self::assertSame('binary', $this->_platform->getDoctrineTypeMapping('varbinary'));
+ self::assertTrue($this->platform->hasDoctrineTypeMappingFor('varbinary'));
+ self::assertSame('binary', $this->platform->getDoctrineTypeMapping('varbinary'));
}
protected function getBinaryDefaultLength()
@@ -788,13 +773,13 @@ protected function getBinaryMaxLength()
public function testReturnsBinaryTypeDeclarationSQL()
{
- self::assertSame('VARBINARY(1)', $this->_platform->getBinaryTypeDeclarationSQL(array()));
- self::assertSame('VARBINARY(1)', $this->_platform->getBinaryTypeDeclarationSQL(array('length' => 0)));
- self::assertSame('VARBINARY(32767)', $this->_platform->getBinaryTypeDeclarationSQL(array('length' => 32767)));
+ self::assertSame('VARBINARY(1)', $this->platform->getBinaryTypeDeclarationSQL([]));
+ self::assertSame('VARBINARY(1)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0]));
+ self::assertSame('VARBINARY(32767)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 32767]));
- self::assertSame('BINARY(1)', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true)));
- self::assertSame('BINARY(1)', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true, 'length' => 0)));
- self::assertSame('BINARY(32767)', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true, 'length' => 32767)));
+ self::assertSame('BINARY(1)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true]));
+ self::assertSame('BINARY(1)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 0]));
+ self::assertSame('BINARY(32767)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 32767]));
}
/**
@@ -803,8 +788,8 @@ public function testReturnsBinaryTypeDeclarationSQL()
*/
public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL()
{
- self::assertSame('LONG BINARY', $this->_platform->getBinaryTypeDeclarationSQL(['length' => 32768]));
- self::assertSame('LONG BINARY', $this->_platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 32768]));
+ self::assertSame('LONG BINARY', $this->platform->getBinaryTypeDeclarationSQL(['length' => 32768]));
+ self::assertSame('LONG BINARY', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 32768]));
}
/**
@@ -812,9 +797,7 @@ public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL()
*/
protected function getAlterTableRenameIndexSQL()
{
- return array(
- 'ALTER INDEX idx_foo ON mytable RENAME TO idx_bar',
- );
+ return ['ALTER INDEX idx_foo ON mytable RENAME TO idx_bar'];
}
/**
@@ -822,10 +805,10 @@ protected function getAlterTableRenameIndexSQL()
*/
protected function getQuotedAlterTableRenameIndexSQL()
{
- return array(
+ return [
'ALTER INDEX "create" ON "table" RENAME TO "select"',
'ALTER INDEX "foo" ON "table" RENAME TO "bar"',
- );
+ ];
}
/**
@@ -833,7 +816,7 @@ protected function getQuotedAlterTableRenameIndexSQL()
*/
protected function getQuotedAlterTableRenameColumnSQL()
{
- return array(
+ return [
'ALTER TABLE mytable RENAME unquoted1 TO unquoted',
'ALTER TABLE mytable RENAME unquoted2 TO "where"',
'ALTER TABLE mytable RENAME unquoted3 TO "foo"',
@@ -843,7 +826,7 @@ protected function getQuotedAlterTableRenameColumnSQL()
'ALTER TABLE mytable RENAME quoted1 TO quoted',
'ALTER TABLE mytable RENAME quoted2 TO "and"',
'ALTER TABLE mytable RENAME quoted3 TO "baz"',
- );
+ ];
}
/**
@@ -859,9 +842,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL()
*/
protected function getAlterTableRenameIndexInSchemaSQL()
{
- return array(
- 'ALTER INDEX idx_foo ON myschema.mytable RENAME TO idx_bar',
- );
+ return ['ALTER INDEX idx_foo ON myschema.mytable RENAME TO idx_bar'];
}
/**
@@ -869,10 +850,10 @@ protected function getAlterTableRenameIndexInSchemaSQL()
*/
protected function getQuotedAlterTableRenameIndexInSchemaSQL()
{
- return array(
+ return [
'ALTER INDEX "create" ON "schema"."table" RENAME TO "select"',
'ALTER INDEX "foo" ON "schema"."table" RENAME TO "bar"',
- );
+ ];
}
/**
@@ -880,7 +861,7 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL()
*/
public function testReturnsGuidTypeDeclarationSQL()
{
- self::assertSame('UNIQUEIDENTIFIER', $this->_platform->getGuidTypeDeclarationSQL(array()));
+ self::assertSame('UNIQUEIDENTIFIER', $this->platform->getGuidTypeDeclarationSQL([]));
}
/**
@@ -888,9 +869,7 @@ public function testReturnsGuidTypeDeclarationSQL()
*/
public function getAlterTableRenameColumnSQL()
{
- return array(
- 'ALTER TABLE foo RENAME bar TO baz',
- );
+ return ['ALTER TABLE foo RENAME bar TO baz'];
}
/**
@@ -898,7 +877,7 @@ public function getAlterTableRenameColumnSQL()
*/
protected function getQuotesTableIdentifiersInAlterTableSQL()
{
- return array(
+ return [
'ALTER TABLE "foo" DROP FOREIGN KEY fk1',
'ALTER TABLE "foo" DROP FOREIGN KEY fk2',
'ALTER TABLE "foo" RENAME id TO war',
@@ -906,7 +885,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL()
'ALTER TABLE "foo" RENAME "table"',
'ALTER TABLE "table" ADD CONSTRAINT fk_add FOREIGN KEY (fk3) REFERENCES fk_table (id)',
'ALTER TABLE "table" ADD CONSTRAINT fk2 FOREIGN KEY (fk2) REFERENCES fk_table2 (id)',
- );
+ ];
}
/**
@@ -914,11 +893,11 @@ protected function getQuotesTableIdentifiersInAlterTableSQL()
*/
protected function getCommentOnColumnSQL()
{
- return array(
+ return [
'COMMENT ON COLUMN foo.bar IS \'comment\'',
'COMMENT ON COLUMN "Foo"."BAR" IS \'comment\'',
'COMMENT ON COLUMN "select"."from" IS \'comment\'',
- );
+ ];
}
/**
@@ -926,19 +905,17 @@ protected function getCommentOnColumnSQL()
*/
public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers()
{
- $table1 = new Table('"foo"', array(new Column('"bar"', Type::getType('integer'))));
- $table2 = new Table('"foo"', array(new Column('"bar"', Type::getType('integer'), array('comment' => 'baz'))));
+ $table1 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'))]);
+ $table2 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'), ['comment' => 'baz'])]);
$comparator = new Comparator();
$tableDiff = $comparator->diffTable($table1, $table2);
- self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
+ self::assertInstanceOf(TableDiff::class, $tableDiff);
self::assertSame(
- array(
- 'COMMENT ON COLUMN "foo"."bar" IS \'baz\'',
- ),
- $this->_platform->getAlterTableSQL($tableDiff)
+ ['COMMENT ON COLUMN "foo"."bar" IS \'baz\''],
+ $this->platform->getAlterTableSQL($tableDiff)
);
}
@@ -947,14 +924,14 @@ public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers()
*/
public function getReturnsForeignKeyReferentialActionSQL()
{
- return array(
- array('CASCADE', 'CASCADE'),
- array('SET NULL', 'SET NULL'),
- array('NO ACTION', 'RESTRICT'),
- array('RESTRICT', 'RESTRICT'),
- array('SET DEFAULT', 'SET DEFAULT'),
- array('CaScAdE', 'CASCADE'),
- );
+ return [
+ ['CASCADE', 'CASCADE'],
+ ['SET NULL', 'SET NULL'],
+ ['NO ACTION', 'RESTRICT'],
+ ['RESTRICT', 'RESTRICT'],
+ ['SET DEFAULT', 'SET DEFAULT'],
+ ['CaScAdE', 'CASCADE'],
+ ];
}
/**
@@ -994,9 +971,7 @@ protected function supportsInlineIndexDeclaration()
*/
protected function getAlterStringToFixedStringSQL()
{
- return array(
- 'ALTER TABLE mytable ALTER name CHAR(2) NOT NULL',
- );
+ return ['ALTER TABLE mytable ALTER name CHAR(2) NOT NULL'];
}
/**
@@ -1004,9 +979,7 @@ protected function getAlterStringToFixedStringSQL()
*/
protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
{
- return array(
- 'ALTER INDEX idx_foo ON mytable RENAME TO idx_foo_renamed',
- );
+ return ['ALTER INDEX idx_foo ON mytable RENAME TO idx_foo_renamed'];
}
/**
@@ -1016,7 +989,7 @@ public function testQuotesSchemaNameInListTableColumnsSQL()
{
self::assertContains(
"'Foo''Bar\\'",
- $this->_platform->getListTableColumnsSQL("Foo'Bar\\.baz_table"),
+ $this->platform->getListTableColumnsSQL("Foo'Bar\\.baz_table"),
'',
true
);
@@ -1027,7 +1000,7 @@ public function testQuotesSchemaNameInListTableColumnsSQL()
*/
public function testQuotesTableNameInListTableConstraintsSQL()
{
- self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\'", $this->platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true);
}
/**
@@ -1037,7 +1010,7 @@ public function testQuotesSchemaNameInListTableConstraintsSQL()
{
self::assertContains(
"'Foo''Bar\\'",
- $this->_platform->getListTableConstraintsSQL("Foo'Bar\\.baz_table"),
+ $this->platform->getListTableConstraintsSQL("Foo'Bar\\.baz_table"),
'',
true
);
@@ -1048,7 +1021,7 @@ public function testQuotesSchemaNameInListTableConstraintsSQL()
*/
public function testQuotesTableNameInListTableForeignKeysSQL()
{
- self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\'", $this->platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
}
/**
@@ -1058,7 +1031,7 @@ public function testQuotesSchemaNameInListTableForeignKeysSQL()
{
self::assertContains(
"'Foo''Bar\\'",
- $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\.baz_table"),
+ $this->platform->getListTableForeignKeysSQL("Foo'Bar\\.baz_table"),
'',
true
);
@@ -1069,7 +1042,7 @@ public function testQuotesSchemaNameInListTableForeignKeysSQL()
*/
public function testQuotesTableNameInListTableIndexesSQL()
{
- self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableIndexesSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\'", $this->platform->getListTableIndexesSQL("Foo'Bar\\"), '', true);
}
/**
@@ -1079,7 +1052,7 @@ public function testQuotesSchemaNameInListTableIndexesSQL()
{
self::assertContains(
"'Foo''Bar\\'",
- $this->_platform->getListTableIndexesSQL("Foo'Bar\\.baz_table"),
+ $this->platform->getListTableIndexesSQL("Foo'Bar\\.baz_table"),
'',
true
);
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php
index f1b93e0eb48..e42aaeb8eaf 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php
@@ -2,6 +2,8 @@
namespace Doctrine\Tests\DBAL\Platforms;
+use Doctrine\DBAL\Platforms\SQLAzurePlatform;
+use Doctrine\DBAL\Schema\Table;
use Doctrine\Tests\DbalTestCase;
/**
@@ -9,23 +11,21 @@
*/
class SQLAzurePlatformTest extends DbalTestCase
{
- /**
- * @var \Doctrine\DBAL\Platforms\SQLAzurePlatform
- */
+ /** @var SQLAzurePlatform */
private $platform;
protected function setUp()
{
- $this->platform = new \Doctrine\DBAL\Platforms\SQLAzurePlatform();
+ $this->platform = new SQLAzurePlatform();
}
public function testCreateFederatedOnTable()
{
- $table = new \Doctrine\DBAL\Schema\Table("tbl");
- $table->addColumn("id", "integer");
+ $table = new Table('tbl');
+ $table->addColumn('id', 'integer');
$table->addOption('azure.federatedOnDistributionName', 'TblId');
$table->addOption('azure.federatedOnColumnName', 'id');
- self::assertEquals(array('CREATE TABLE tbl (id INT NOT NULL) FEDERATED ON (TblId = id)'), $this->platform->getCreateTableSQL($table));
+ self::assertEquals(['CREATE TABLE tbl (id INT NOT NULL) FEDERATED ON (TblId = id)'], $this->platform->getCreateTableSQL($table));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php
index 3670c4a80a6..3083ab7b606 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php
@@ -8,11 +8,11 @@ class SQLServer2008PlatformTest extends AbstractSQLServerPlatformTestCase
{
public function createPlatform()
{
- return new SQLServer2008Platform;
+ return new SQLServer2008Platform();
}
public function testGeneratesTypeDeclarationForDateTimeTz()
{
- self::assertEquals('DATETIMEOFFSET(6)', $this->_platform->getDateTimeTzTypeDeclarationSQL([]));
+ self::assertEquals('DATETIMEOFFSET(6)', $this->platform->getDateTimeTzTypeDeclarationSQL([]));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php
index 69e0840b629..b908c427c28 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php
@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Platforms;
+use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Schema\Sequence;
@@ -9,17 +10,17 @@ class SQLServer2012PlatformTest extends AbstractSQLServerPlatformTestCase
{
public function createPlatform()
{
- return new SQLServer2012Platform;
+ return new SQLServer2012Platform();
}
public function testSupportsSequences()
{
- self::assertTrue($this->_platform->supportsSequences());
+ self::assertTrue($this->platform->supportsSequences());
}
public function testDoesNotPreferSequences()
{
- self::assertFalse($this->_platform->prefersSequences());
+ self::assertFalse($this->platform->prefersSequences());
}
public function testGeneratesSequenceSqlCommands()
@@ -27,95 +28,95 @@ public function testGeneratesSequenceSqlCommands()
$sequence = new Sequence('myseq', 20, 1);
self::assertEquals(
'CREATE SEQUENCE myseq START WITH 1 INCREMENT BY 20 MINVALUE 1',
- $this->_platform->getCreateSequenceSQL($sequence)
+ $this->platform->getCreateSequenceSQL($sequence)
);
self::assertEquals(
'ALTER SEQUENCE myseq INCREMENT BY 20',
- $this->_platform->getAlterSequenceSQL($sequence)
+ $this->platform->getAlterSequenceSQL($sequence)
);
self::assertEquals(
'DROP SEQUENCE myseq',
- $this->_platform->getDropSequenceSQL('myseq')
+ $this->platform->getDropSequenceSQL('myseq')
);
self::assertEquals(
- "SELECT NEXT VALUE FOR myseq",
- $this->_platform->getSequenceNextValSQL('myseq')
+ 'SELECT NEXT VALUE FOR myseq',
+ $this->platform->getSequenceNextValSQL('myseq')
);
}
public function testModifyLimitQuery()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
self::assertEquals('SELECT * FROM user ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql);
}
public function testModifyLimitQueryWithEmptyOffset()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10);
self::assertEquals('SELECT * FROM user ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql);
}
public function testModifyLimitQueryWithOffset()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10, 5);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10, 5);
self::assertEquals('SELECT * FROM user ORDER BY username DESC OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY', $sql);
}
public function testModifyLimitQueryWithAscOrderBy()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10);
self::assertEquals('SELECT * FROM user ORDER BY username ASC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql);
}
public function testModifyLimitQueryWithLowercaseOrderBy()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user order by username', 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user order by username', 10);
self::assertEquals('SELECT * FROM user order by username OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql);
}
public function testModifyLimitQueryWithDescOrderBy()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10);
self::assertEquals('SELECT * FROM user ORDER BY username DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql);
}
public function testModifyLimitQueryWithMultipleOrderBy()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC, usereamil ASC', 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC, usereamil ASC', 10);
self::assertEquals('SELECT * FROM user ORDER BY username DESC, usereamil ASC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql);
}
public function testModifyLimitQueryWithSubSelect()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result', 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result', 10);
self::assertEquals('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql);
}
public function testModifyLimitQueryWithSubSelectAndOrder()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY uname DESC', 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY uname DESC', 10);
self::assertEquals('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY uname DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql);
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM (SELECT u.id, u.name) dctrn_result ORDER BY name DESC', 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM (SELECT u.id, u.name) dctrn_result ORDER BY name DESC', 10);
self::assertEquals('SELECT * FROM (SELECT u.id, u.name) dctrn_result ORDER BY name DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql);
}
public function testModifyLimitQueryWithSubSelectAndMultipleOrder()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY uname DESC, uid ASC', 10, 5);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY uname DESC, uid ASC', 10, 5);
self::assertEquals('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY uname DESC, uid ASC OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY', $sql);
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM (SELECT u.id uid, u.name uname) dctrn_result ORDER BY uname DESC, uid ASC', 10, 5);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM (SELECT u.id uid, u.name uname) dctrn_result ORDER BY uname DESC, uid ASC', 10, 5);
self::assertEquals('SELECT * FROM (SELECT u.id uid, u.name uname) dctrn_result ORDER BY uname DESC, uid ASC OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY', $sql);
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM (SELECT u.id, u.name) dctrn_result ORDER BY name DESC, id ASC', 10, 5);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM (SELECT u.id, u.name) dctrn_result ORDER BY name DESC, id ASC', 10, 5);
self::assertEquals('SELECT * FROM (SELECT u.id, u.name) dctrn_result ORDER BY name DESC, id ASC OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY', $sql);
}
public function testModifyLimitQueryWithFromColumnNames()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT a.fromFoo, fromBar FROM foo', 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT a.fromFoo, fromBar FROM foo', 10);
self::assertEquals('SELECT a.fromFoo, fromBar FROM foo ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql);
}
@@ -124,19 +125,18 @@ public function testModifyLimitQueryWithFromColumnNames()
*/
public function testModifyLimitQueryWithExtraLongQuery()
{
- $query = 'SELECT table1.column1, table2.column2, table3.column3, table4.column4, table5.column5, table6.column6, table7.column7, table8.column8 FROM table1, table2, table3, table4, table5, table6, table7, table8 ';
- $query.= 'WHERE (table1.column1 = table2.column2) AND (table1.column1 = table3.column3) AND (table1.column1 = table4.column4) AND (table1.column1 = table5.column5) AND (table1.column1 = table6.column6) AND (table1.column1 = table7.column7) AND (table1.column1 = table8.column8) AND (table2.column2 = table3.column3) AND (table2.column2 = table4.column4) AND (table2.column2 = table5.column5) AND (table2.column2 = table6.column6) ';
- $query.= 'AND (table2.column2 = table7.column7) AND (table2.column2 = table8.column8) AND (table3.column3 = table4.column4) AND (table3.column3 = table5.column5) AND (table3.column3 = table6.column6) AND (table3.column3 = table7.column7) AND (table3.column3 = table8.column8) AND (table4.column4 = table5.column5) AND (table4.column4 = table6.column6) AND (table4.column4 = table7.column7) AND (table4.column4 = table8.column8) ';
- $query.= 'AND (table5.column5 = table6.column6) AND (table5.column5 = table7.column7) AND (table5.column5 = table8.column8) AND (table6.column6 = table7.column7) AND (table6.column6 = table8.column8) AND (table7.column7 = table8.column8)';
+ $query = 'SELECT table1.column1, table2.column2, table3.column3, table4.column4, table5.column5, table6.column6, table7.column7, table8.column8 FROM table1, table2, table3, table4, table5, table6, table7, table8 ';
+ $query .= 'WHERE (table1.column1 = table2.column2) AND (table1.column1 = table3.column3) AND (table1.column1 = table4.column4) AND (table1.column1 = table5.column5) AND (table1.column1 = table6.column6) AND (table1.column1 = table7.column7) AND (table1.column1 = table8.column8) AND (table2.column2 = table3.column3) AND (table2.column2 = table4.column4) AND (table2.column2 = table5.column5) AND (table2.column2 = table6.column6) ';
+ $query .= 'AND (table2.column2 = table7.column7) AND (table2.column2 = table8.column8) AND (table3.column3 = table4.column4) AND (table3.column3 = table5.column5) AND (table3.column3 = table6.column6) AND (table3.column3 = table7.column7) AND (table3.column3 = table8.column8) AND (table4.column4 = table5.column5) AND (table4.column4 = table6.column6) AND (table4.column4 = table7.column7) AND (table4.column4 = table8.column8) ';
+ $query .= 'AND (table5.column5 = table6.column6) AND (table5.column5 = table7.column7) AND (table5.column5 = table8.column8) AND (table6.column6 = table7.column7) AND (table6.column6 = table8.column8) AND (table7.column7 = table8.column8)';
- $sql = $this->_platform->modifyLimitQuery($query, 10);
-
- $expected = 'SELECT table1.column1, table2.column2, table3.column3, table4.column4, table5.column5, table6.column6, table7.column7, table8.column8 FROM table1, table2, table3, table4, table5, table6, table7, table8 ';
- $expected.= 'WHERE (table1.column1 = table2.column2) AND (table1.column1 = table3.column3) AND (table1.column1 = table4.column4) AND (table1.column1 = table5.column5) AND (table1.column1 = table6.column6) AND (table1.column1 = table7.column7) AND (table1.column1 = table8.column8) AND (table2.column2 = table3.column3) AND (table2.column2 = table4.column4) AND (table2.column2 = table5.column5) AND (table2.column2 = table6.column6) ';
- $expected.= 'AND (table2.column2 = table7.column7) AND (table2.column2 = table8.column8) AND (table3.column3 = table4.column4) AND (table3.column3 = table5.column5) AND (table3.column3 = table6.column6) AND (table3.column3 = table7.column7) AND (table3.column3 = table8.column8) AND (table4.column4 = table5.column5) AND (table4.column4 = table6.column6) AND (table4.column4 = table7.column7) AND (table4.column4 = table8.column8) ';
- $expected.= 'AND (table5.column5 = table6.column6) AND (table5.column5 = table7.column7) AND (table5.column5 = table8.column8) AND (table6.column6 = table7.column7) AND (table6.column6 = table8.column8) AND (table7.column7 = table8.column8) ';
- $expected.= 'ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY';
+ $sql = $this->platform->modifyLimitQuery($query, 10);
+ $expected = 'SELECT table1.column1, table2.column2, table3.column3, table4.column4, table5.column5, table6.column6, table7.column7, table8.column8 FROM table1, table2, table3, table4, table5, table6, table7, table8 ';
+ $expected .= 'WHERE (table1.column1 = table2.column2) AND (table1.column1 = table3.column3) AND (table1.column1 = table4.column4) AND (table1.column1 = table5.column5) AND (table1.column1 = table6.column6) AND (table1.column1 = table7.column7) AND (table1.column1 = table8.column8) AND (table2.column2 = table3.column3) AND (table2.column2 = table4.column4) AND (table2.column2 = table5.column5) AND (table2.column2 = table6.column6) ';
+ $expected .= 'AND (table2.column2 = table7.column7) AND (table2.column2 = table8.column8) AND (table3.column3 = table4.column4) AND (table3.column3 = table5.column5) AND (table3.column3 = table6.column6) AND (table3.column3 = table7.column7) AND (table3.column3 = table8.column8) AND (table4.column4 = table5.column5) AND (table4.column4 = table6.column6) AND (table4.column4 = table7.column7) AND (table4.column4 = table8.column8) ';
+ $expected .= 'AND (table5.column5 = table6.column6) AND (table5.column5 = table7.column7) AND (table5.column5 = table8.column8) AND (table6.column6 = table7.column7) AND (table6.column6 = table8.column8) AND (table7.column7 = table8.column8) ';
+ $expected .= 'ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY';
self::assertEquals($expected, $sql);
}
@@ -148,7 +148,7 @@ public function testModifyLimitQueryWithOrderByClause()
{
$sql = 'SELECT m0_.NOMBRE AS NOMBRE0, m0_.FECHAINICIO AS FECHAINICIO1, m0_.FECHAFIN AS FECHAFIN2 FROM MEDICION m0_ WITH (NOLOCK) INNER JOIN ESTUDIO e1_ ON m0_.ESTUDIO_ID = e1_.ID INNER JOIN CLIENTE c2_ ON e1_.CLIENTE_ID = c2_.ID INNER JOIN USUARIO u3_ ON c2_.ID = u3_.CLIENTE_ID WHERE u3_.ID = ? ORDER BY m0_.FECHAINICIO DESC';
$expected = 'SELECT m0_.NOMBRE AS NOMBRE0, m0_.FECHAINICIO AS FECHAINICIO1, m0_.FECHAFIN AS FECHAFIN2 FROM MEDICION m0_ WITH (NOLOCK) INNER JOIN ESTUDIO e1_ ON m0_.ESTUDIO_ID = e1_.ID INNER JOIN CLIENTE c2_ ON e1_.CLIENTE_ID = c2_.ID INNER JOIN USUARIO u3_ ON c2_.ID = u3_.CLIENTE_ID WHERE u3_.ID = ? ORDER BY m0_.FECHAINICIO DESC OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY';
- $actual = $this->_platform->modifyLimitQuery($sql, 10, 5);
+ $actual = $this->platform->modifyLimitQuery($sql, 10, 5);
self::assertEquals($expected, $actual);
}
@@ -158,27 +158,27 @@ public function testModifyLimitQueryWithOrderByClause()
*/
public function testModifyLimitQueryWithSubSelectInSelectList()
{
- $sql = $this->_platform->modifyLimitQuery(
- "SELECT " .
- "u.id, " .
- "(u.foo/2) foodiv, " .
- "CONCAT(u.bar, u.baz) barbaz, " .
- "(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count " .
- "FROM user u " .
+ $sql = $this->platform->modifyLimitQuery(
+ 'SELECT ' .
+ 'u.id, ' .
+ '(u.foo/2) foodiv, ' .
+ 'CONCAT(u.bar, u.baz) barbaz, ' .
+ '(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count ' .
+ 'FROM user u ' .
"WHERE u.status = 'disabled'",
10
);
self::assertEquals(
- "SELECT " .
- "u.id, " .
- "(u.foo/2) foodiv, " .
- "CONCAT(u.bar, u.baz) barbaz, " .
- "(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count " .
- "FROM user u " .
+ 'SELECT ' .
+ 'u.id, ' .
+ '(u.foo/2) foodiv, ' .
+ 'CONCAT(u.bar, u.baz) barbaz, ' .
+ '(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count ' .
+ 'FROM user u ' .
"WHERE u.status = 'disabled' " .
- "ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY",
+ 'ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY',
$sql
);
}
@@ -188,29 +188,29 @@ public function testModifyLimitQueryWithSubSelectInSelectList()
*/
public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause()
{
- $sql = $this->_platform->modifyLimitQuery(
- "SELECT " .
- "u.id, " .
- "(u.foo/2) foodiv, " .
- "CONCAT(u.bar, u.baz) barbaz, " .
- "(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count " .
- "FROM user u " .
+ $sql = $this->platform->modifyLimitQuery(
+ 'SELECT ' .
+ 'u.id, ' .
+ '(u.foo/2) foodiv, ' .
+ 'CONCAT(u.bar, u.baz) barbaz, ' .
+ '(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count ' .
+ 'FROM user u ' .
"WHERE u.status = 'disabled' " .
- "ORDER BY u.username DESC",
+ 'ORDER BY u.username DESC',
10,
5
);
self::assertEquals(
- "SELECT " .
- "u.id, " .
- "(u.foo/2) foodiv, " .
- "CONCAT(u.bar, u.baz) barbaz, " .
- "(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count " .
- "FROM user u " .
+ 'SELECT ' .
+ 'u.id, ' .
+ '(u.foo/2) foodiv, ' .
+ 'CONCAT(u.bar, u.baz) barbaz, ' .
+ '(SELECT (SELECT COUNT(*) FROM login l WHERE l.profile_id = p.id) FROM profile p WHERE p.user_id = u.id) login_count ' .
+ 'FROM user u ' .
"WHERE u.status = 'disabled' " .
- "ORDER BY u.username DESC " .
- "OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY",
+ 'ORDER BY u.username DESC ' .
+ 'OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY',
$sql
);
}
@@ -220,155 +220,155 @@ public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause()
*/
public function testModifyLimitQueryWithAggregateFunctionInOrderByClause()
{
- $sql = $this->_platform->modifyLimitQuery(
- "SELECT " .
- "MAX(heading_id) aliased, " .
- "code " .
- "FROM operator_model_operator " .
- "GROUP BY code " .
- "ORDER BY MAX(heading_id) DESC",
+ $sql = $this->platform->modifyLimitQuery(
+ 'SELECT ' .
+ 'MAX(heading_id) aliased, ' .
+ 'code ' .
+ 'FROM operator_model_operator ' .
+ 'GROUP BY code ' .
+ 'ORDER BY MAX(heading_id) DESC',
1,
0
);
self::assertEquals(
- "SELECT " .
- "MAX(heading_id) aliased, " .
- "code " .
- "FROM operator_model_operator " .
- "GROUP BY code " .
- "ORDER BY MAX(heading_id) DESC " .
- "OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY",
+ 'SELECT ' .
+ 'MAX(heading_id) aliased, ' .
+ 'code ' .
+ 'FROM operator_model_operator ' .
+ 'GROUP BY code ' .
+ 'ORDER BY MAX(heading_id) DESC ' .
+ 'OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY',
$sql
);
}
public function testModifyLimitQueryWithFromSubquery()
{
- $sql = $this->_platform->modifyLimitQuery("SELECT DISTINCT id_0 FROM (SELECT k0_.id AS id_0 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result", 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT DISTINCT id_0 FROM (SELECT k0_.id AS id_0 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result', 10);
- $expected = "SELECT DISTINCT id_0 FROM (SELECT k0_.id AS id_0 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result ORDER BY 1 OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY";
+ $expected = 'SELECT DISTINCT id_0 FROM (SELECT k0_.id AS id_0 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result ORDER BY 1 OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY';
self::assertEquals($sql, $expected);
}
public function testModifyLimitQueryWithFromSubqueryAndOrder()
{
- $sql = $this->_platform->modifyLimitQuery("SELECT DISTINCT id_0, value_1 FROM (SELECT k0_.id AS id_0, k0_.value AS value_1 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result ORDER BY value_1 DESC", 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT DISTINCT id_0, value_1 FROM (SELECT k0_.id AS id_0, k0_.value AS value_1 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result ORDER BY value_1 DESC', 10);
- $expected = "SELECT DISTINCT id_0, value_1 FROM (SELECT k0_.id AS id_0, k0_.value AS value_1 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result ORDER BY value_1 DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY";
+ $expected = 'SELECT DISTINCT id_0, value_1 FROM (SELECT k0_.id AS id_0, k0_.value AS value_1 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result ORDER BY value_1 DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY';
self::assertEquals($sql, $expected);
}
public function testModifyLimitQueryWithComplexOrderByExpression()
{
- $sql = $this->_platform->modifyLimitQuery("SELECT * FROM table ORDER BY (table.x * table.y) DESC", 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM table ORDER BY (table.x * table.y) DESC', 10);
- $expected = "SELECT * FROM table ORDER BY (table.x * table.y) DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY";
+ $expected = 'SELECT * FROM table ORDER BY (table.x * table.y) DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY';
self::assertEquals($sql, $expected);
}
/**
- * @throws \Doctrine\DBAL\DBALException
+ * @throws DBALException
*/
public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBaseTable()
{
- $querySql = "SELECT DISTINCT id_0, name_1 "
- . "FROM ("
- . "SELECT t1.id AS id_0, t2.name AS name_1 "
- . "FROM table_parent t1 "
- . "LEFT JOIN join_table t2 ON t1.id = t2.table_id"
- . ") dctrn_result "
- . "ORDER BY id_0 ASC";
- $alteredSql = "SELECT DISTINCT id_0, name_1 "
- . "FROM ("
- . "SELECT t1.id AS id_0, t2.name AS name_1 "
- . "FROM table_parent t1 "
- . "LEFT JOIN join_table t2 ON t1.id = t2.table_id"
- . ") dctrn_result "
- . "ORDER BY id_0 ASC OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY";
- $sql = $this->_platform->modifyLimitQuery($querySql, 5);
+ $querySql = 'SELECT DISTINCT id_0, name_1 '
+ . 'FROM ('
+ . 'SELECT t1.id AS id_0, t2.name AS name_1 '
+ . 'FROM table_parent t1 '
+ . 'LEFT JOIN join_table t2 ON t1.id = t2.table_id'
+ . ') dctrn_result '
+ . 'ORDER BY id_0 ASC';
+ $alteredSql = 'SELECT DISTINCT id_0, name_1 '
+ . 'FROM ('
+ . 'SELECT t1.id AS id_0, t2.name AS name_1 '
+ . 'FROM table_parent t1 '
+ . 'LEFT JOIN join_table t2 ON t1.id = t2.table_id'
+ . ') dctrn_result '
+ . 'ORDER BY id_0 ASC OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY';
+ $sql = $this->platform->modifyLimitQuery($querySql, 5);
self::assertEquals($alteredSql, $sql);
}
/**
- * @throws \Doctrine\DBAL\DBALException
+ * @throws DBALException
*/
public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoinTable()
{
- $querySql = "SELECT DISTINCT id_0, name_1 "
- . "FROM ("
- . "SELECT t1.id AS id_0, t2.name AS name_1 "
- . "FROM table_parent t1 "
- . "LEFT JOIN join_table t2 ON t1.id = t2.table_id"
- . ") dctrn_result "
- . "ORDER BY name_1 ASC";
- $alteredSql = "SELECT DISTINCT id_0, name_1 "
- . "FROM ("
- . "SELECT t1.id AS id_0, t2.name AS name_1 "
- . "FROM table_parent t1 "
- . "LEFT JOIN join_table t2 ON t1.id = t2.table_id"
- . ") dctrn_result "
- . "ORDER BY name_1 ASC OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY";
- $sql = $this->_platform->modifyLimitQuery($querySql, 5);
+ $querySql = 'SELECT DISTINCT id_0, name_1 '
+ . 'FROM ('
+ . 'SELECT t1.id AS id_0, t2.name AS name_1 '
+ . 'FROM table_parent t1 '
+ . 'LEFT JOIN join_table t2 ON t1.id = t2.table_id'
+ . ') dctrn_result '
+ . 'ORDER BY name_1 ASC';
+ $alteredSql = 'SELECT DISTINCT id_0, name_1 '
+ . 'FROM ('
+ . 'SELECT t1.id AS id_0, t2.name AS name_1 '
+ . 'FROM table_parent t1 '
+ . 'LEFT JOIN join_table t2 ON t1.id = t2.table_id'
+ . ') dctrn_result '
+ . 'ORDER BY name_1 ASC OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY';
+ $sql = $this->platform->modifyLimitQuery($querySql, 5);
self::assertEquals($alteredSql, $sql);
}
/**
- * @throws \Doctrine\DBAL\DBALException
+ * @throws DBALException
*/
public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBothTables()
{
- $querySql = "SELECT DISTINCT id_0, name_1, foo_2 "
- . "FROM ("
- . "SELECT t1.id AS id_0, t2.name AS name_1, t2.foo AS foo_2 "
- . "FROM table_parent t1 "
- . "LEFT JOIN join_table t2 ON t1.id = t2.table_id"
- . ") dctrn_result "
- . "ORDER BY name_1 ASC, foo_2 DESC";
- $alteredSql = "SELECT DISTINCT id_0, name_1, foo_2 "
- . "FROM ("
- . "SELECT t1.id AS id_0, t2.name AS name_1, t2.foo AS foo_2 "
- . "FROM table_parent t1 "
- . "LEFT JOIN join_table t2 ON t1.id = t2.table_id"
- . ") dctrn_result "
- . "ORDER BY name_1 ASC, foo_2 DESC OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY";
- $sql = $this->_platform->modifyLimitQuery($querySql, 5);
+ $querySql = 'SELECT DISTINCT id_0, name_1, foo_2 '
+ . 'FROM ('
+ . 'SELECT t1.id AS id_0, t2.name AS name_1, t2.foo AS foo_2 '
+ . 'FROM table_parent t1 '
+ . 'LEFT JOIN join_table t2 ON t1.id = t2.table_id'
+ . ') dctrn_result '
+ . 'ORDER BY name_1 ASC, foo_2 DESC';
+ $alteredSql = 'SELECT DISTINCT id_0, name_1, foo_2 '
+ . 'FROM ('
+ . 'SELECT t1.id AS id_0, t2.name AS name_1, t2.foo AS foo_2 '
+ . 'FROM table_parent t1 '
+ . 'LEFT JOIN join_table t2 ON t1.id = t2.table_id'
+ . ') dctrn_result '
+ . 'ORDER BY name_1 ASC, foo_2 DESC OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY';
+ $sql = $this->platform->modifyLimitQuery($querySql, 5);
self::assertEquals($alteredSql, $sql);
}
public function testModifyLimitSubquerySimple()
{
- $querySql = "SELECT DISTINCT id_0 FROM "
- . "(SELECT k0_.id AS id_0, k0_.field AS field_1 "
- . "FROM key_table k0_ WHERE (k0_.where_field IN (1))) dctrn_result";
- $alteredSql = "SELECT DISTINCT id_0 FROM (SELECT k0_.id AS id_0, k0_.field AS field_1 "
- . "FROM key_table k0_ WHERE (k0_.where_field IN (1))) dctrn_result ORDER BY 1 OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY";
- $sql = $this->_platform->modifyLimitQuery($querySql, 20);
+ $querySql = 'SELECT DISTINCT id_0 FROM '
+ . '(SELECT k0_.id AS id_0, k0_.field AS field_1 '
+ . 'FROM key_table k0_ WHERE (k0_.where_field IN (1))) dctrn_result';
+ $alteredSql = 'SELECT DISTINCT id_0 FROM (SELECT k0_.id AS id_0, k0_.field AS field_1 '
+ . 'FROM key_table k0_ WHERE (k0_.where_field IN (1))) dctrn_result ORDER BY 1 OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY';
+ $sql = $this->platform->modifyLimitQuery($querySql, 20);
self::assertEquals($alteredSql, $sql);
}
public function testModifyLimitQueryWithTopNSubQueryWithOrderBy()
{
- $querySql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC)';
+ $querySql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC)';
$expectedSql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC) ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10);
self::assertEquals($expectedSql, $sql);
- $querySql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC) ORDER BY t.data2 DESC';
+ $querySql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC) ORDER BY t.data2 DESC';
$expectedSql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC) ORDER BY t.data2 DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY';
- $sql = $this->_platform->modifyLimitQuery($querySql, 10);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10);
self::assertEquals($expectedSql, $sql);
}
public function testModifyLimitQueryWithNewlineBeforeOrderBy()
{
- $querySql = "SELECT * FROM test\nORDER BY col DESC";
+ $querySql = "SELECT * FROM test\nORDER BY col DESC";
$expectedSql = "SELECT * FROM test\nORDER BY col DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY";
- $sql = $this->_platform->modifyLimitQuery($querySql, 10);
+ $sql = $this->platform->modifyLimitQuery($querySql, 10);
self::assertEquals($expectedSql, $sql);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
index f8b42f61819..ed2842813aa 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
@@ -7,10 +7,9 @@
class SQLServerPlatformTest extends AbstractSQLServerPlatformTestCase
{
-
public function createPlatform()
{
- return new SQLServerPlatform;
+ return new SQLServerPlatform();
}
/**
@@ -22,7 +21,7 @@ public function testAppendsLockHint($lockMode, $lockHint)
$fromClause = 'FROM users';
$expectedResult = $fromClause . $lockHint;
- self::assertSame($expectedResult, $this->_platform->appendLockHint($fromClause, $lockMode));
+ self::assertSame($expectedResult, $this->platform->appendLockHint($fromClause, $lockMode));
}
/**
@@ -31,20 +30,20 @@ public function testAppendsLockHint($lockMode, $lockHint)
*/
public function testScrubInnerOrderBy($query, $limit, $offset, $expectedResult)
{
- self::assertSame($expectedResult, $this->_platform->modifyLimitQuery($query, $limit, $offset));
+ self::assertSame($expectedResult, $this->platform->modifyLimitQuery($query, $limit, $offset));
}
public function getLockHints()
{
- return array(
- array(null, ''),
- array(false, ''),
- array(true, ''),
- array(LockMode::NONE, ' WITH (NOLOCK)'),
- array(LockMode::OPTIMISTIC, ''),
- array(LockMode::PESSIMISTIC_READ, ' WITH (HOLDLOCK, ROWLOCK)'),
- array(LockMode::PESSIMISTIC_WRITE, ' WITH (UPDLOCK, ROWLOCK)'),
- );
+ return [
+ [null, ''],
+ [false, ''],
+ [true, ''],
+ [LockMode::NONE, ' WITH (NOLOCK)'],
+ [LockMode::OPTIMISTIC, ''],
+ [LockMode::PESSIMISTIC_READ, ' WITH (HOLDLOCK, ROWLOCK)'],
+ [LockMode::PESSIMISTIC_WRITE, ' WITH (UPDLOCK, ROWLOCK)'],
+ ];
}
public function getModifyLimitQueries()
diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
index 3975b8fd2c7..f2e12ae7b22 100644
--- a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
+++ b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
@@ -14,7 +14,7 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
{
public function createPlatform()
{
- return new SqlitePlatform;
+ return new SqlitePlatform();
}
public function getGenerateTableSql()
@@ -24,49 +24,49 @@ public function getGenerateTableSql()
public function getGenerateTableWithMultiColumnUniqueIndexSql()
{
- return array(
+ return [
'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)',
'CREATE UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA ON test (foo, bar)',
- );
+ ];
}
public function testGeneratesSqlSnippets()
{
- self::assertEquals('REGEXP', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct');
- self::assertEquals('SUBSTR(column, 5, LENGTH(column))', $this->_platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct');
- self::assertEquals('SUBSTR(column, 0, 5)', $this->_platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct');
+ self::assertEquals('REGEXP', $this->platform->getRegexpExpression(), 'Regular expression operator is not correct');
+ self::assertEquals('SUBSTR(column, 5, LENGTH(column))', $this->platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct');
+ self::assertEquals('SUBSTR(column, 0, 5)', $this->platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct');
}
public function testGeneratesTransactionCommands()
{
self::assertEquals(
'PRAGMA read_uncommitted = 0',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_UNCOMMITTED)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_UNCOMMITTED)
);
self::assertEquals(
'PRAGMA read_uncommitted = 1',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_COMMITTED)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::READ_COMMITTED)
);
self::assertEquals(
'PRAGMA read_uncommitted = 1',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::REPEATABLE_READ)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::REPEATABLE_READ)
);
self::assertEquals(
'PRAGMA read_uncommitted = 1',
- $this->_platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::SERIALIZABLE)
+ $this->platform->getSetTransactionIsolationSQL(TransactionIsolationLevel::SERIALIZABLE)
);
}
public function testPrefersIdentityColumns()
{
- self::assertTrue($this->_platform->prefersIdentityColumns());
+ self::assertTrue($this->platform->prefersIdentityColumns());
}
public function testIgnoresUnsignedIntegerDeclarationForAutoIncrementalIntegers()
{
self::assertSame(
'INTEGER PRIMARY KEY AUTOINCREMENT',
- $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true, 'unsigned' => true))
+ $this->platform->getIntegerTypeDeclarationSQL(['autoincrement' => true, 'unsigned' => true])
);
}
@@ -78,24 +78,25 @@ public function testGeneratesTypeDeclarationForTinyIntegers()
{
self::assertEquals(
'TINYINT',
- $this->_platform->getTinyIntTypeDeclarationSQL(array())
+ $this->platform->getTinyIntTypeDeclarationSQL([])
);
self::assertEquals(
'INTEGER PRIMARY KEY AUTOINCREMENT',
- $this->_platform->getTinyIntTypeDeclarationSQL(array('autoincrement' => true))
+ $this->platform->getTinyIntTypeDeclarationSQL(['autoincrement' => true])
);
self::assertEquals(
'INTEGER PRIMARY KEY AUTOINCREMENT',
- $this->_platform->getTinyIntTypeDeclarationSQL(
- array('autoincrement' => true, 'primary' => true))
+ $this->platform->getTinyIntTypeDeclarationSQL(
+ ['autoincrement' => true, 'primary' => true]
+ )
);
self::assertEquals(
'TINYINT',
- $this->_platform->getTinyIntTypeDeclarationSQL(array('unsigned' => false))
+ $this->platform->getTinyIntTypeDeclarationSQL(['unsigned' => false])
);
self::assertEquals(
'TINYINT UNSIGNED',
- $this->_platform->getTinyIntTypeDeclarationSQL(array('unsigned' => true))
+ $this->platform->getTinyIntTypeDeclarationSQL(['unsigned' => true])
);
}
@@ -107,28 +108,29 @@ public function testGeneratesTypeDeclarationForSmallIntegers()
{
self::assertEquals(
'SMALLINT',
- $this->_platform->getSmallIntTypeDeclarationSQL(array())
+ $this->platform->getSmallIntTypeDeclarationSQL([])
);
self::assertEquals(
'INTEGER PRIMARY KEY AUTOINCREMENT',
- $this->_platform->getSmallIntTypeDeclarationSQL(array('autoincrement' => true))
+ $this->platform->getSmallIntTypeDeclarationSQL(['autoincrement' => true])
);
self::assertEquals(
'INTEGER PRIMARY KEY AUTOINCREMENT',
- $this->_platform->getTinyIntTypeDeclarationSQL(array('autoincrement' => true, 'unsigned' => true))
+ $this->platform->getTinyIntTypeDeclarationSQL(['autoincrement' => true, 'unsigned' => true])
);
self::assertEquals(
'INTEGER PRIMARY KEY AUTOINCREMENT',
- $this->_platform->getSmallIntTypeDeclarationSQL(
- array('autoincrement' => true, 'primary' => true))
+ $this->platform->getSmallIntTypeDeclarationSQL(
+ ['autoincrement' => true, 'primary' => true]
+ )
);
self::assertEquals(
'SMALLINT',
- $this->_platform->getSmallIntTypeDeclarationSQL(array('unsigned' => false))
+ $this->platform->getSmallIntTypeDeclarationSQL(['unsigned' => false])
);
self::assertEquals(
'SMALLINT UNSIGNED',
- $this->_platform->getSmallIntTypeDeclarationSQL(array('unsigned' => true))
+ $this->platform->getSmallIntTypeDeclarationSQL(['unsigned' => true])
);
}
@@ -140,28 +142,29 @@ public function testGeneratesTypeDeclarationForMediumIntegers()
{
self::assertEquals(
'MEDIUMINT',
- $this->_platform->getMediumIntTypeDeclarationSQL(array())
+ $this->platform->getMediumIntTypeDeclarationSQL([])
);
self::assertEquals(
'INTEGER PRIMARY KEY AUTOINCREMENT',
- $this->_platform->getMediumIntTypeDeclarationSQL(array('autoincrement' => true))
+ $this->platform->getMediumIntTypeDeclarationSQL(['autoincrement' => true])
);
self::assertEquals(
'INTEGER PRIMARY KEY AUTOINCREMENT',
- $this->_platform->getMediumIntTypeDeclarationSQL(array('autoincrement' => true, 'unsigned' => true))
+ $this->platform->getMediumIntTypeDeclarationSQL(['autoincrement' => true, 'unsigned' => true])
);
self::assertEquals(
'INTEGER PRIMARY KEY AUTOINCREMENT',
- $this->_platform->getMediumIntTypeDeclarationSQL(
- array('autoincrement' => true, 'primary' => true))
+ $this->platform->getMediumIntTypeDeclarationSQL(
+ ['autoincrement' => true, 'primary' => true]
+ )
);
self::assertEquals(
'MEDIUMINT',
- $this->_platform->getMediumIntTypeDeclarationSQL(array('unsigned' => false))
+ $this->platform->getMediumIntTypeDeclarationSQL(['unsigned' => false])
);
self::assertEquals(
'MEDIUMINT UNSIGNED',
- $this->_platform->getMediumIntTypeDeclarationSQL(array('unsigned' => true))
+ $this->platform->getMediumIntTypeDeclarationSQL(['unsigned' => true])
);
}
@@ -169,28 +172,29 @@ public function testGeneratesTypeDeclarationForIntegers()
{
self::assertEquals(
'INTEGER',
- $this->_platform->getIntegerTypeDeclarationSQL(array())
+ $this->platform->getIntegerTypeDeclarationSQL([])
);
self::assertEquals(
'INTEGER PRIMARY KEY AUTOINCREMENT',
- $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true))
+ $this->platform->getIntegerTypeDeclarationSQL(['autoincrement' => true])
);
self::assertEquals(
'INTEGER PRIMARY KEY AUTOINCREMENT',
- $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true, 'unsigned' => true))
+ $this->platform->getIntegerTypeDeclarationSQL(['autoincrement' => true, 'unsigned' => true])
);
self::assertEquals(
'INTEGER PRIMARY KEY AUTOINCREMENT',
- $this->_platform->getIntegerTypeDeclarationSQL(
- array('autoincrement' => true, 'primary' => true))
+ $this->platform->getIntegerTypeDeclarationSQL(
+ ['autoincrement' => true, 'primary' => true]
+ )
);
self::assertEquals(
'INTEGER',
- $this->_platform->getIntegerTypeDeclarationSQL(array('unsigned' => false))
+ $this->platform->getIntegerTypeDeclarationSQL(['unsigned' => false])
);
self::assertEquals(
'INTEGER UNSIGNED',
- $this->_platform->getIntegerTypeDeclarationSQL(array('unsigned' => true))
+ $this->platform->getIntegerTypeDeclarationSQL(['unsigned' => true])
);
}
@@ -202,28 +206,29 @@ public function testGeneratesTypeDeclarationForBigIntegers()
{
self::assertEquals(
'BIGINT',
- $this->_platform->getBigIntTypeDeclarationSQL(array())
+ $this->platform->getBigIntTypeDeclarationSQL([])
);
self::assertEquals(
'INTEGER PRIMARY KEY AUTOINCREMENT',
- $this->_platform->getBigIntTypeDeclarationSQL(array('autoincrement' => true))
+ $this->platform->getBigIntTypeDeclarationSQL(['autoincrement' => true])
);
self::assertEquals(
'INTEGER PRIMARY KEY AUTOINCREMENT',
- $this->_platform->getBigIntTypeDeclarationSQL(array('autoincrement' => true, 'unsigned' => true))
+ $this->platform->getBigIntTypeDeclarationSQL(['autoincrement' => true, 'unsigned' => true])
);
self::assertEquals(
'INTEGER PRIMARY KEY AUTOINCREMENT',
- $this->_platform->getBigIntTypeDeclarationSQL(
- array('autoincrement' => true, 'primary' => true))
+ $this->platform->getBigIntTypeDeclarationSQL(
+ ['autoincrement' => true, 'primary' => true]
+ )
);
self::assertEquals(
'BIGINT',
- $this->_platform->getBigIntTypeDeclarationSQL(array('unsigned' => false))
+ $this->platform->getBigIntTypeDeclarationSQL(['unsigned' => false])
);
self::assertEquals(
'BIGINT UNSIGNED',
- $this->_platform->getBigIntTypeDeclarationSQL(array('unsigned' => true))
+ $this->platform->getBigIntTypeDeclarationSQL(['unsigned' => true])
);
}
@@ -231,17 +236,18 @@ public function testGeneratesTypeDeclarationForStrings()
{
self::assertEquals(
'CHAR(10)',
- $this->_platform->getVarcharTypeDeclarationSQL(
- array('length' => 10, 'fixed' => true))
+ $this->platform->getVarcharTypeDeclarationSQL(
+ ['length' => 10, 'fixed' => true]
+ )
);
self::assertEquals(
'VARCHAR(50)',
- $this->_platform->getVarcharTypeDeclarationSQL(array('length' => 50)),
+ $this->platform->getVarcharTypeDeclarationSQL(['length' => 50]),
'Variable string declaration is not correct'
);
self::assertEquals(
'VARCHAR(255)',
- $this->_platform->getVarcharTypeDeclarationSQL(array()),
+ $this->platform->getVarcharTypeDeclarationSQL([]),
'Long string declaration is not correct'
);
}
@@ -279,32 +285,32 @@ public function getGenerateForeignKeySql()
public function testModifyLimitQuery()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0);
self::assertEquals('SELECT * FROM user LIMIT 10', $sql);
}
public function testModifyLimitQueryWithEmptyOffset()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10);
self::assertEquals('SELECT * FROM user LIMIT 10', $sql);
}
public function testModifyLimitQueryWithOffsetAndEmptyLimit()
{
- $sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', null, 10);
+ $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', null, 10);
self::assertEquals('SELECT * FROM user LIMIT -1 OFFSET 10', $sql);
}
public function getGenerateAlterTableSql()
{
- return array(
- "CREATE TEMPORARY TABLE __temp__mytable AS SELECT id, bar, bloo FROM mytable",
- "DROP TABLE mytable",
+ return [
+ 'CREATE TEMPORARY TABLE __temp__mytable AS SELECT id, bar, bloo FROM mytable',
+ 'DROP TABLE mytable',
"CREATE TABLE mytable (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, baz VARCHAR(255) DEFAULT 'def' NOT NULL, bloo BOOLEAN DEFAULT '0' NOT NULL, quota INTEGER DEFAULT NULL)",
- "INSERT INTO mytable (id, baz, bloo) SELECT id, bar, bloo FROM __temp__mytable",
- "DROP TABLE __temp__mytable",
- "ALTER TABLE mytable RENAME TO userlist",
- );
+ 'INSERT INTO mytable (id, baz, bloo) SELECT id, bar, bloo FROM __temp__mytable',
+ 'DROP TABLE __temp__mytable',
+ 'ALTER TABLE mytable RENAME TO userlist',
+ ];
}
/**
@@ -312,11 +318,11 @@ public function getGenerateAlterTableSql()
*/
public function testGenerateTableSqlShouldNotAutoQuotePrimaryKey()
{
- $table = new \Doctrine\DBAL\Schema\Table('test');
- $table->addColumn('"like"', 'integer', array('notnull' => true, 'autoincrement' => true));
- $table->setPrimaryKey(array('"like"'));
+ $table = new Table('test');
+ $table->addColumn('"like"', 'integer', ['notnull' => true, 'autoincrement' => true]);
+ $table->setPrimaryKey(['"like"']);
- $createTableSQL = $this->_platform->getCreateTableSQL($table);
+ $createTableSQL = $this->platform->getCreateTableSQL($table);
self::assertEquals(
'CREATE TABLE test ("like" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)',
$createTableSQL[0]
@@ -325,16 +331,16 @@ public function testGenerateTableSqlShouldNotAutoQuotePrimaryKey()
public function testAlterTableAddColumns()
{
- $diff = new TableDiff('user');
- $diff->addedColumns['foo'] = new Column('foo', Type::getType('string'));
- $diff->addedColumns['count'] = new Column('count', Type::getType('integer'), array('notnull' => false, 'default' => 1));
+ $diff = new TableDiff('user');
+ $diff->addedColumns['foo'] = new Column('foo', Type::getType('string'));
+ $diff->addedColumns['count'] = new Column('count', Type::getType('integer'), ['notnull' => false, 'default' => 1]);
- $expected = array(
+ $expected = [
'ALTER TABLE user ADD COLUMN foo VARCHAR(255) NOT NULL',
'ALTER TABLE user ADD COLUMN count INTEGER DEFAULT 1',
- );
+ ];
- self::assertEquals($expected, $this->_platform->getAlterTableSQL($diff));
+ self::assertEquals($expected, $this->platform->getAlterTableSQL($diff));
}
/**
@@ -344,17 +350,17 @@ public function testAlterTableAddComplexColumns(TableDiff $diff) : void
{
$this->expectException(DBALException::class);
- $this->_platform->getAlterTableSQL($diff);
+ $this->platform->getAlterTableSQL($diff);
}
+ /** @return mixed[] */
public function complexDiffProvider() : array
{
- $date = new TableDiff('user');
- $date->addedColumns['time'] = new Column('time', Type::getType('date'), array('default' => 'CURRENT_DATE'));
+ $date = new TableDiff('user');
+ $date->addedColumns['time'] = new Column('time', Type::getType('date'), ['default' => 'CURRENT_DATE']);
-
- $id = new TableDiff('user');
- $id->addedColumns['id'] = new Column('id', Type::getType('integer'), array('autoincrement' => true));
+ $id = new TableDiff('user');
+ $id->addedColumns['id'] = new Column('id', Type::getType('integer'), ['autoincrement' => true]);
return [
'date column with default value' => [$date],
@@ -369,12 +375,12 @@ public function testCreateTableWithDeferredForeignKeys()
$table->addColumn('article', 'integer');
$table->addColumn('post', 'integer');
$table->addColumn('parent', 'integer');
- $table->setPrimaryKey(array('id'));
- $table->addForeignKeyConstraint('article', array('article'), array('id'), array('deferrable' => true));
- $table->addForeignKeyConstraint('post', array('post'), array('id'), array('deferred' => true));
- $table->addForeignKeyConstraint('user', array('parent'), array('id'), array('deferrable' => true, 'deferred' => true));
+ $table->setPrimaryKey(['id']);
+ $table->addForeignKeyConstraint('article', ['article'], ['id'], ['deferrable' => true]);
+ $table->addForeignKeyConstraint('post', ['post'], ['id'], ['deferred' => true]);
+ $table->addForeignKeyConstraint('user', ['parent'], ['id'], ['deferrable' => true, 'deferred' => true]);
- $sql = array(
+ $sql = [
'CREATE TABLE user ('
. 'id INTEGER NOT NULL, article INTEGER NOT NULL, post INTEGER NOT NULL, parent INTEGER NOT NULL'
. ', PRIMARY KEY(id)'
@@ -385,9 +391,9 @@ public function testCreateTableWithDeferredForeignKeys()
'CREATE INDEX IDX_8D93D64923A0E66 ON user (article)',
'CREATE INDEX IDX_8D93D6495A8A6C8D ON user (post)',
'CREATE INDEX IDX_8D93D6493D8E604F ON user (parent)',
- );
+ ];
- self::assertEquals($sql, $this->_platform->getCreateTableSQL($table));
+ self::assertEquals($sql, $this->platform->getCreateTableSQL($table));
}
public function testAlterTable()
@@ -397,21 +403,21 @@ public function testAlterTable()
$table->addColumn('article', 'integer');
$table->addColumn('post', 'integer');
$table->addColumn('parent', 'integer');
- $table->setPrimaryKey(array('id'));
- $table->addForeignKeyConstraint('article', array('article'), array('id'), array('deferrable' => true));
- $table->addForeignKeyConstraint('post', array('post'), array('id'), array('deferred' => true));
- $table->addForeignKeyConstraint('user', array('parent'), array('id'), array('deferrable' => true, 'deferred' => true));
- $table->addIndex(array('article', 'post'), 'index1');
-
- $diff = new TableDiff('user');
- $diff->fromTable = $table;
- $diff->newName = 'client';
- $diff->renamedColumns['id'] = new \Doctrine\DBAL\Schema\Column('key', \Doctrine\DBAL\Types\Type::getType('integer'), array());
- $diff->renamedColumns['post'] = new \Doctrine\DBAL\Schema\Column('comment', \Doctrine\DBAL\Types\Type::getType('integer'), array());
- $diff->removedColumns['parent'] = new \Doctrine\DBAL\Schema\Column('comment', \Doctrine\DBAL\Types\Type::getType('integer'), array());
+ $table->setPrimaryKey(['id']);
+ $table->addForeignKeyConstraint('article', ['article'], ['id'], ['deferrable' => true]);
+ $table->addForeignKeyConstraint('post', ['post'], ['id'], ['deferred' => true]);
+ $table->addForeignKeyConstraint('user', ['parent'], ['id'], ['deferrable' => true, 'deferred' => true]);
+ $table->addIndex(['article', 'post'], 'index1');
+
+ $diff = new TableDiff('user');
+ $diff->fromTable = $table;
+ $diff->newName = 'client';
+ $diff->renamedColumns['id'] = new Column('key', Type::getType('integer'), []);
+ $diff->renamedColumns['post'] = new Column('comment', Type::getType('integer'), []);
+ $diff->removedColumns['parent'] = new Column('comment', Type::getType('integer'), []);
$diff->removedIndexes['index1'] = $table->getIndex('index1');
- $sql = array(
+ $sql = [
'DROP INDEX IDX_8D93D64923A0E66',
'DROP INDEX IDX_8D93D6495A8A6C8D',
'DROP INDEX IDX_8D93D6493D8E604F',
@@ -429,43 +435,41 @@ public function testAlterTable()
'ALTER TABLE user RENAME TO client',
'CREATE INDEX IDX_8D93D64923A0E66 ON client (article)',
'CREATE INDEX IDX_8D93D6495A8A6C8D ON client (comment)',
- );
+ ];
- self::assertEquals($sql, $this->_platform->getAlterTableSQL($diff));
+ self::assertEquals($sql, $this->platform->getAlterTableSQL($diff));
}
protected function getQuotedColumnInPrimaryKeySQL()
{
- return array(
- 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY("create"))',
- );
+ return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY("create"))'];
}
protected function getQuotedColumnInIndexSQL()
{
- return array(
+ return [
'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)',
'CREATE INDEX IDX_22660D028FD6E0FB ON "quoted" ("create")',
- );
+ ];
}
protected function getQuotedNameInIndexSQL()
{
- return array(
+ return [
'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)',
'CREATE INDEX "key" ON test (column1)',
- );
+ ];
}
protected function getQuotedColumnInForeignKeySQL()
{
- return array(
+ return [
'CREATE TABLE "quoted" (' .
'"create" VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, "bar" VARCHAR(255) NOT NULL, ' .
'CONSTRAINT FK_WITH_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES "foreign" ("create", bar, "foo-bar") NOT DEFERRABLE INITIALLY IMMEDIATE, ' .
'CONSTRAINT FK_WITH_NON_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES foo ("create", bar, "foo-bar") NOT DEFERRABLE INITIALLY IMMEDIATE, ' .
'CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY ("create", foo, "bar") REFERENCES "foo-bar" ("create", bar, "foo-bar") NOT DEFERRABLE INITIALLY IMMEDIATE)',
- );
+ ];
}
protected function getBinaryDefaultLength()
@@ -480,13 +484,13 @@ protected function getBinaryMaxLength()
public function testReturnsBinaryTypeDeclarationSQL()
{
- self::assertSame('BLOB', $this->_platform->getBinaryTypeDeclarationSQL(array()));
- self::assertSame('BLOB', $this->_platform->getBinaryTypeDeclarationSQL(array('length' => 0)));
- self::assertSame('BLOB', $this->_platform->getBinaryTypeDeclarationSQL(array('length' => 9999999)));
+ self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL([]));
+ self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0]));
+ self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL(['length' => 9999999]));
- self::assertSame('BLOB', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true)));
- self::assertSame('BLOB', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true, 'length' => 0)));
- self::assertSame('BLOB', $this->_platform->getBinaryTypeDeclarationSQL(array('fixed' => true, 'length' => 9999999)));
+ self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true]));
+ self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 0]));
+ self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 9999999]));
}
/**
@@ -494,14 +498,14 @@ public function testReturnsBinaryTypeDeclarationSQL()
*/
protected function getAlterTableRenameIndexSQL()
{
- return array(
+ return [
'CREATE TEMPORARY TABLE __temp__mytable AS SELECT id FROM mytable',
'DROP TABLE mytable',
'CREATE TABLE mytable (id INTEGER NOT NULL, PRIMARY KEY(id))',
'INSERT INTO mytable (id) SELECT id FROM __temp__mytable',
'DROP TABLE __temp__mytable',
'CREATE INDEX idx_bar ON mytable (id)',
- );
+ ];
}
/**
@@ -509,7 +513,7 @@ protected function getAlterTableRenameIndexSQL()
*/
protected function getQuotedAlterTableRenameIndexSQL()
{
- return array(
+ return [
'CREATE TEMPORARY TABLE __temp__table AS SELECT id FROM "table"',
'DROP TABLE "table"',
'CREATE TABLE "table" (id INTEGER NOT NULL, PRIMARY KEY(id))',
@@ -517,7 +521,7 @@ protected function getQuotedAlterTableRenameIndexSQL()
'DROP TABLE __temp__table',
'CREATE INDEX "select" ON "table" (id)',
'CREATE INDEX "bar" ON "table" (id)',
- );
+ ];
}
/**
@@ -525,7 +529,7 @@ protected function getQuotedAlterTableRenameIndexSQL()
*/
protected function getQuotedAlterTableRenameColumnSQL()
{
- return array(
+ return [
'CREATE TEMPORARY TABLE __temp__mytable AS SELECT unquoted1, unquoted2, unquoted3, "create", "table", "select", "quoted1", "quoted2", "quoted3" FROM mytable',
'DROP TABLE mytable',
'CREATE TABLE mytable (unquoted INTEGER NOT NULL --Unquoted 1
@@ -540,7 +544,7 @@ protected function getQuotedAlterTableRenameColumnSQL()
)',
'INSERT INTO mytable (unquoted, "where", "foo", reserved_keyword, "from", "bar", quoted, "and", "baz") SELECT unquoted1, unquoted2, unquoted3, "create", "table", "select", "quoted1", "quoted2", "quoted3" FROM __temp__mytable',
'DROP TABLE __temp__mytable',
- );
+ ];
}
/**
@@ -548,7 +552,7 @@ protected function getQuotedAlterTableRenameColumnSQL()
*/
protected function getQuotedAlterTableChangeColumnLengthSQL()
{
- return array(
+ return [
'CREATE TEMPORARY TABLE __temp__mytable AS SELECT unquoted1, unquoted2, unquoted3, "create", "table", "select" FROM mytable',
'DROP TABLE mytable',
'CREATE TABLE mytable (unquoted1 VARCHAR(255) NOT NULL --Unquoted 1
@@ -560,7 +564,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL()
)',
'INSERT INTO mytable (unquoted1, unquoted2, unquoted3, "create", "table", "select") SELECT unquoted1, unquoted2, unquoted3, "create", "table", "select" FROM __temp__mytable',
'DROP TABLE __temp__mytable',
- );
+ ];
}
/**
@@ -590,7 +594,7 @@ public function testQuotesAlterTableRenameIndexInSchema()
*/
public function testReturnsGuidTypeDeclarationSQL()
{
- self::assertSame('CHAR(36)', $this->_platform->getGuidTypeDeclarationSQL(array()));
+ self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([]));
}
/**
@@ -598,14 +602,14 @@ public function testReturnsGuidTypeDeclarationSQL()
*/
public function getAlterTableRenameColumnSQL()
{
- return array(
+ return [
'CREATE TEMPORARY TABLE __temp__foo AS SELECT bar FROM foo',
'DROP TABLE foo',
'CREATE TABLE foo (baz INTEGER DEFAULT 666 NOT NULL --rename test
)',
'INSERT INTO foo (baz) SELECT bar FROM __temp__foo',
'DROP TABLE __temp__foo',
- );
+ ];
}
/**
@@ -613,7 +617,7 @@ public function getAlterTableRenameColumnSQL()
*/
protected function getQuotesTableIdentifiersInAlterTableSQL()
{
- return array(
+ return [
'DROP INDEX IDX_8C736521A81E660E',
'DROP INDEX IDX_8C736521FDC58D6C',
'CREATE TEMPORARY TABLE __temp__foo AS SELECT fk, fk2, id, fk3, bar FROM "foo"',
@@ -627,7 +631,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL()
'ALTER TABLE "foo" RENAME TO "table"',
'CREATE INDEX IDX_8C736521A81E660E ON "table" (fk)',
'CREATE INDEX IDX_8C736521FDC58D6C ON "table" (fk2)',
- );
+ ];
}
/**
@@ -635,11 +639,11 @@ protected function getQuotesTableIdentifiersInAlterTableSQL()
*/
protected function getCommentOnColumnSQL()
{
- return array(
+ return [
'COMMENT ON COLUMN foo.bar IS \'comment\'',
'COMMENT ON COLUMN "Foo"."BAR" IS \'comment\'',
'COMMENT ON COLUMN "select"."from" IS \'comment\'',
- );
+ ];
}
protected function getInlineColumnCommentDelimiter()
@@ -691,13 +695,13 @@ protected function getQuotesReservedKeywordInTruncateTableSQL()
*/
protected function getAlterStringToFixedStringSQL()
{
- return array(
+ return [
'CREATE TEMPORARY TABLE __temp__mytable AS SELECT name FROM mytable',
'DROP TABLE mytable',
'CREATE TABLE mytable (name CHAR(2) NOT NULL)',
'INSERT INTO mytable (name) SELECT name FROM __temp__mytable',
'DROP TABLE __temp__mytable',
- );
+ ];
}
/**
@@ -705,7 +709,7 @@ protected function getAlterStringToFixedStringSQL()
*/
protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
{
- return array(
+ return [
'DROP INDEX idx_foo',
'DROP INDEX idx_bar',
'CREATE TEMPORARY TABLE __temp__mytable AS SELECT foo, bar, baz FROM mytable',
@@ -715,7 +719,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
'DROP TABLE __temp__mytable',
'CREATE INDEX idx_bar ON mytable (bar)',
'CREATE INDEX idx_foo_renamed ON mytable (foo)',
- );
+ ];
}
/**
@@ -723,7 +727,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL()
*/
public function testQuotesTableNameInListTableConstraintsSQL()
{
- self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\'", $this->platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true);
}
/**
@@ -731,7 +735,7 @@ public function testQuotesTableNameInListTableConstraintsSQL()
*/
public function testQuotesTableNameInListTableColumnsSQL()
{
- self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableColumnsSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\'", $this->platform->getListTableColumnsSQL("Foo'Bar\\"), '', true);
}
/**
@@ -739,7 +743,7 @@ public function testQuotesTableNameInListTableColumnsSQL()
*/
public function testQuotesTableNameInListTableIndexesSQL()
{
- self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableIndexesSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\'", $this->platform->getListTableIndexesSQL("Foo'Bar\\"), '', true);
}
/**
@@ -747,29 +751,29 @@ public function testQuotesTableNameInListTableIndexesSQL()
*/
public function testQuotesTableNameInListTableForeignKeysSQL()
{
- self::assertContains("'Foo''Bar\\'", $this->_platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
+ self::assertContains("'Foo''Bar\\'", $this->platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true);
}
public function testDateAddStaticNumberOfDays()
{
- self::assertSame("DATE(rentalBeginsOn,'+12 DAY')", $this->_platform->getDateAddDaysExpression('rentalBeginsOn', 12));
+ self::assertSame("DATE(rentalBeginsOn,'+12 DAY')", $this->platform->getDateAddDaysExpression('rentalBeginsOn', 12));
}
public function testDateAddNumberOfDaysFromColumn()
{
- self::assertSame("DATE(rentalBeginsOn,'+' || duration || ' DAY')", $this->_platform->getDateAddDaysExpression('rentalBeginsOn', 'duration'));
+ self::assertSame("DATE(rentalBeginsOn,'+' || duration || ' DAY')", $this->platform->getDateAddDaysExpression('rentalBeginsOn', 'duration'));
}
public function testSupportsColumnCollation() : void
{
- self::assertTrue($this->_platform->supportsColumnCollation());
+ self::assertTrue($this->platform->supportsColumnCollation());
}
public function testColumnCollationDeclarationSQL() : void
{
self::assertSame(
'COLLATE NOCASE',
- $this->_platform->getColumnCollationDeclarationSQL('NOCASE')
+ $this->platform->getColumnCollationDeclarationSQL('NOCASE')
);
}
@@ -781,7 +785,7 @@ public function testGetCreateTableSQLWithColumnCollation() : void
self::assertSame(
['CREATE TABLE foo (no_collation VARCHAR(255) NOT NULL, column_collation VARCHAR(255) NOT NULL COLLATE NOCASE)'],
- $this->_platform->getCreateTableSQL($table),
+ $this->platform->getCreateTableSQL($table),
'Column "no_collation" will use the default collation (BINARY) and "column_collation" overwrites the collation on this column'
);
}
diff --git a/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php b/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php
index 83775e13f2e..88676130a52 100644
--- a/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php
+++ b/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php
@@ -6,23 +6,20 @@
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Portability\Connection;
use Doctrine\DBAL\Portability\Statement;
+use Doctrine\Tests\DbalTestCase;
+use Doctrine\Tests\Mocks\DriverStatementMock;
+use PHPUnit_Framework_MockObject_MockObject;
use function iterator_to_array;
-class StatementTest extends \Doctrine\Tests\DbalTestCase
+class StatementTest extends DbalTestCase
{
- /**
- * @var \Doctrine\DBAL\Portability\Connection|\PHPUnit_Framework_MockObject_MockObject
- */
+ /** @var Connection|PHPUnit_Framework_MockObject_MockObject */
protected $conn;
- /**
- * @var \Doctrine\DBAL\Portability\Statement
- */
+ /** @var Statement */
protected $stmt;
- /**
- * @var \Doctrine\DBAL\Driver\Statement|\PHPUnit_Framework_MockObject_MockObject
- */
+ /** @var \Doctrine\DBAL\Driver\Statement|PHPUnit_Framework_MockObject_MockObject */
protected $wrappedStmt;
/**
@@ -100,7 +97,7 @@ public function testErrorCode()
public function testErrorInfo()
{
- $errorInfo = array('666', 'Evil error.');
+ $errorInfo = ['666', 'Evil error.'];
$this->wrappedStmt->expects($this->once())
->method('errorInfo')
@@ -111,10 +108,10 @@ public function testErrorInfo()
public function testExecute()
{
- $params = array(
+ $params = [
'foo',
- 'bar'
- );
+ 'bar',
+ ];
$this->wrappedStmt->expects($this->once())
->method('execute')
@@ -128,7 +125,7 @@ public function testSetFetchMode()
{
$fetchMode = FetchMode::CUSTOM_OBJECT;
$arg1 = 'MyClass';
- $arg2 = array(1, 2);
+ $arg2 = [1, 2];
$this->wrappedStmt->expects($this->once())
->method('setFetchMode')
@@ -161,20 +158,17 @@ public function testRowCount()
}
/**
- * @return \Doctrine\DBAL\Portability\Connection|\PHPUnit_Framework_MockObject_MockObject
+ * @return Connection|PHPUnit_Framework_MockObject_MockObject
*/
protected function createConnection()
{
- return $this->getMockBuilder('Doctrine\DBAL\Portability\Connection')
+ return $this->getMockBuilder(Connection::class)
->disableOriginalConstructor()
->getMock();
}
/**
- * @param \Doctrine\DBAL\Driver\Statement $wrappedStatement
- * @param \Doctrine\DBAL\Portability\Connection $connection
- *
- * @return \Doctrine\DBAL\Portability\Statement
+ * @return Statement
*/
protected function createStatement(\Doctrine\DBAL\Driver\Statement $wrappedStatement, Connection $connection)
{
@@ -182,10 +176,10 @@ protected function createStatement(\Doctrine\DBAL\Driver\Statement $wrappedState
}
/**
- * @return \Doctrine\DBAL\Driver\Statement|\PHPUnit_Framework_MockObject_MockObject
+ * @return \Doctrine\DBAL\Driver\Statement|PHPUnit_Framework_MockObject_MockObject
*/
protected function createWrappedStatement()
{
- return $this->createMock('Doctrine\Tests\Mocks\DriverStatementMock');
+ return $this->createMock(DriverStatementMock::class);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php b/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php
index 2ae9d0087e4..512dfb08224 100644
--- a/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php
@@ -3,15 +3,16 @@
namespace Doctrine\Tests\DBAL\Query\Expression;
use Doctrine\DBAL\Query\Expression\CompositeExpression;
+use Doctrine\Tests\DbalTestCase;
/**
* @group DBAL-12
*/
-class CompositeExpressionTest extends \Doctrine\Tests\DbalTestCase
+class CompositeExpressionTest extends DbalTestCase
{
public function testCount()
{
- $expr = new CompositeExpression(CompositeExpression::TYPE_OR, array('u.group_id = 1'));
+ $expr = new CompositeExpression(CompositeExpression::TYPE_OR, ['u.group_id = 1']);
self::assertCount(1, $expr);
@@ -22,15 +23,15 @@ public function testCount()
public function testAdd()
{
- $expr = new CompositeExpression(CompositeExpression::TYPE_OR, array('u.group_id = 1'));
+ $expr = new CompositeExpression(CompositeExpression::TYPE_OR, ['u.group_id = 1']);
self::assertCount(1, $expr);
- $expr->add(new CompositeExpression(CompositeExpression::TYPE_AND, array()));
+ $expr->add(new CompositeExpression(CompositeExpression::TYPE_AND, []));
self::assertCount(1, $expr);
- $expr->add(new CompositeExpression(CompositeExpression::TYPE_OR, array('u.user_id = 1')));
+ $expr->add(new CompositeExpression(CompositeExpression::TYPE_OR, ['u.user_id = 1']));
self::assertCount(2, $expr);
@@ -55,49 +56,49 @@ public function testCompositeUsageAndGeneration($type, $parts, $expects)
public function provideDataForConvertToString()
{
- return array(
- array(
+ return [
+ [
CompositeExpression::TYPE_AND,
- array('u.user = 1'),
- 'u.user = 1'
- ),
- array(
+ ['u.user = 1'],
+ 'u.user = 1',
+ ],
+ [
CompositeExpression::TYPE_AND,
- array('u.user = 1', 'u.group_id = 1'),
- '(u.user = 1) AND (u.group_id = 1)'
- ),
- array(
+ ['u.user = 1', 'u.group_id = 1'],
+ '(u.user = 1) AND (u.group_id = 1)',
+ ],
+ [
CompositeExpression::TYPE_OR,
- array('u.user = 1'),
- 'u.user = 1'
- ),
- array(
+ ['u.user = 1'],
+ 'u.user = 1',
+ ],
+ [
CompositeExpression::TYPE_OR,
- array('u.group_id = 1', 'u.group_id = 2'),
- '(u.group_id = 1) OR (u.group_id = 2)'
- ),
- array(
+ ['u.group_id = 1', 'u.group_id = 2'],
+ '(u.group_id = 1) OR (u.group_id = 2)',
+ ],
+ [
CompositeExpression::TYPE_AND,
- array(
+ [
'u.user = 1',
new CompositeExpression(
CompositeExpression::TYPE_OR,
- array('u.group_id = 1', 'u.group_id = 2')
- )
- ),
- '(u.user = 1) AND ((u.group_id = 1) OR (u.group_id = 2))'
- ),
- array(
+ ['u.group_id = 1', 'u.group_id = 2']
+ ),
+ ],
+ '(u.user = 1) AND ((u.group_id = 1) OR (u.group_id = 2))',
+ ],
+ [
CompositeExpression::TYPE_OR,
- array(
+ [
'u.group_id = 1',
new CompositeExpression(
CompositeExpression::TYPE_AND,
- array('u.user = 1', 'u.group_id = 2')
- )
- ),
- '(u.group_id = 1) OR ((u.user = 1) AND (u.group_id = 2))'
- ),
- );
+ ['u.user = 1', 'u.group_id = 2']
+ ),
+ ],
+ '(u.group_id = 1) OR ((u.user = 1) AND (u.group_id = 2))',
+ ],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php
index d4a1d111942..efa173829c3 100644
--- a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php
+++ b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php
@@ -2,22 +2,22 @@
namespace Doctrine\Tests\DBAL\Query\Expression;
+use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Query\Expression\CompositeExpression;
use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
+use Doctrine\Tests\DbalTestCase;
/**
* @group DBAL-12
*/
-class ExpressionBuilderTest extends \Doctrine\Tests\DbalTestCase
+class ExpressionBuilderTest extends DbalTestCase
{
- /**
- * @var ExpressionBuilder
- */
+ /** @var ExpressionBuilder */
protected $expr;
protected function setUp()
{
- $conn = $this->createMock('Doctrine\DBAL\Connection');
+ $conn = $this->createMock(Connection::class);
$this->expr = new ExpressionBuilder($conn);
@@ -42,44 +42,44 @@ public function testAndX($parts, $expected)
public function provideDataForAndX()
{
- return array(
- array(
- array('u.user = 1'),
- 'u.user = 1'
- ),
- array(
- array('u.user = 1', 'u.group_id = 1'),
- '(u.user = 1) AND (u.group_id = 1)'
- ),
- array(
- array('u.user = 1'),
- 'u.user = 1'
- ),
- array(
- array('u.group_id = 1', 'u.group_id = 2'),
- '(u.group_id = 1) AND (u.group_id = 2)'
- ),
- array(
- array(
+ return [
+ [
+ ['u.user = 1'],
+ 'u.user = 1',
+ ],
+ [
+ ['u.user = 1', 'u.group_id = 1'],
+ '(u.user = 1) AND (u.group_id = 1)',
+ ],
+ [
+ ['u.user = 1'],
+ 'u.user = 1',
+ ],
+ [
+ ['u.group_id = 1', 'u.group_id = 2'],
+ '(u.group_id = 1) AND (u.group_id = 2)',
+ ],
+ [
+ [
'u.user = 1',
new CompositeExpression(
CompositeExpression::TYPE_OR,
- array('u.group_id = 1', 'u.group_id = 2')
- )
- ),
- '(u.user = 1) AND ((u.group_id = 1) OR (u.group_id = 2))'
- ),
- array(
- array(
+ ['u.group_id = 1', 'u.group_id = 2']
+ ),
+ ],
+ '(u.user = 1) AND ((u.group_id = 1) OR (u.group_id = 2))',
+ ],
+ [
+ [
'u.group_id = 1',
new CompositeExpression(
CompositeExpression::TYPE_AND,
- array('u.user = 1', 'u.group_id = 2')
- )
- ),
- '(u.group_id = 1) AND ((u.user = 1) AND (u.group_id = 2))'
- ),
- );
+ ['u.user = 1', 'u.group_id = 2']
+ ),
+ ],
+ '(u.group_id = 1) AND ((u.user = 1) AND (u.group_id = 2))',
+ ],
+ ];
}
/**
@@ -98,44 +98,44 @@ public function testOrX($parts, $expected)
public function provideDataForOrX()
{
- return array(
- array(
- array('u.user = 1'),
- 'u.user = 1'
- ),
- array(
- array('u.user = 1', 'u.group_id = 1'),
- '(u.user = 1) OR (u.group_id = 1)'
- ),
- array(
- array('u.user = 1'),
- 'u.user = 1'
- ),
- array(
- array('u.group_id = 1', 'u.group_id = 2'),
- '(u.group_id = 1) OR (u.group_id = 2)'
- ),
- array(
- array(
+ return [
+ [
+ ['u.user = 1'],
+ 'u.user = 1',
+ ],
+ [
+ ['u.user = 1', 'u.group_id = 1'],
+ '(u.user = 1) OR (u.group_id = 1)',
+ ],
+ [
+ ['u.user = 1'],
+ 'u.user = 1',
+ ],
+ [
+ ['u.group_id = 1', 'u.group_id = 2'],
+ '(u.group_id = 1) OR (u.group_id = 2)',
+ ],
+ [
+ [
'u.user = 1',
new CompositeExpression(
CompositeExpression::TYPE_OR,
- array('u.group_id = 1', 'u.group_id = 2')
- )
- ),
- '(u.user = 1) OR ((u.group_id = 1) OR (u.group_id = 2))'
- ),
- array(
- array(
+ ['u.group_id = 1', 'u.group_id = 2']
+ ),
+ ],
+ '(u.user = 1) OR ((u.group_id = 1) OR (u.group_id = 2))',
+ ],
+ [
+ [
'u.group_id = 1',
new CompositeExpression(
CompositeExpression::TYPE_AND,
- array('u.user = 1', 'u.group_id = 2')
- )
- ),
- '(u.group_id = 1) OR ((u.user = 1) AND (u.group_id = 2))'
- ),
- );
+ ['u.user = 1', 'u.group_id = 2']
+ ),
+ ],
+ '(u.group_id = 1) OR ((u.user = 1) AND (u.group_id = 2))',
+ ],
+ ];
}
/**
@@ -150,14 +150,14 @@ public function testComparison($leftExpr, $operator, $rightExpr, $expected)
public function provideDataForComparison()
{
- return array(
- array('u.user_id', ExpressionBuilder::EQ, '1', 'u.user_id = 1'),
- array('u.user_id', ExpressionBuilder::NEQ, '1', 'u.user_id <> 1'),
- array('u.salary', ExpressionBuilder::LT, '10000', 'u.salary < 10000'),
- array('u.salary', ExpressionBuilder::LTE, '10000', 'u.salary <= 10000'),
- array('u.salary', ExpressionBuilder::GT, '10000', 'u.salary > 10000'),
- array('u.salary', ExpressionBuilder::GTE, '10000', 'u.salary >= 10000'),
- );
+ return [
+ ['u.user_id', ExpressionBuilder::EQ, '1', 'u.user_id = 1'],
+ ['u.user_id', ExpressionBuilder::NEQ, '1', 'u.user_id <> 1'],
+ ['u.salary', ExpressionBuilder::LT, '10000', 'u.salary < 10000'],
+ ['u.salary', ExpressionBuilder::LTE, '10000', 'u.salary <= 10000'],
+ ['u.salary', ExpressionBuilder::GT, '10000', 'u.salary > 10000'],
+ ['u.salary', ExpressionBuilder::GTE, '10000', 'u.salary >= 10000'],
+ ];
}
public function testEq()
@@ -202,7 +202,7 @@ public function testIsNotNull()
public function testIn()
{
- self::assertEquals('u.groups IN (1, 3, 4, 7)', $this->expr->in('u.groups', array(1,3,4,7)));
+ self::assertEquals('u.groups IN (1, 3, 4, 7)', $this->expr->in('u.groups', [1, 3, 4, 7]));
}
public function testInWithPlaceholder()
@@ -212,7 +212,7 @@ public function testInWithPlaceholder()
public function testNotIn()
{
- self::assertEquals('u.groups NOT IN (1, 3, 4, 7)', $this->expr->notIn('u.groups', array(1,3,4,7)));
+ self::assertEquals('u.groups NOT IN (1, 3, 4, 7)', $this->expr->notIn('u.groups', [1, 3, 4, 7]));
}
public function testNotInWithPlaceholder()
diff --git a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
index 97145d53d3a..fdd28d87847 100644
--- a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
+++ b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
@@ -2,23 +2,24 @@
namespace Doctrine\Tests\DBAL\Query;
+use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
use Doctrine\DBAL\Query\QueryBuilder;
+use Doctrine\DBAL\Query\QueryException;
+use Doctrine\Tests\DbalTestCase;
/**
* @group DBAL-12
*/
-class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
+class QueryBuilderTest extends DbalTestCase
{
- /**
- * @var \Doctrine\DBAL\Connection
- */
+ /** @var Connection */
protected $conn;
protected function setUp()
{
- $this->conn = $this->createMock('Doctrine\DBAL\Connection');
+ $this->conn = $this->createMock(Connection::class);
$expressionBuilder = new ExpressionBuilder($this->conn);
@@ -58,7 +59,7 @@ public function testSelectWithSimpleWhere()
->from('users', 'u')
->where($expr->andX($expr->eq('u.nickname', '?')));
- self::assertEquals("SELECT u.id FROM users u WHERE u.nickname = ?", (string) $qb);
+ self::assertEquals('SELECT u.id FROM users u WHERE u.nickname = ?', (string) $qb);
}
public function testSelectWithLeftJoin()
@@ -181,7 +182,7 @@ public function testSelectEmptyGroupBy()
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
- ->groupBy(array())
+ ->groupBy([])
->from('users', 'u');
self::assertEquals('SELECT u.*, p.* FROM users u', (string) $qb);
@@ -193,7 +194,7 @@ public function testSelectEmptyAddGroupBy()
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
- ->addGroupBy(array())
+ ->addGroupBy([])
->from('users', 'u');
self::assertEquals('SELECT u.*, p.* FROM users u', (string) $qb);
@@ -348,7 +349,7 @@ public function testSelectAddAddOrderBy()
public function testEmptySelect()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb2 = $qb->select();
self::assertSame($qb, $qb2);
@@ -369,7 +370,7 @@ public function testSelectAddSelect()
public function testEmptyAddSelect()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb2 = $qb->addSelect();
self::assertSame($qb, $qb2);
@@ -391,7 +392,7 @@ public function testSelectMultipleFrom()
public function testUpdate()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb->update('users', 'u')
->set('u.foo', '?')
->set('u.bar', '?');
@@ -402,7 +403,7 @@ public function testUpdate()
public function testUpdateWithoutAlias()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb->update('users')
->set('foo', '?')
->set('bar', '?');
@@ -412,7 +413,7 @@ public function testUpdateWithoutAlias()
public function testUpdateWhere()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb->update('users', 'u')
->set('u.foo', '?')
->where('u.foo = ?');
@@ -422,7 +423,7 @@ public function testUpdateWhere()
public function testEmptyUpdate()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb2 = $qb->update();
self::assertEquals(QueryBuilder::UPDATE, $qb->getType());
@@ -431,7 +432,7 @@ public function testEmptyUpdate()
public function testDelete()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb->delete('users', 'u');
self::assertEquals(QueryBuilder::DELETE, $qb->getType());
@@ -440,7 +441,7 @@ public function testDelete()
public function testDeleteWithoutAlias()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb->delete('users');
self::assertEquals(QueryBuilder::DELETE, $qb->getType());
@@ -449,7 +450,7 @@ public function testDeleteWithoutAlias()
public function testDeleteWhere()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb->delete('users', 'u')
->where('u.foo = ?');
@@ -458,7 +459,7 @@ public function testDeleteWhere()
public function testEmptyDelete()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb2 = $qb->delete();
self::assertEquals(QueryBuilder::DELETE, $qb->getType());
@@ -470,10 +471,10 @@ public function testInsertValues()
$qb = new QueryBuilder($this->conn);
$qb->insert('users')
->values(
- array(
+ [
'foo' => '?',
- 'bar' => '?'
- )
+ 'bar' => '?',
+ ]
);
self::assertEquals(QueryBuilder::INSERT, $qb->getType());
@@ -485,16 +486,16 @@ public function testInsertReplaceValues()
$qb = new QueryBuilder($this->conn);
$qb->insert('users')
->values(
- array(
+ [
'foo' => '?',
- 'bar' => '?'
- )
+ 'bar' => '?',
+ ]
)
->values(
- array(
+ [
'bar' => '?',
- 'foo' => '?'
- )
+ 'foo' => '?',
+ ]
);
self::assertEquals(QueryBuilder::INSERT, $qb->getType());
@@ -518,9 +519,7 @@ public function testInsertValuesSetValue()
$qb = new QueryBuilder($this->conn);
$qb->insert('users')
->values(
- array(
- 'foo' => '?'
- )
+ ['foo' => '?']
)
->setValue('bar', '?');
@@ -530,7 +529,7 @@ public function testInsertValuesSetValue()
public function testEmptyInsert()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb2 = $qb->insert();
self::assertEquals(QueryBuilder::INSERT, $qb->getType());
@@ -539,13 +538,13 @@ public function testEmptyInsert()
public function testGetConnection()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
self::assertSame($this->conn, $qb->getConnection());
}
public function testGetState()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
self::assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState());
@@ -561,7 +560,7 @@ public function testGetState()
public function testSetMaxResults()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb->setMaxResults(10);
self::assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState());
@@ -570,7 +569,7 @@ public function testSetMaxResults()
public function testSetFirstResult()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb->setFirstResult(10);
self::assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState());
@@ -579,7 +578,7 @@ public function testSetFirstResult()
public function testResetQueryPart()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb->select('u.*')->from('users', 'u')->where('u.name = ?');
@@ -590,18 +589,18 @@ public function testResetQueryPart()
public function testResetQueryParts()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb->select('u.*')->from('users', 'u')->where('u.name = ?')->orderBy('u.name');
self::assertEquals('SELECT u.* FROM users u WHERE u.name = ? ORDER BY u.name ASC', (string) $qb);
- $qb->resetQueryParts(array('where', 'orderBy'));
+ $qb->resetQueryParts(['where', 'orderBy']);
self::assertEquals('SELECT u.* FROM users u', (string) $qb);
}
public function testCreateNamedParameter()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb->select('u.*')->from('users', 'u')->where(
$qb->expr()->eq('u.name', $qb->createNamedParameter(10, ParameterType::INTEGER))
@@ -614,7 +613,7 @@ public function testCreateNamedParameter()
public function testCreateNamedParameterCustomPlaceholder()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb->select('u.*')->from('users', 'u')->where(
$qb->expr()->eq('u.name', $qb->createNamedParameter(10, ParameterType::INTEGER, ':test'))
@@ -627,7 +626,7 @@ public function testCreateNamedParameterCustomPlaceholder()
public function testCreatePositionalParameter()
{
- $qb = new QueryBuilder($this->conn);
+ $qb = new QueryBuilder($this->conn);
$qb->select('u.*')->from('users', 'u')->where(
$qb->expr()->eq('u.name', $qb->createPositionalParameter(10, ParameterType::INTEGER))
@@ -652,7 +651,7 @@ public function testReferenceJoinFromJoin()
->innerJoin('nt', 'node', 'n', 'nt.node = n.id')
->where('nt.lang = :lang AND n.deleted != 1');
- $this->expectException('Doctrine\DBAL\Query\QueryException');
+ $this->expectException(QueryException::class);
$this->expectExceptionMessage("The given alias 'invalid' is not part of any FROM or JOIN clause table. The currently registered aliases are: news, nv.");
self::assertEquals('', $qb->getSQL());
}
@@ -785,7 +784,7 @@ public function testSelectWithSimpleWhereWithoutTableAlias()
->from('users')
->where('awesome=9001');
- self::assertEquals("SELECT id, name FROM users WHERE awesome=9001", (string) $qb);
+ self::assertEquals('SELECT id, name FROM users WHERE awesome=9001', (string) $qb);
}
public function testComplexSelectWithoutTableAliases()
@@ -823,7 +822,7 @@ public function testSelectAllFromTableWithoutTableAlias()
$qb->select('users.*')
->from('users');
- self::assertEquals("SELECT users.* FROM users", (string) $qb);
+ self::assertEquals('SELECT users.* FROM users', (string) $qb);
}
public function testSelectAllWithoutTableAlias()
@@ -833,7 +832,7 @@ public function testSelectAllWithoutTableAlias()
$qb->select('*')
->from('users');
- self::assertEquals("SELECT * FROM users", (string) $qb);
+ self::assertEquals('SELECT * FROM users', (string) $qb);
}
/**
@@ -866,12 +865,12 @@ public function testGetParameterTypes()
$qb->select('*')->from('users');
- self::assertSame(array(), $qb->getParameterTypes());
+ self::assertSame([], $qb->getParameterTypes());
$qb->where('name = :name');
$qb->setParameter('name', 'foo');
- self::assertSame(array(), $qb->getParameterTypes());
+ self::assertSame([], $qb->getParameterTypes());
$qb->setParameter('name', 'foo', ParameterType::STRING);
@@ -895,7 +894,7 @@ public function testJoinWithNonUniqueAliasThrowsException()
->from('table_a', 'a')
->join('a', 'table_b', 'a', 'a.fk_b = a.id');
- $this->expectException('Doctrine\DBAL\Query\QueryException');
+ $this->expectException(QueryException::class);
$this->expectExceptionMessage("The given alias 'a' is not unique in FROM and JOIN clause table. The currently registered aliases are: a.");
$qb->getSQL();
diff --git a/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php b/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
index 0e057953b8a..68d3cbcedd3 100644
--- a/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
+++ b/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
@@ -5,60 +5,62 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\SQLParserUtils;
+use Doctrine\DBAL\SQLParserUtilsException;
+use Doctrine\Tests\DbalTestCase;
/**
* @group DBAL-78
* @group DDC-1372
*/
-class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase
+class SQLParserUtilsTest extends DbalTestCase
{
public function dataGetPlaceholderPositions()
{
- return array(
+ return [
// none
- array('SELECT * FROM Foo', true, array()),
- array('SELECT * FROM Foo', false, array()),
+ ['SELECT * FROM Foo', true, []],
+ ['SELECT * FROM Foo', false, []],
// Positionals
- array('SELECT ?', true, array(7)),
- array('SELECT * FROM Foo WHERE bar IN (?, ?, ?)', true, array(32, 35, 38)),
- array('SELECT ? FROM ?', true, array(7, 14)),
- array('SELECT "?" FROM foo', true, array()),
- array("SELECT '?' FROM foo", true, array()),
- array("SELECT `?` FROM foo", true, array()), // Ticket DBAL-552
- array("SELECT [?] FROM foo", true, array()),
- array("SELECT 'Doctrine\DBAL?' FROM foo", true, array()), // Ticket DBAL-558
- array('SELECT "Doctrine\DBAL?" FROM foo', true, array()), // Ticket DBAL-558
- array('SELECT `Doctrine\DBAL?` FROM foo', true, array()), // Ticket DBAL-558
- array('SELECT [Doctrine\DBAL?] FROM foo', true, array()), // Ticket DBAL-558
- array('SELECT "?" FROM foo WHERE bar = ?', true, array(32)),
- array("SELECT '?' FROM foo WHERE bar = ?", true, array(32)),
- array("SELECT `?` FROM foo WHERE bar = ?", true, array(32)), // Ticket DBAL-552
- array("SELECT [?] FROM foo WHERE bar = ?", true, array(32)),
- array('SELECT * FROM foo WHERE jsonb_exists_any(foo.bar, ARRAY[?])', true, array(56)), // Ticket GH-2295
- array("SELECT 'Doctrine\DBAL?' FROM foo WHERE bar = ?", true, array(45)), // Ticket DBAL-558
- array('SELECT "Doctrine\DBAL?" FROM foo WHERE bar = ?', true, array(45)), // Ticket DBAL-558
- array('SELECT `Doctrine\DBAL?` FROM foo WHERE bar = ?', true, array(45)), // Ticket DBAL-558
- array('SELECT [Doctrine\DBAL?] FROM foo WHERE bar = ?', true, array(45)), // Ticket DBAL-558
- array("SELECT * FROM FOO WHERE bar = 'it\\'s a trap? \\\\' OR bar = ?\nAND baz = \"\\\"quote\\\" me on it? \\\\\" OR baz = ?", true, array(58, 104)),
- array('SELECT * FROM foo WHERE foo = ? AND bar = ?', true, array(1 => 42, 0 => 30)), // explicit keys
+ ['SELECT ?', true, [7]],
+ ['SELECT * FROM Foo WHERE bar IN (?, ?, ?)', true, [32, 35, 38]],
+ ['SELECT ? FROM ?', true, [7, 14]],
+ ['SELECT "?" FROM foo', true, []],
+ ["SELECT '?' FROM foo", true, []],
+ ['SELECT `?` FROM foo', true, []], // Ticket DBAL-552
+ ['SELECT [?] FROM foo', true, []],
+ ["SELECT 'Doctrine\DBAL?' FROM foo", true, []], // Ticket DBAL-558
+ ['SELECT "Doctrine\DBAL?" FROM foo', true, []], // Ticket DBAL-558
+ ['SELECT `Doctrine\DBAL?` FROM foo', true, []], // Ticket DBAL-558
+ ['SELECT [Doctrine\DBAL?] FROM foo', true, []], // Ticket DBAL-558
+ ['SELECT "?" FROM foo WHERE bar = ?', true, [32]],
+ ["SELECT '?' FROM foo WHERE bar = ?", true, [32]],
+ ['SELECT `?` FROM foo WHERE bar = ?', true, [32]], // Ticket DBAL-552
+ ['SELECT [?] FROM foo WHERE bar = ?', true, [32]],
+ ['SELECT * FROM foo WHERE jsonb_exists_any(foo.bar, ARRAY[?])', true, [56]], // Ticket GH-2295
+ ["SELECT 'Doctrine\DBAL?' FROM foo WHERE bar = ?", true, [45]], // Ticket DBAL-558
+ ['SELECT "Doctrine\DBAL?" FROM foo WHERE bar = ?', true, [45]], // Ticket DBAL-558
+ ['SELECT `Doctrine\DBAL?` FROM foo WHERE bar = ?', true, [45]], // Ticket DBAL-558
+ ['SELECT [Doctrine\DBAL?] FROM foo WHERE bar = ?', true, [45]], // Ticket DBAL-558
+ ["SELECT * FROM FOO WHERE bar = 'it\\'s a trap? \\\\' OR bar = ?\nAND baz = \"\\\"quote\\\" me on it? \\\\\" OR baz = ?", true, [58, 104]],
+ ['SELECT * FROM foo WHERE foo = ? AND bar = ?', true, [1 => 42, 0 => 30]], // explicit keys
// named
- array('SELECT :foo FROM :bar', false, array(7 => 'foo', 17 => 'bar')),
- array('SELECT * FROM Foo WHERE bar IN (:name1, :name2)', false, array(32 => 'name1', 40 => 'name2')),
- array('SELECT ":foo" FROM Foo WHERE bar IN (:name1, :name2)', false, array(37 => 'name1', 45 => 'name2')),
- array("SELECT ':foo' FROM Foo WHERE bar IN (:name1, :name2)", false, array(37 => 'name1', 45 => 'name2')),
- array('SELECT :foo_id', false, array(7 => 'foo_id')), // Ticket DBAL-231
- array('SELECT @rank := 1', false, array()), // Ticket DBAL-398
- array('SELECT @rank := 1 AS rank, :foo AS foo FROM :bar', false, array(27 => 'foo', 44 => 'bar')), // Ticket DBAL-398
- array('SELECT * FROM Foo WHERE bar > :start_date AND baz > :start_date', false, array(30 => 'start_date', 52 => 'start_date')), // Ticket GH-113
- array('SELECT foo::date as date FROM Foo WHERE bar > :start_date AND baz > :start_date', false, array(46 => 'start_date', 68 => 'start_date')), // Ticket GH-259
- array('SELECT `d.ns:col_name` FROM my_table d WHERE `d.date` >= :param1', false, array(57 => 'param1')), // Ticket DBAL-552
- array('SELECT [d.ns:col_name] FROM my_table d WHERE [d.date] >= :param1', false, array(57 => 'param1')), // Ticket DBAL-552
+ ['SELECT :foo FROM :bar', false, [7 => 'foo', 17 => 'bar']],
+ ['SELECT * FROM Foo WHERE bar IN (:name1, :name2)', false, [32 => 'name1', 40 => 'name2']],
+ ['SELECT ":foo" FROM Foo WHERE bar IN (:name1, :name2)', false, [37 => 'name1', 45 => 'name2']],
+ ["SELECT ':foo' FROM Foo WHERE bar IN (:name1, :name2)", false, [37 => 'name1', 45 => 'name2']],
+ ['SELECT :foo_id', false, [7 => 'foo_id']], // Ticket DBAL-231
+ ['SELECT @rank := 1', false, []], // Ticket DBAL-398
+ ['SELECT @rank := 1 AS rank, :foo AS foo FROM :bar', false, [27 => 'foo', 44 => 'bar']], // Ticket DBAL-398
+ ['SELECT * FROM Foo WHERE bar > :start_date AND baz > :start_date', false, [30 => 'start_date', 52 => 'start_date']], // Ticket GH-113
+ ['SELECT foo::date as date FROM Foo WHERE bar > :start_date AND baz > :start_date', false, [46 => 'start_date', 68 => 'start_date']], // Ticket GH-259
+ ['SELECT `d.ns:col_name` FROM my_table d WHERE `d.date` >= :param1', false, [57 => 'param1']], // Ticket DBAL-552
+ ['SELECT [d.ns:col_name] FROM my_table d WHERE [d.date] >= :param1', false, [57 => 'param1']], // Ticket DBAL-552
['SELECT * FROM foo WHERE jsonb_exists_any(foo.bar, ARRAY[:foo])', false, [56 => 'foo']], // Ticket GH-2295
['SELECT * FROM foo WHERE jsonb_exists_any(foo.bar, array[:foo])', false, [56 => 'foo']],
- array(
-<<<'SQLDATA'
+ [
+ <<<'SQLDATA'
SELECT * FROM foo WHERE
bar = ':not_a_param1 ''":not_a_param2"'''
OR bar=:a_param1
@@ -67,15 +69,21 @@ public function dataGetPlaceholderPositions()
OR bar=''
OR bar=:a_param3
SQLDATA
- , false, array(74 => 'a_param1', 91 => 'a_param2', 190 => 'a_param3')
- ),
- array("SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE '\\\\') AND (data.description LIKE :condition_1 ESCAPE '\\\\') ORDER BY id ASC", false, array(121 => 'condition_0', 174 => 'condition_1')),
- array('SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE "\\\\") AND (data.description LIKE :condition_1 ESCAPE "\\\\") ORDER BY id ASC', false, array(121 => 'condition_0', 174 => 'condition_1')),
- array('SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE "\\\\") AND (data.description LIKE :condition_1 ESCAPE \'\\\\\') ORDER BY id ASC', false, array(121 => 'condition_0', 174 => 'condition_1')),
- array('SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE `\\\\`) AND (data.description LIKE :condition_1 ESCAPE `\\\\`) ORDER BY id ASC', false, array(121 => 'condition_0', 174 => 'condition_1')),
- array('SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE \'\\\\\') AND (data.description LIKE :condition_1 ESCAPE `\\\\`) ORDER BY id ASC', false, array(121 => 'condition_0', 174 => 'condition_1')),
+ ,
+ false,
+ [
+ 74 => 'a_param1',
+ 91 => 'a_param2',
+ 190 => 'a_param3',
+ ],
+ ],
+ ["SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE '\\\\') AND (data.description LIKE :condition_1 ESCAPE '\\\\') ORDER BY id ASC", false, [121 => 'condition_0', 174 => 'condition_1']],
+ ['SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE "\\\\") AND (data.description LIKE :condition_1 ESCAPE "\\\\") ORDER BY id ASC', false, [121 => 'condition_0', 174 => 'condition_1']],
+ ['SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE "\\\\") AND (data.description LIKE :condition_1 ESCAPE \'\\\\\') ORDER BY id ASC', false, [121 => 'condition_0', 174 => 'condition_1']],
+ ['SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE `\\\\`) AND (data.description LIKE :condition_1 ESCAPE `\\\\`) ORDER BY id ASC', false, [121 => 'condition_0', 174 => 'condition_1']],
+ ['SELECT data.age AS age, data.id AS id, data.name AS name, data.id AS id FROM test_data data WHERE (data.description LIKE :condition_0 ESCAPE \'\\\\\') AND (data.description LIKE :condition_1 ESCAPE `\\\\`) ORDER BY id ASC', false, [121 => 'condition_0', 174 => 'condition_1']],
- );
+ ];
}
/**
@@ -89,120 +97,120 @@ public function testGetPlaceholderPositions($query, $isPositional, $expectedPara
public function dataExpandListParameters()
{
- return array(
+ return [
// Positional: Very simple with one needle
- array(
- "SELECT * FROM Foo WHERE foo IN (?)",
- array(array(1, 2, 3)),
- array(Connection::PARAM_INT_ARRAY),
+ [
+ 'SELECT * FROM Foo WHERE foo IN (?)',
+ [[1, 2, 3]],
+ [Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo IN (?, ?, ?)',
- array(1, 2, 3),
- array(ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER)
- ),
+ [1, 2, 3],
+ [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER],
+ ],
// Positional: One non-list before d one after list-needle
- array(
- "SELECT * FROM Foo WHERE foo = ? AND bar IN (?)",
- array("string", array(1, 2, 3)),
- array(ParameterType::STRING, Connection::PARAM_INT_ARRAY),
+ [
+ 'SELECT * FROM Foo WHERE foo = ? AND bar IN (?)',
+ ['string', [1, 2, 3]],
+ [ParameterType::STRING, Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?)',
- array("string", 1, 2, 3),
- array(ParameterType::STRING, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER)
- ),
+ ['string', 1, 2, 3],
+ [ParameterType::STRING, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER],
+ ],
// Positional: One non-list after list-needle
- array(
- "SELECT * FROM Foo WHERE bar IN (?) AND baz = ?",
- array(array(1, 2, 3), "foo"),
- array(Connection::PARAM_INT_ARRAY, ParameterType::STRING),
+ [
+ 'SELECT * FROM Foo WHERE bar IN (?) AND baz = ?',
+ [[1, 2, 3], 'foo'],
+ [Connection::PARAM_INT_ARRAY, ParameterType::STRING],
'SELECT * FROM Foo WHERE bar IN (?, ?, ?) AND baz = ?',
- array(1, 2, 3, "foo"),
- array(ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING)
- ),
+ [1, 2, 3, 'foo'],
+ [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING],
+ ],
// Positional: One non-list before and one after list-needle
- array(
- "SELECT * FROM Foo WHERE foo = ? AND bar IN (?) AND baz = ?",
- array(1, array(1, 2, 3), 4),
- array(ParameterType::INTEGER, Connection::PARAM_INT_ARRAY, ParameterType::INTEGER),
+ [
+ 'SELECT * FROM Foo WHERE foo = ? AND bar IN (?) AND baz = ?',
+ [1, [1, 2, 3], 4],
+ [ParameterType::INTEGER, Connection::PARAM_INT_ARRAY, ParameterType::INTEGER],
'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?) AND baz = ?',
- array(1, 1, 2, 3, 4),
- array(
+ [1, 1, 2, 3, 4],
+ [
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
- )
- ),
+ ],
+ ],
// Positional: Two lists
- array(
- "SELECT * FROM Foo WHERE foo IN (?, ?)",
- array(array(1, 2, 3), array(4, 5)),
- array(Connection::PARAM_INT_ARRAY, Connection::PARAM_INT_ARRAY),
+ [
+ 'SELECT * FROM Foo WHERE foo IN (?, ?)',
+ [[1, 2, 3], [4, 5]],
+ [Connection::PARAM_INT_ARRAY, Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo IN (?, ?, ?, ?, ?)',
- array(1, 2, 3, 4, 5),
- array(
+ [1, 2, 3, 4, 5],
+ [
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
- )
- ),
+ ],
+ ],
// Positional: Empty "integer" array DDC-1978
- array(
- "SELECT * FROM Foo WHERE foo IN (?)",
- array(array()),
- array(Connection::PARAM_INT_ARRAY),
+ [
+ 'SELECT * FROM Foo WHERE foo IN (?)',
+ [[]],
+ [Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo IN (NULL)',
- array(),
- array()
- ),
+ [],
+ [],
+ ],
// Positional: Empty "str" array DDC-1978
- array(
- "SELECT * FROM Foo WHERE foo IN (?)",
- array(array()),
- array(Connection::PARAM_STR_ARRAY),
+ [
+ 'SELECT * FROM Foo WHERE foo IN (?)',
+ [[]],
+ [Connection::PARAM_STR_ARRAY],
'SELECT * FROM Foo WHERE foo IN (NULL)',
- array(),
- array()
- ),
+ [],
+ [],
+ ],
// Positional: explicit keys for params and types
- array(
- "SELECT * FROM Foo WHERE foo = ? AND bar = ? AND baz = ?",
- array(1 => 'bar', 2 => 'baz', 0 => 1),
- array(2 => ParameterType::STRING, 1 => ParameterType::STRING),
+ [
'SELECT * FROM Foo WHERE foo = ? AND bar = ? AND baz = ?',
- array(1 => 'bar', 0 => 1, 2 => 'baz'),
- array(1 => ParameterType::STRING, 2 => ParameterType::STRING),
- ),
+ [1 => 'bar', 2 => 'baz', 0 => 1],
+ [2 => ParameterType::STRING, 1 => ParameterType::STRING],
+ 'SELECT * FROM Foo WHERE foo = ? AND bar = ? AND baz = ?',
+ [1 => 'bar', 0 => 1, 2 => 'baz'],
+ [1 => ParameterType::STRING, 2 => ParameterType::STRING],
+ ],
// Positional: explicit keys for array params and array types
- array(
- "SELECT * FROM Foo WHERE foo IN (?) AND bar IN (?) AND baz = ?",
- array(1 => array('bar1', 'bar2'), 2 => true, 0 => array(1, 2, 3)),
- array(2 => ParameterType::BOOLEAN, 1 => Connection::PARAM_STR_ARRAY, 0 => Connection::PARAM_INT_ARRAY),
+ [
+ 'SELECT * FROM Foo WHERE foo IN (?) AND bar IN (?) AND baz = ?',
+ [1 => ['bar1', 'bar2'], 2 => true, 0 => [1, 2, 3]],
+ [2 => ParameterType::BOOLEAN, 1 => Connection::PARAM_STR_ARRAY, 0 => Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo IN (?, ?, ?) AND bar IN (?, ?) AND baz = ?',
- array(1, 2, 3, 'bar1', 'bar2', true),
- array(
+ [1, 2, 3, 'bar1', 'bar2', true],
+ [
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::STRING,
ParameterType::STRING,
ParameterType::BOOLEAN,
- )
- ),
+ ],
+ ],
// Positional starts from 1: One non-list before and one after list-needle
- array(
- "SELECT * FROM Foo WHERE foo = ? AND bar IN (?) AND baz = ? AND foo IN (?)",
- array(1 => 1, 2 => array(1, 2, 3), 3 => 4, 4 => array(5, 6)),
- array(
+ [
+ 'SELECT * FROM Foo WHERE foo = ? AND bar IN (?) AND baz = ? AND foo IN (?)',
+ [1 => 1, 2 => [1, 2, 3], 3 => 4, 4 => [5, 6]],
+ [
1 => ParameterType::INTEGER,
2 => Connection::PARAM_INT_ARRAY,
3 => ParameterType::INTEGER,
4 => Connection::PARAM_INT_ARRAY,
- ),
+ ],
'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?) AND baz = ? AND foo IN (?, ?)',
- array(1, 1, 2, 3, 4, 5, 6),
- array(
+ [1, 1, 2, 3, 4, 5, 6],
+ [
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
@@ -210,194 +218,194 @@ public function dataExpandListParameters()
ParameterType::INTEGER,
ParameterType::INTEGER,
ParameterType::INTEGER,
- )
- ),
+ ],
+ ],
// Named parameters : Very simple with param int
- array(
- "SELECT * FROM Foo WHERE foo = :foo",
- array('foo'=>1),
- array('foo' => ParameterType::INTEGER),
+ [
+ 'SELECT * FROM Foo WHERE foo = :foo',
+ ['foo' => 1],
+ ['foo' => ParameterType::INTEGER],
'SELECT * FROM Foo WHERE foo = ?',
- array(1),
- array(ParameterType::INTEGER),
- ),
+ [1],
+ [ParameterType::INTEGER],
+ ],
// Named parameters : Very simple with param int and string
- array(
- "SELECT * FROM Foo WHERE foo = :foo AND bar = :bar",
- array('bar'=>'Some String','foo'=>1),
- array('foo' => ParameterType::INTEGER, 'bar' => ParameterType::STRING),
+ [
+ 'SELECT * FROM Foo WHERE foo = :foo AND bar = :bar',
+ ['bar' => 'Some String','foo' => 1],
+ ['foo' => ParameterType::INTEGER, 'bar' => ParameterType::STRING],
'SELECT * FROM Foo WHERE foo = ? AND bar = ?',
- array(1,'Some String'),
- array(ParameterType::INTEGER, ParameterType::STRING)
- ),
+ [1,'Some String'],
+ [ParameterType::INTEGER, ParameterType::STRING],
+ ],
// Named parameters : Very simple with one needle
- array(
- "SELECT * FROM Foo WHERE foo IN (:foo)",
- array('foo'=>array(1, 2, 3)),
- array('foo'=>Connection::PARAM_INT_ARRAY),
+ [
+ 'SELECT * FROM Foo WHERE foo IN (:foo)',
+ ['foo' => [1, 2, 3]],
+ ['foo' => Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo IN (?, ?, ?)',
- array(1, 2, 3),
- array(ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER),
- ),
+ [1, 2, 3],
+ [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER],
+ ],
// Named parameters: One non-list before d one after list-needle
- array(
- "SELECT * FROM Foo WHERE foo = :foo AND bar IN (:bar)",
- array('foo'=>"string", 'bar'=>array(1, 2, 3)),
- array('foo' => ParameterType::STRING, 'bar' => Connection::PARAM_INT_ARRAY),
+ [
+ 'SELECT * FROM Foo WHERE foo = :foo AND bar IN (:bar)',
+ ['foo' => 'string', 'bar' => [1, 2, 3]],
+ ['foo' => ParameterType::STRING, 'bar' => Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?)',
- array("string", 1, 2, 3),
- array(ParameterType::STRING, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER)
- ),
+ ['string', 1, 2, 3],
+ [ParameterType::STRING, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER],
+ ],
// Named parameters: One non-list after list-needle
- array(
- "SELECT * FROM Foo WHERE bar IN (:bar) AND baz = :baz",
- array('bar'=>array(1, 2, 3), 'baz'=>"foo"),
- array('bar'=>Connection::PARAM_INT_ARRAY, 'baz'=>ParameterType::STRING),
+ [
+ 'SELECT * FROM Foo WHERE bar IN (:bar) AND baz = :baz',
+ ['bar' => [1, 2, 3], 'baz' => 'foo'],
+ ['bar' => Connection::PARAM_INT_ARRAY, 'baz' => ParameterType::STRING],
'SELECT * FROM Foo WHERE bar IN (?, ?, ?) AND baz = ?',
- array(1, 2, 3, "foo"),
- array(ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING)
- ),
+ [1, 2, 3, 'foo'],
+ [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING],
+ ],
// Named parameters: One non-list before and one after list-needle
- array(
- "SELECT * FROM Foo WHERE foo = :foo AND bar IN (:bar) AND baz = :baz",
- array('bar'=>array(1, 2, 3),'foo'=>1, 'baz'=>4),
- array('bar'=>Connection::PARAM_INT_ARRAY, 'foo'=>ParameterType::INTEGER, 'baz'=>ParameterType::INTEGER),
+ [
+ 'SELECT * FROM Foo WHERE foo = :foo AND bar IN (:bar) AND baz = :baz',
+ ['bar' => [1, 2, 3],'foo' => 1, 'baz' => 4],
+ ['bar' => Connection::PARAM_INT_ARRAY, 'foo' => ParameterType::INTEGER, 'baz' => ParameterType::INTEGER],
'SELECT * FROM Foo WHERE foo = ? AND bar IN (?, ?, ?) AND baz = ?',
- array(1, 1, 2, 3, 4),
- array(ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER)
- ),
+ [1, 1, 2, 3, 4],
+ [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER],
+ ],
// Named parameters: Two lists
- array(
- "SELECT * FROM Foo WHERE foo IN (:a, :b)",
- array('b'=>array(4, 5),'a'=>array(1, 2, 3)),
- array('a'=>Connection::PARAM_INT_ARRAY, 'b'=>Connection::PARAM_INT_ARRAY),
+ [
+ 'SELECT * FROM Foo WHERE foo IN (:a, :b)',
+ ['b' => [4, 5],'a' => [1, 2, 3]],
+ ['a' => Connection::PARAM_INT_ARRAY, 'b' => Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo IN (?, ?, ?, ?, ?)',
- array(1, 2, 3, 4, 5),
- array(ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER)
- ),
+ [1, 2, 3, 4, 5],
+ [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER],
+ ],
// Named parameters : With the same name arg type string
- array(
- "SELECT * FROM Foo WHERE foo <> :arg AND bar = :arg",
- array('arg'=>"Some String"),
- array('arg'=>ParameterType::STRING),
+ [
+ 'SELECT * FROM Foo WHERE foo <> :arg AND bar = :arg',
+ ['arg' => 'Some String'],
+ ['arg' => ParameterType::STRING],
'SELECT * FROM Foo WHERE foo <> ? AND bar = ?',
- array("Some String","Some String"),
- array(ParameterType::STRING,ParameterType::STRING,)
- ),
+ ['Some String','Some String'],
+ [ParameterType::STRING,ParameterType::STRING],
+ ],
// Named parameters : With the same name arg
- array(
- "SELECT * FROM Foo WHERE foo IN (:arg) AND NOT bar IN (:arg)",
- array('arg'=>array(1, 2, 3)),
- array('arg'=>Connection::PARAM_INT_ARRAY),
+ [
+ 'SELECT * FROM Foo WHERE foo IN (:arg) AND NOT bar IN (:arg)',
+ ['arg' => [1, 2, 3]],
+ ['arg' => Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo IN (?, ?, ?) AND NOT bar IN (?, ?, ?)',
- array(1, 2, 3, 1, 2, 3),
- array(ParameterType::INTEGER,ParameterType::INTEGER, ParameterType::INTEGER,ParameterType::INTEGER,ParameterType::INTEGER, ParameterType::INTEGER)
- ),
+ [1, 2, 3, 1, 2, 3],
+ [ParameterType::INTEGER,ParameterType::INTEGER, ParameterType::INTEGER,ParameterType::INTEGER,ParameterType::INTEGER, ParameterType::INTEGER],
+ ],
// Named parameters : Same name, other name in between DBAL-299
- array(
- "SELECT * FROM Foo WHERE (:foo = 2) AND (:bar = 3) AND (:foo = 2)",
- array('foo'=>2,'bar'=>3),
- array('foo'=>ParameterType::INTEGER,'bar'=>ParameterType::INTEGER),
+ [
+ 'SELECT * FROM Foo WHERE (:foo = 2) AND (:bar = 3) AND (:foo = 2)',
+ ['foo' => 2,'bar' => 3],
+ ['foo' => ParameterType::INTEGER,'bar' => ParameterType::INTEGER],
'SELECT * FROM Foo WHERE (? = 2) AND (? = 3) AND (? = 2)',
- array(2, 3, 2),
- array(ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER)
- ),
+ [2, 3, 2],
+ [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::INTEGER],
+ ],
// Named parameters : Empty "integer" array DDC-1978
- array(
- "SELECT * FROM Foo WHERE foo IN (:foo)",
- array('foo'=>array()),
- array('foo'=>Connection::PARAM_INT_ARRAY),
+ [
+ 'SELECT * FROM Foo WHERE foo IN (:foo)',
+ ['foo' => []],
+ ['foo' => Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo IN (NULL)',
- array(),
- array()
- ),
+ [],
+ [],
+ ],
// Named parameters : Two empty "str" array DDC-1978
- array(
- "SELECT * FROM Foo WHERE foo IN (:foo) OR bar IN (:bar)",
- array('foo'=>array(), 'bar'=>array()),
- array('foo'=>Connection::PARAM_STR_ARRAY, 'bar'=>Connection::PARAM_STR_ARRAY),
+ [
+ 'SELECT * FROM Foo WHERE foo IN (:foo) OR bar IN (:bar)',
+ ['foo' => [], 'bar' => []],
+ ['foo' => Connection::PARAM_STR_ARRAY, 'bar' => Connection::PARAM_STR_ARRAY],
'SELECT * FROM Foo WHERE foo IN (NULL) OR bar IN (NULL)',
- array(),
- array()
- ),
- array(
- "SELECT * FROM Foo WHERE foo IN (:foo) OR bar = :bar OR baz = :baz",
- array('foo' => array(1, 2), 'bar' => 'bar', 'baz' => 'baz'),
- array('foo' => Connection::PARAM_INT_ARRAY, 'baz' => 'string'),
+ [],
+ [],
+ ],
+ [
+ 'SELECT * FROM Foo WHERE foo IN (:foo) OR bar = :bar OR baz = :baz',
+ ['foo' => [1, 2], 'bar' => 'bar', 'baz' => 'baz'],
+ ['foo' => Connection::PARAM_INT_ARRAY, 'baz' => 'string'],
'SELECT * FROM Foo WHERE foo IN (?, ?) OR bar = ? OR baz = ?',
- array(1, 2, 'bar', 'baz'),
- array(ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING, 'string')
- ),
- array(
- "SELECT * FROM Foo WHERE foo IN (:foo) OR bar = :bar",
- array('foo' => array(1, 2), 'bar' => 'bar'),
- array('foo' => Connection::PARAM_INT_ARRAY),
+ [1, 2, 'bar', 'baz'],
+ [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING, 'string'],
+ ],
+ [
+ 'SELECT * FROM Foo WHERE foo IN (:foo) OR bar = :bar',
+ ['foo' => [1, 2], 'bar' => 'bar'],
+ ['foo' => Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo IN (?, ?) OR bar = ?',
- array(1, 2, 'bar'),
- array(ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING)
- ),
+ [1, 2, 'bar'],
+ [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING],
+ ],
// Params/types with colons
- array(
- "SELECT * FROM Foo WHERE foo = :foo OR bar = :bar",
- array(':foo' => 'foo', ':bar' => 'bar'),
- array(':foo' => ParameterType::INTEGER),
+ [
+ 'SELECT * FROM Foo WHERE foo = :foo OR bar = :bar',
+ [':foo' => 'foo', ':bar' => 'bar'],
+ [':foo' => ParameterType::INTEGER],
'SELECT * FROM Foo WHERE foo = ? OR bar = ?',
- array('foo', 'bar'),
- array(ParameterType::INTEGER, ParameterType::STRING)
- ),
- array(
- "SELECT * FROM Foo WHERE foo = :foo OR bar = :bar",
- array(':foo' => 'foo', ':bar' => 'bar'),
- array(':foo' => ParameterType::INTEGER, 'bar' => ParameterType::INTEGER),
+ ['foo', 'bar'],
+ [ParameterType::INTEGER, ParameterType::STRING],
+ ],
+ [
+ 'SELECT * FROM Foo WHERE foo = :foo OR bar = :bar',
+ [':foo' => 'foo', ':bar' => 'bar'],
+ [':foo' => ParameterType::INTEGER, 'bar' => ParameterType::INTEGER],
'SELECT * FROM Foo WHERE foo = ? OR bar = ?',
- array('foo', 'bar'),
- array(ParameterType::INTEGER, ParameterType::INTEGER)
- ),
- array(
- "SELECT * FROM Foo WHERE foo IN (:foo) OR bar = :bar",
- array(':foo' => array(1, 2), ':bar' => 'bar'),
- array('foo' => Connection::PARAM_INT_ARRAY),
+ ['foo', 'bar'],
+ [ParameterType::INTEGER, ParameterType::INTEGER],
+ ],
+ [
+ 'SELECT * FROM Foo WHERE foo IN (:foo) OR bar = :bar',
+ [':foo' => [1, 2], ':bar' => 'bar'],
+ ['foo' => Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo IN (?, ?) OR bar = ?',
- array(1, 2, 'bar'),
- array(ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING)
- ),
- array(
- "SELECT * FROM Foo WHERE foo IN (:foo) OR bar = :bar",
- array('foo' => array(1, 2), 'bar' => 'bar'),
- array(':foo' => Connection::PARAM_INT_ARRAY),
+ [1, 2, 'bar'],
+ [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING],
+ ],
+ [
+ 'SELECT * FROM Foo WHERE foo IN (:foo) OR bar = :bar',
+ ['foo' => [1, 2], 'bar' => 'bar'],
+ [':foo' => Connection::PARAM_INT_ARRAY],
'SELECT * FROM Foo WHERE foo IN (?, ?) OR bar = ?',
- array(1, 2, 'bar'),
- array(ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING)
- ),
+ [1, 2, 'bar'],
+ [ParameterType::INTEGER, ParameterType::INTEGER, ParameterType::STRING],
+ ],
// DBAL-522 - null valued parameters are not considered
- array(
+ [
'INSERT INTO Foo (foo, bar) values (:foo, :bar)',
- array('foo' => 1, 'bar' => null),
- array(':foo' => ParameterType::INTEGER, ':bar' => ParameterType::NULL),
+ ['foo' => 1, 'bar' => null],
+ [':foo' => ParameterType::INTEGER, ':bar' => ParameterType::NULL],
'INSERT INTO Foo (foo, bar) values (?, ?)',
- array(1, null),
- array(ParameterType::INTEGER, ParameterType::NULL)
- ),
- array(
+ [1, null],
+ [ParameterType::INTEGER, ParameterType::NULL],
+ ],
+ [
'INSERT INTO Foo (foo, bar) values (?, ?)',
- array(1, null),
- array(ParameterType::INTEGER, ParameterType::NULL),
+ [1, null],
+ [ParameterType::INTEGER, ParameterType::NULL],
'INSERT INTO Foo (foo, bar) values (?, ?)',
- array(1, null),
- array(ParameterType::INTEGER, ParameterType::NULL)
- ),
+ [1, null],
+ [ParameterType::INTEGER, ParameterType::NULL],
+ ],
// DBAL-1205 - Escaped single quotes SQL- and C-Style
- array(
+ [
"SELECT * FROM Foo WHERE foo = :foo||''':not_a_param''\\'' OR bar = ''':not_a_param''\\'':bar",
- array(':foo' => 1, ':bar' => 2),
- array(':foo' => ParameterType::INTEGER, 'bar' => ParameterType::INTEGER),
+ [':foo' => 1, ':bar' => 2],
+ [':foo' => ParameterType::INTEGER, 'bar' => ParameterType::INTEGER],
'SELECT * FROM Foo WHERE foo = ?||\'\'\':not_a_param\'\'\\\'\' OR bar = \'\'\':not_a_param\'\'\\\'\'?',
- array(1, 2),
- array(ParameterType::INTEGER, ParameterType::INTEGER)
- ),
- );
+ [1, 2],
+ [ParameterType::INTEGER, ParameterType::INTEGER],
+ ],
+ ];
}
/**
@@ -405,55 +413,55 @@ public function dataExpandListParameters()
*/
public function testExpandListParameters($q, $p, $t, $expectedQuery, $expectedParams, $expectedTypes)
{
- list($query, $params, $types) = SQLParserUtils::expandListParameters($q, $p, $t);
+ [$query, $params, $types] = SQLParserUtils::expandListParameters($q, $p, $t);
- self::assertEquals($expectedQuery, $query, "Query was not rewritten correctly.");
- self::assertEquals($expectedParams, $params, "Params dont match");
- self::assertEquals($expectedTypes, $types, "Types dont match");
+ self::assertEquals($expectedQuery, $query, 'Query was not rewritten correctly.');
+ self::assertEquals($expectedParams, $params, 'Params dont match');
+ self::assertEquals($expectedTypes, $types, 'Types dont match');
}
public function dataQueryWithMissingParameters()
{
- return array(
- array(
- "SELECT * FROM foo WHERE bar = :param",
- array('other' => 'val'),
- array(),
- ),
- array(
- "SELECT * FROM foo WHERE bar = :param",
- array(),
- array(),
- ),
- array(
- "SELECT * FROM foo WHERE bar = :param",
- array(),
- array('param' => Connection::PARAM_INT_ARRAY),
- ),
- array(
- "SELECT * FROM foo WHERE bar = :param",
- array(),
- array(':param' => Connection::PARAM_INT_ARRAY),
- ),
- array(
- "SELECT * FROM foo WHERE bar = :param",
- array(),
- array('bar' => Connection::PARAM_INT_ARRAY),
- ),
- array(
- "SELECT * FROM foo WHERE bar = :param",
- array('bar' => 'value'),
- array('bar' => Connection::PARAM_INT_ARRAY),
- ),
- );
+ return [
+ [
+ 'SELECT * FROM foo WHERE bar = :param',
+ ['other' => 'val'],
+ [],
+ ],
+ [
+ 'SELECT * FROM foo WHERE bar = :param',
+ [],
+ [],
+ ],
+ [
+ 'SELECT * FROM foo WHERE bar = :param',
+ [],
+ ['param' => Connection::PARAM_INT_ARRAY],
+ ],
+ [
+ 'SELECT * FROM foo WHERE bar = :param',
+ [],
+ [':param' => Connection::PARAM_INT_ARRAY],
+ ],
+ [
+ 'SELECT * FROM foo WHERE bar = :param',
+ [],
+ ['bar' => Connection::PARAM_INT_ARRAY],
+ ],
+ [
+ 'SELECT * FROM foo WHERE bar = :param',
+ ['bar' => 'value'],
+ ['bar' => Connection::PARAM_INT_ARRAY],
+ ],
+ ];
}
/**
* @dataProvider dataQueryWithMissingParameters
*/
- public function testExceptionIsThrownForMissingParam($query, $params, $types = array())
+ public function testExceptionIsThrownForMissingParam($query, $params, $types = [])
{
- $this->expectException('Doctrine\DBAL\SQLParserUtilsException');
+ $this->expectException(SQLParserUtilsException::class);
$this->expectExceptionMessage('Value for :param not found in params array. Params array key should be "param"');
SQLParserUtils::expandListParameters($query, $params, $types);
diff --git a/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php
index 13bf74f6aff..046118f91fa 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php
@@ -5,8 +5,9 @@
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Types\Type;
+use PHPUnit\Framework\TestCase;
-class ColumnDiffTest extends \PHPUnit\Framework\TestCase
+class ColumnDiffTest extends TestCase
{
/**
* @group DBAL-1255
@@ -14,15 +15,15 @@ class ColumnDiffTest extends \PHPUnit\Framework\TestCase
public function testPreservesOldColumnNameQuotation()
{
$fromColumn = new Column('"foo"', Type::getType(Type::INTEGER));
- $toColumn = new Column('bar', Type::getType(Type::INTEGER));
+ $toColumn = new Column('bar', Type::getType(Type::INTEGER));
- $columnDiff = new ColumnDiff('"foo"', $toColumn, array());
+ $columnDiff = new ColumnDiff('"foo"', $toColumn, []);
self::assertTrue($columnDiff->getOldColumnName()->isQuoted());
- $columnDiff = new ColumnDiff('"foo"', $toColumn, array(), $fromColumn);
+ $columnDiff = new ColumnDiff('"foo"', $toColumn, [], $fromColumn);
self::assertTrue($columnDiff->getOldColumnName()->isQuoted());
- $columnDiff = new ColumnDiff('foo', $toColumn, array(), $fromColumn);
+ $columnDiff = new ColumnDiff('foo', $toColumn, [], $fromColumn);
self::assertTrue($columnDiff->getOldColumnName()->isQuoted());
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php b/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php
index c78595442fa..51fe749e28e 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php
@@ -2,17 +2,20 @@
namespace Doctrine\Tests\DBAL\Schema;
-use Doctrine\DBAL\Exception\InvalidArgumentException;
+use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\SqlitePlatform;
+use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Types\Type;
+use PHPUnit\Framework\TestCase;
-class ColumnTest extends \PHPUnit\Framework\TestCase
+class ColumnTest extends TestCase
{
public function testGet()
{
$column = $this->createColumn();
- self::assertEquals("foo", $column->getName());
+ self::assertEquals('foo', $column->getName());
self::assertSame(Type::getType('string'), $column->getType());
self::assertEquals(200, $column->getLength());
@@ -21,14 +24,14 @@ public function testGet()
self::assertTrue($column->getUnsigned());
self::assertFalse($column->getNotNull());
self::assertTrue($column->getFixed());
- self::assertEquals("baz", $column->getDefault());
+ self::assertEquals('baz', $column->getDefault());
- self::assertEquals(array('foo' => 'bar'), $column->getPlatformOptions());
+ self::assertEquals(['foo' => 'bar'], $column->getPlatformOptions());
self::assertTrue($column->hasPlatformOption('foo'));
self::assertEquals('bar', $column->getPlatformOption('foo'));
self::assertFalse($column->hasPlatformOption('bar'));
- self::assertEquals(array('bar' => 'baz'), $column->getCustomSchemaOptions());
+ self::assertEquals(['bar' => 'baz'], $column->getCustomSchemaOptions());
self::assertTrue($column->hasCustomSchemaOption('bar'));
self::assertEquals('baz', $column->getCustomSchemaOption('bar'));
self::assertFalse($column->hasCustomSchemaOption('foo'));
@@ -36,7 +39,7 @@ public function testGet()
public function testToArray()
{
- $expected = array(
+ $expected = [
'name' => 'foo',
'type' => Type::getType('string'),
'default' => 'baz',
@@ -50,8 +53,8 @@ public function testToArray()
'columnDefinition' => null,
'comment' => null,
'foo' => 'bar',
- 'bar' => 'baz'
- );
+ 'bar' => 'baz',
+ ];
self::assertEquals($expected, $this->createColumn()->toArray());
}
@@ -83,7 +86,7 @@ public function testOptionsShouldNotBeIgnored() : void
*/
public function createColumn()
{
- $options = array(
+ $options = [
'length' => 200,
'precision' => 5,
'scale' => 2,
@@ -91,12 +94,12 @@ public function createColumn()
'notnull' => false,
'fixed' => true,
'default' => 'baz',
- 'platformOptions' => array('foo' => 'bar'),
- 'customSchemaOptions' => array('bar' => 'baz'),
- );
+ 'platformOptions' => ['foo' => 'bar'],
+ 'customSchemaOptions' => ['bar' => 'baz'],
+ ];
$string = Type::getType('string');
- return new Column("foo", $string, $options);
+ return new Column('foo', $string, $options);
}
/**
@@ -106,18 +109,18 @@ public function createColumn()
public function testQuotedColumnName()
{
$string = Type::getType('string');
- $column = new Column("`bar`", $string, array());
+ $column = new Column('`bar`', $string, []);
- $mysqlPlatform = new \Doctrine\DBAL\Platforms\MySqlPlatform();
- $sqlitePlatform = new \Doctrine\DBAL\Platforms\SqlitePlatform();
+ $mysqlPlatform = new MySqlPlatform();
+ $sqlitePlatform = new SqlitePlatform();
self::assertEquals('bar', $column->getName());
self::assertEquals('`bar`', $column->getQuotedName($mysqlPlatform));
self::assertEquals('"bar"', $column->getQuotedName($sqlitePlatform));
- $column = new Column("[bar]", $string);
+ $column = new Column('[bar]', $string);
- $sqlServerPlatform = new \Doctrine\DBAL\Platforms\SQLServerPlatform();
+ $sqlServerPlatform = new SQLServerPlatform();
self::assertEquals('bar', $column->getName());
self::assertEquals('[bar]', $column->getQuotedName($sqlServerPlatform));
@@ -129,7 +132,7 @@ public function testQuotedColumnName()
*/
public function testIsQuoted($columnName, $isQuoted)
{
- $type = Type::getType('string');
+ $type = Type::getType('string');
$column = new Column($columnName, $type);
self::assertSame($isQuoted, $column->isQuoted());
@@ -137,12 +140,12 @@ public function testIsQuoted($columnName, $isQuoted)
public function getIsQuoted()
{
- return array(
- array('bar', false),
- array('`bar`', true),
- array('"bar"', true),
- array('[bar]', true),
- );
+ return [
+ ['bar', false],
+ ['`bar`', true],
+ ['"bar"', true],
+ ['[bar]', true],
+ ];
}
/**
@@ -150,11 +153,11 @@ public function getIsQuoted()
*/
public function testColumnComment()
{
- $column = new Column("bar", Type::getType('string'));
+ $column = new Column('bar', Type::getType('string'));
self::assertNull($column->getComment());
- $column->setComment("foo");
- self::assertEquals("foo", $column->getComment());
+ $column->setComment('foo');
+ self::assertEquals('foo', $column->getComment());
$columnArray = $column->toArray();
self::assertArrayHasKey('comment', $columnArray);
diff --git a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
index 24d097c3006..43431ea9f9d 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
@@ -1,21 +1,4 @@
.
- */
namespace Doctrine\Tests\DBAL\Schema;
@@ -31,182 +14,189 @@
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\Type;
+use PHPUnit\Framework\TestCase;
use function array_keys;
/**
- * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
- * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
- * @license http://ez.no/licenses/new_bsd New BSD License
- * @since 2.0
- * @version $Revision$
- * @author Benjamin Eberlei
*/
-class ComparatorTest extends \PHPUnit\Framework\TestCase
+class ComparatorTest extends TestCase
{
public function testCompareSame1()
{
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => new Column('integerfield1', Type::getType('integer' ) ),
- )
+ $schema1 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
+ 'integerfield1' => new Column('integerfield1', Type::getType('integer')),
+ ]
),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
- 'integerfield1' => new Column('integerfield1', Type::getType('integer') ),
- )
+ ]);
+ $schema2 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
+ 'integerfield1' => new Column('integerfield1', Type::getType('integer')),
+ ]
),
- ) );
+ ]);
- $expected = new SchemaDiff();
+ $expected = new SchemaDiff();
$expected->fromSchema = $schema1;
- self::assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
+ self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2));
}
public function testCompareSame2()
{
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
+ $schema1 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
'integerfield1' => new Column('integerfield1', Type::getType('integer')),
'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- )
+ ]
),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
+ ]);
+ $schema2 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
'integerfield2' => new Column('integerfield2', Type::getType('integer')),
'integerfield1' => new Column('integerfield1', Type::getType('integer')),
- )
+ ]
),
- ) );
+ ]);
- $expected = new SchemaDiff();
+ $expected = new SchemaDiff();
$expected->fromSchema = $schema1;
- self::assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
+ self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2));
}
public function testCompareMissingTable()
{
- $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig;
- $table = new Table('bugdb', array ('integerfield1' => new Column('integerfield1', Type::getType('integer'))));
+ $schemaConfig = new SchemaConfig();
+ $table = new Table('bugdb', ['integerfield1' => new Column('integerfield1', Type::getType('integer'))]);
$table->setSchemaConfig($schemaConfig);
- $schema1 = new Schema( array($table), array(), $schemaConfig );
- $schema2 = new Schema( array(), array(), $schemaConfig );
+ $schema1 = new Schema([$table], [], $schemaConfig);
+ $schema2 = new Schema([], [], $schemaConfig);
- $expected = new SchemaDiff( array(), array(), array('bugdb' => $table), $schema1 );
+ $expected = new SchemaDiff([], [], ['bugdb' => $table], $schema1);
- self::assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
+ self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2));
}
public function testCompareNewTable()
{
- $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig;
- $table = new Table('bugdb', array ('integerfield1' => new Column('integerfield1', Type::getType('integer'))));
+ $schemaConfig = new SchemaConfig();
+ $table = new Table('bugdb', ['integerfield1' => new Column('integerfield1', Type::getType('integer'))]);
$table->setSchemaConfig($schemaConfig);
- $schema1 = new Schema( array(), array(), $schemaConfig );
- $schema2 = new Schema( array($table), array(), $schemaConfig );
+ $schema1 = new Schema([], [], $schemaConfig);
+ $schema2 = new Schema([$table], [], $schemaConfig);
- $expected = new SchemaDiff( array('bugdb' => $table), array(), array(), $schema1 );
+ $expected = new SchemaDiff(['bugdb' => $table], [], [], $schema1);
- self::assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
+ self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2));
}
public function testCompareOnlyAutoincrementChanged()
{
- $column1 = new Column('foo', Type::getType('integer'), array('autoincrement' => true));
- $column2 = new Column('foo', Type::getType('integer'), array('autoincrement' => false));
+ $column1 = new Column('foo', Type::getType('integer'), ['autoincrement' => true]);
+ $column2 = new Column('foo', Type::getType('integer'), ['autoincrement' => false]);
- $comparator = new Comparator();
+ $comparator = new Comparator();
$changedProperties = $comparator->diffColumn($column1, $column2);
- self::assertEquals(array('autoincrement'), $changedProperties);
+ self::assertEquals(['autoincrement'], $changedProperties);
}
public function testCompareMissingField()
{
$missingColumn = new Column('integerfield1', Type::getType('integer'));
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
+ $schema1 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
'integerfield1' => $missingColumn,
'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- )
+ ]
),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
+ ]);
+ $schema2 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- )
+ ]
),
- ) );
-
- $expected = new SchemaDiff ( array(),
- array (
- 'bugdb' => new TableDiff( 'bugdb', array(), array(),
- array (
- 'integerfield1' => $missingColumn,
- )
- )
- )
+ ]);
+
+ $expected = new SchemaDiff(
+ [],
+ [
+ 'bugdb' => new TableDiff(
+ 'bugdb',
+ [],
+ [],
+ ['integerfield1' => $missingColumn]
+ ),
+ ]
);
- $expected->fromSchema = $schema1;
+ $expected->fromSchema = $schema1;
$expected->changedTables['bugdb']->fromTable = $schema1->getTable('bugdb');
- self::assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
+ self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2));
}
public function testCompareNewField()
{
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
+ $schema1 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
'integerfield1' => new Column('integerfield1', Type::getType('integer')),
- )
+ ]
),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
+ ]);
+ $schema2 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
'integerfield1' => new Column('integerfield1', Type::getType('integer')),
'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- )
+ ]
),
- ) );
-
- $expected = new SchemaDiff ( array(),
- array (
- 'bugdb' => new TableDiff ('bugdb',
- array (
+ ]);
+
+ $expected = new SchemaDiff(
+ [],
+ [
+ 'bugdb' => new TableDiff(
+ 'bugdb',
+ [
'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- )
+ ]
),
- )
+ ]
);
- $expected->fromSchema = $schema1;
+ $expected->fromSchema = $schema1;
$expected->changedTables['bugdb']->fromTable = $schema1->getTable('bugdb');
- self::assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
+ self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2));
}
- public function testCompareChangedColumns_ChangeType()
+ public function testCompareChangedColumnsChangeType()
{
$column1 = new Column('charfield1', Type::getType('string'));
$column2 = new Column('charfield1', Type::getType('integer'));
$c = new Comparator();
- self::assertEquals(array('type'), $c->diffColumn($column1, $column2));
- self::assertEquals(array(), $c->diffColumn($column1, $column1));
+ self::assertEquals(['type'], $c->diffColumn($column1, $column2));
+ self::assertEquals([], $c->diffColumn($column1, $column1));
}
- public function testCompareChangedColumns_ChangeCustomSchemaOption()
+ public function testCompareChangedColumnsChangeCustomSchemaOption()
{
$column1 = new Column('charfield1', Type::getType('string'));
$column2 = new Column('charfield1', Type::getType('string'));
@@ -218,216 +208,245 @@ public function testCompareChangedColumns_ChangeCustomSchemaOption()
$column2->setCustomSchemaOption('foo2', 'bar2');
$c = new Comparator();
- self::assertEquals(array('foo1', 'foo2'), $c->diffColumn($column1, $column2));
- self::assertEquals(array(), $c->diffColumn($column1, $column1));
+ self::assertEquals(['foo1', 'foo2'], $c->diffColumn($column1, $column2));
+ self::assertEquals([], $c->diffColumn($column1, $column1));
}
- public function testCompareChangeColumns_MultipleNewColumnsRename()
+ public function testCompareChangeColumnsMultipleNewColumnsRename()
{
- $tableA = new Table("foo");
+ $tableA = new Table('foo');
$tableA->addColumn('datefield1', 'datetime');
- $tableB = new Table("foo");
+ $tableB = new Table('foo');
$tableB->addColumn('new_datefield1', 'datetime');
$tableB->addColumn('new_datefield2', 'datetime');
- $c = new Comparator();
+ $c = new Comparator();
$tableDiff = $c->diffTable($tableA, $tableB);
- self::assertCount(1, $tableDiff->renamedColumns, "we should have one rename datefield1 => new_datefield1.");
+ self::assertCount(1, $tableDiff->renamedColumns, 'we should have one rename datefield1 => new_datefield1.');
self::assertArrayHasKey('datefield1', $tableDiff->renamedColumns, "'datefield1' should be set to be renamed to new_datefield1");
self::assertCount(1, $tableDiff->addedColumns, "'new_datefield2' should be added");
self::assertArrayHasKey('new_datefield2', $tableDiff->addedColumns, "'new_datefield2' should be added, not created through renaming!");
- self::assertCount(0, $tableDiff->removedColumns, "Nothing should be removed.");
- self::assertCount(0, $tableDiff->changedColumns, "Nothing should be changed as all fields old & new have diff names.");
+ self::assertCount(0, $tableDiff->removedColumns, 'Nothing should be removed.');
+ self::assertCount(0, $tableDiff->changedColumns, 'Nothing should be changed as all fields old & new have diff names.');
}
public function testCompareRemovedIndex()
{
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
+ $schema1 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
'integerfield1' => new Column('integerfield1', Type::getType('integer')),
'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- ),
- array (
- 'primary' => new Index('primary',
- array(
- 'integerfield1'
- ),
+ ],
+ [
+ 'primary' => new Index(
+ 'primary',
+ ['integerfield1'],
true
- )
- )
+ ),
+ ]
),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
+ ]);
+ $schema2 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
'integerfield1' => new Column('integerfield1', Type::getType('integer')),
'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- )
+ ]
),
- ) );
-
- $expected = new SchemaDiff ( array(),
- array (
- 'bugdb' => new TableDiff( 'bugdb', array(), array(), array(), array(), array(),
- array (
- 'primary' => new Index('primary',
- array(
- 'integerfield1'
+ ]);
+
+ $expected = new SchemaDiff(
+ [],
+ [
+ 'bugdb' => new TableDiff(
+ 'bugdb',
+ [],
+ [],
+ [],
+ [],
+ [],
+ [
+ 'primary' => new Index(
+ 'primary',
+ ['integerfield1'],
+ true
),
- true
- )
- )
+ ]
),
- )
+ ]
);
- $expected->fromSchema = $schema1;
+ $expected->fromSchema = $schema1;
$expected->changedTables['bugdb']->fromTable = $schema1->getTable('bugdb');
- self::assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
+ self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2));
}
public function testCompareNewIndex()
{
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
+ $schema1 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
'integerfield1' => new Column('integerfield1', Type::getType('integer')),
'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- )
+ ]
),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
+ ]);
+ $schema2 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
'integerfield1' => new Column('integerfield1', Type::getType('integer')),
'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- ),
- array (
- 'primary' => new Index('primary',
- array(
- 'integerfield1'
- ),
+ ],
+ [
+ 'primary' => new Index(
+ 'primary',
+ ['integerfield1'],
true
- )
- )
+ ),
+ ]
),
- ) );
-
- $expected = new SchemaDiff ( array(),
- array (
- 'bugdb' => new TableDiff( 'bugdb', array(), array(), array(),
- array (
- 'primary' => new Index('primary',
- array(
- 'integerfield1'
- ),
+ ]);
+
+ $expected = new SchemaDiff(
+ [],
+ [
+ 'bugdb' => new TableDiff(
+ 'bugdb',
+ [],
+ [],
+ [],
+ [
+ 'primary' => new Index(
+ 'primary',
+ ['integerfield1'],
true
- )
- )
+ ),
+ ]
),
- )
+ ]
);
- $expected->fromSchema = $schema1;
+ $expected->fromSchema = $schema1;
$expected->changedTables['bugdb']->fromTable = $schema1->getTable('bugdb');
- self::assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
+ self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2));
}
public function testCompareChangedIndex()
{
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
+ $schema1 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
'integerfield1' => new Column('integerfield1', Type::getType('integer')),
'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- ),
- array (
- 'primary' => new Index('primary',
- array(
- 'integerfield1'
- ),
+ ],
+ [
+ 'primary' => new Index(
+ 'primary',
+ ['integerfield1'],
true
- )
- )
+ ),
+ ]
),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
+ ]);
+ $schema2 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
'integerfield1' => new Column('integerfield1', Type::getType('integer')),
'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- ),
- array (
- 'primary' => new Index('primary',
- array('integerfield1', 'integerfield2'),
+ ],
+ [
+ 'primary' => new Index(
+ 'primary',
+ ['integerfield1', 'integerfield2'],
true
- )
- )
+ ),
+ ]
),
- ) );
-
- $expected = new SchemaDiff ( array(),
- array (
- 'bugdb' => new TableDiff( 'bugdb', array(), array(), array(), array(),
- array (
- 'primary' => new Index('primary',
- array(
+ ]);
+
+ $expected = new SchemaDiff(
+ [],
+ [
+ 'bugdb' => new TableDiff(
+ 'bugdb',
+ [],
+ [],
+ [],
+ [],
+ [
+ 'primary' => new Index(
+ 'primary',
+ [
'integerfield1',
- 'integerfield2'
- ),
+ 'integerfield2',
+ ],
true
- )
- )
+ ),
+ ]
),
- )
+ ]
);
- $expected->fromSchema = $schema1;
+ $expected->fromSchema = $schema1;
$expected->changedTables['bugdb']->fromTable = $schema1->getTable('bugdb');
- self::assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ));
+ self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2));
}
public function testCompareChangedIndexFieldPositions()
{
- $schema1 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
+ $schema1 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
'integerfield1' => new Column('integerfield1', Type::getType('integer')),
'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- ),
- array (
- 'primary' => new Index('primary', array('integerfield1', 'integerfield2'), true)
- )
+ ],
+ [
+ 'primary' => new Index('primary', ['integerfield1', 'integerfield2'], true),
+ ]
),
- ) );
- $schema2 = new Schema( array(
- 'bugdb' => new Table('bugdb',
- array (
+ ]);
+ $schema2 = new Schema([
+ 'bugdb' => new Table(
+ 'bugdb',
+ [
'integerfield1' => new Column('integerfield1', Type::getType('integer')),
'integerfield2' => new Column('integerfield2', Type::getType('integer')),
- ),
- array (
- 'primary' => new Index('primary', array('integerfield2', 'integerfield1'), true)
- )
+ ],
+ [
+ 'primary' => new Index('primary', ['integerfield2', 'integerfield1'], true),
+ ]
),
- ) );
-
- $expected = new SchemaDiff ( array(),
- array (
- 'bugdb' => new TableDiff('bugdb', array(), array(), array(), array(),
- array (
- 'primary' => new Index('primary', array('integerfield2', 'integerfield1'), true)
- )
+ ]);
+
+ $expected = new SchemaDiff(
+ [],
+ [
+ 'bugdb' => new TableDiff(
+ 'bugdb',
+ [],
+ [],
+ [],
+ [],
+ [
+ 'primary' => new Index('primary', ['integerfield2', 'integerfield1'], true),
+ ]
),
- )
+ ]
);
- $expected->fromSchema = $schema1;
+ $expected->fromSchema = $schema1;
$expected->changedTables['bugdb']->fromTable = $schema1->getTable('bugdb');
- self::assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ));
+ self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2));
}
public function testCompareSequences()
@@ -447,11 +466,11 @@ public function testCompareSequences()
public function testRemovedSequence()
{
$schema1 = new Schema();
- $seq = $schema1->createSequence('foo');
+ $seq = $schema1->createSequence('foo');
$schema2 = new Schema();
- $c = new Comparator();
+ $c = new Comparator();
$diffSchema = $c->compare($schema1, $schema2);
self::assertCount(1, $diffSchema->removedSequences);
@@ -463,9 +482,9 @@ public function testAddedSequence()
$schema1 = new Schema();
$schema2 = new Schema();
- $seq = $schema2->createSequence('foo');
+ $seq = $schema2->createSequence('foo');
- $c = new Comparator();
+ $c = new Comparator();
$diffSchema = $c->compare($schema1, $schema2);
self::assertCount(1, $diffSchema->newSequences);
@@ -474,82 +493,82 @@ public function testAddedSequence()
public function testTableAddForeignKey()
{
- $tableForeign = new Table("bar");
+ $tableForeign = new Table('bar');
$tableForeign->addColumn('id', 'integer');
- $table1 = new Table("foo");
+ $table1 = new Table('foo');
$table1->addColumn('fk', 'integer');
- $table2 = new Table("foo");
+ $table2 = new Table('foo');
$table2->addColumn('fk', 'integer');
- $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id'));
+ $table2->addForeignKeyConstraint($tableForeign, ['fk'], ['id']);
- $c = new Comparator();
+ $c = new Comparator();
$tableDiff = $c->diffTable($table1, $table2);
- self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
+ self::assertInstanceOf(TableDiff::class, $tableDiff);
self::assertCount(1, $tableDiff->addedForeignKeys);
}
public function testTableRemoveForeignKey()
{
- $tableForeign = new Table("bar");
+ $tableForeign = new Table('bar');
$tableForeign->addColumn('id', 'integer');
- $table1 = new Table("foo");
+ $table1 = new Table('foo');
$table1->addColumn('fk', 'integer');
- $table2 = new Table("foo");
+ $table2 = new Table('foo');
$table2->addColumn('fk', 'integer');
- $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id'));
+ $table2->addForeignKeyConstraint($tableForeign, ['fk'], ['id']);
- $c = new Comparator();
+ $c = new Comparator();
$tableDiff = $c->diffTable($table2, $table1);
- self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
+ self::assertInstanceOf(TableDiff::class, $tableDiff);
self::assertCount(1, $tableDiff->removedForeignKeys);
}
public function testTableUpdateForeignKey()
{
- $tableForeign = new Table("bar");
+ $tableForeign = new Table('bar');
$tableForeign->addColumn('id', 'integer');
- $table1 = new Table("foo");
+ $table1 = new Table('foo');
$table1->addColumn('fk', 'integer');
- $table1->addForeignKeyConstraint($tableForeign, array('fk'), array('id'));
+ $table1->addForeignKeyConstraint($tableForeign, ['fk'], ['id']);
- $table2 = new Table("foo");
+ $table2 = new Table('foo');
$table2->addColumn('fk', 'integer');
- $table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id'), array('onUpdate' => 'CASCADE'));
+ $table2->addForeignKeyConstraint($tableForeign, ['fk'], ['id'], ['onUpdate' => 'CASCADE']);
- $c = new Comparator();
+ $c = new Comparator();
$tableDiff = $c->diffTable($table1, $table2);
- self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
+ self::assertInstanceOf(TableDiff::class, $tableDiff);
self::assertCount(1, $tableDiff->changedForeignKeys);
}
public function testMovedForeignKeyForeignTable()
{
- $tableForeign = new Table("bar");
+ $tableForeign = new Table('bar');
$tableForeign->addColumn('id', 'integer');
- $tableForeign2 = new Table("bar2");
+ $tableForeign2 = new Table('bar2');
$tableForeign2->addColumn('id', 'integer');
- $table1 = new Table("foo");
+ $table1 = new Table('foo');
$table1->addColumn('fk', 'integer');
- $table1->addForeignKeyConstraint($tableForeign, array('fk'), array('id'));
+ $table1->addForeignKeyConstraint($tableForeign, ['fk'], ['id']);
- $table2 = new Table("foo");
+ $table2 = new Table('foo');
$table2->addColumn('fk', 'integer');
- $table2->addForeignKeyConstraint($tableForeign2, array('fk'), array('id'));
+ $table2->addForeignKeyConstraint($tableForeign2, ['fk'], ['id']);
- $c = new Comparator();
+ $c = new Comparator();
$tableDiff = $c->diffTable($table1, $table2);
- self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
+ self::assertInstanceOf(TableDiff::class, $tableDiff);
self::assertCount(1, $tableDiff->changedForeignKeys);
}
@@ -567,7 +586,7 @@ public function testTablesCaseInsensitive()
$schemaB->createTable('Baz');
$schemaB->createTable('old');
- $c = new Comparator();
+ $c = new Comparator();
$diff = $c->compare($schemaA, $schemaB);
self::assertSchemaTableChangeCount($diff, 1, 0, 1);
@@ -587,7 +606,7 @@ public function testSequencesCaseInsensitive()
$schemaB->createSequence('baz');
$schemaB->createSequence('old');
- $c = new Comparator();
+ $c = new Comparator();
$diff = $c->compare($schemaA, $schemaB);
self::assertSchemaSequenceChangeCount($diff, 1, 0, 1);
@@ -595,13 +614,13 @@ public function testSequencesCaseInsensitive()
public function testCompareColumnCompareCaseInsensitive()
{
- $tableA = new Table("foo");
+ $tableA = new Table('foo');
$tableA->addColumn('id', 'integer');
- $tableB = new Table("foo");
+ $tableB = new Table('foo');
$tableB->addColumn('ID', 'integer');
- $c = new Comparator();
+ $c = new Comparator();
$tableDiff = $c->diffTable($tableA, $tableB);
self::assertFalse($tableDiff);
@@ -609,18 +628,18 @@ public function testCompareColumnCompareCaseInsensitive()
public function testCompareIndexBasedOnPropertiesNotName()
{
- $tableA = new Table("foo");
+ $tableA = new Table('foo');
$tableA->addColumn('id', 'integer');
- $tableA->addIndex(array("id"), "foo_bar_idx");
+ $tableA->addIndex(['id'], 'foo_bar_idx');
- $tableB = new Table("foo");
+ $tableB = new Table('foo');
$tableB->addColumn('ID', 'integer');
- $tableB->addIndex(array("id"), "bar_foo_idx");
+ $tableB->addIndex(['id'], 'bar_foo_idx');
- $c = new Comparator();
- $tableDiff = new TableDiff('foo');
- $tableDiff->fromTable = $tableA;
- $tableDiff->renamedIndexes['foo_bar_idx'] = new Index('bar_foo_idx', array('id'));
+ $c = new Comparator();
+ $tableDiff = new TableDiff('foo');
+ $tableDiff->fromTable = $tableA;
+ $tableDiff->renamedIndexes['foo_bar_idx'] = new Index('bar_foo_idx', ['id']);
self::assertEquals(
$tableDiff,
@@ -630,24 +649,24 @@ public function testCompareIndexBasedOnPropertiesNotName()
public function testCompareForeignKeyBasedOnPropertiesNotName()
{
- $tableA = new Table("foo");
+ $tableA = new Table('foo');
$tableA->addColumn('id', 'integer');
- $tableA->addNamedForeignKeyConstraint('foo_constraint', 'bar', array('id'), array('id'));
+ $tableA->addNamedForeignKeyConstraint('foo_constraint', 'bar', ['id'], ['id']);
- $tableB = new Table("foo");
+ $tableB = new Table('foo');
$tableB->addColumn('ID', 'integer');
- $tableB->addNamedForeignKeyConstraint('bar_constraint', 'bar', array('id'), array('id'));
+ $tableB->addNamedForeignKeyConstraint('bar_constraint', 'bar', ['id'], ['id']);
- $c = new Comparator();
+ $c = new Comparator();
$tableDiff = $c->diffTable($tableA, $tableB);
self::assertFalse($tableDiff);
}
- public function testCompareForeignKey_RestrictNoAction_AreTheSame()
+ public function testCompareForeignKeyRestrictNoActionAreTheSame()
{
- $fk1 = new ForeignKeyConstraint(array("foo"), "bar", array("baz"), "fk1", array('onDelete' => 'NO ACTION'));
- $fk2 = new ForeignKeyConstraint(array("foo"), "bar", array("baz"), "fk1", array('onDelete' => 'RESTRICT'));
+ $fk1 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'NO ACTION']);
+ $fk2 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'RESTRICT']);
$c = new Comparator();
self::assertFalse($c->diffForeignKey($fk1, $fk2));
@@ -656,10 +675,10 @@ public function testCompareForeignKey_RestrictNoAction_AreTheSame()
/**
* @group DBAL-492
*/
- public function testCompareForeignKeyNamesUnqualified_AsNoSchemaInformationIsAvailable()
+ public function testCompareForeignKeyNamesUnqualifiedAsNoSchemaInformationIsAvailable()
{
- $fk1 = new ForeignKeyConstraint(array("foo"), "foo.bar", array("baz"), "fk1");
- $fk2 = new ForeignKeyConstraint(array("foo"), "baz.bar", array("baz"), "fk1");
+ $fk1 = new ForeignKeyConstraint(['foo'], 'foo.bar', ['baz'], 'fk1');
+ $fk2 = new ForeignKeyConstraint(['foo'], 'baz.bar', ['baz'], 'fk1');
$c = new Comparator();
self::assertFalse($c->diffForeignKey($fk1, $fk2));
@@ -667,13 +686,13 @@ public function testCompareForeignKeyNamesUnqualified_AsNoSchemaInformationIsAva
public function testDetectRenameColumn()
{
- $tableA = new Table("foo");
+ $tableA = new Table('foo');
$tableA->addColumn('foo', 'integer');
- $tableB = new Table("foo");
+ $tableB = new Table('foo');
$tableB->addColumn('bar', 'integer');
- $c = new Comparator();
+ $c = new Comparator();
$tableDiff = $c->diffTable($tableA, $tableB);
self::assertCount(0, $tableDiff->addedColumns);
@@ -691,14 +710,14 @@ public function testDetectRenameColumn()
*/
public function testDetectRenameColumnAmbiguous()
{
- $tableA = new Table("foo");
+ $tableA = new Table('foo');
$tableA->addColumn('foo', 'integer');
$tableA->addColumn('bar', 'integer');
- $tableB = new Table("foo");
+ $tableB = new Table('foo');
$tableB->addColumn('baz', 'integer');
- $c = new Comparator();
+ $c = new Comparator();
$tableDiff = $c->diffTable($tableA, $tableB);
self::assertCount(1, $tableDiff->addedColumns, "'baz' should be added, not created through renaming!");
@@ -706,7 +725,7 @@ public function testDetectRenameColumnAmbiguous()
self::assertCount(2, $tableDiff->removedColumns, "'foo' and 'bar' should both be dropped, an ambiguity exists which one could be renamed to 'baz'.");
self::assertArrayHasKey('foo', $tableDiff->removedColumns, "'foo' should be removed.");
self::assertArrayHasKey('bar', $tableDiff->removedColumns, "'bar' should be removed.");
- self::assertCount(0, $tableDiff->renamedColumns, "no renamings should take place.");
+ self::assertCount(0, $tableDiff->renamedColumns, 'no renamings should take place.');
}
/**
@@ -719,12 +738,12 @@ public function testDetectRenameIndex()
$table2 = clone $table1;
- $table1->addIndex(array('foo'), 'idx_foo');
+ $table1->addIndex(['foo'], 'idx_foo');
- $table2->addIndex(array('foo'), 'idx_bar');
+ $table2->addIndex(['foo'], 'idx_bar');
$comparator = new Comparator();
- $tableDiff = $comparator->diffTable($table1, $table2);
+ $tableDiff = $comparator->diffTable($table1, $table2);
self::assertCount(0, $tableDiff->addedIndexes);
self::assertCount(0, $tableDiff->removedIndexes);
@@ -746,13 +765,13 @@ public function testDetectRenameIndexAmbiguous()
$table2 = clone $table1;
- $table1->addIndex(array('foo'), 'idx_foo');
- $table1->addIndex(array('foo'), 'idx_bar');
+ $table1->addIndex(['foo'], 'idx_foo');
+ $table1->addIndex(['foo'], 'idx_bar');
- $table2->addIndex(array('foo'), 'idx_baz');
+ $table2->addIndex(['foo'], 'idx_baz');
$comparator = new Comparator();
- $tableDiff = $comparator->diffTable($table1, $table2);
+ $tableDiff = $comparator->diffTable($table1, $table2);
self::assertCount(1, $tableDiff->addedIndexes);
self::assertArrayHasKey('idx_baz', $tableDiff->addedIndexes);
@@ -766,16 +785,16 @@ public function testDetectChangeIdentifierType()
{
$this->markTestSkipped('DBAL-2 was reopened, this test cannot work anymore.');
- $tableA = new Table("foo");
- $tableA->addColumn('id', 'integer', array('autoincrement' => false));
+ $tableA = new Table('foo');
+ $tableA->addColumn('id', 'integer', ['autoincrement' => false]);
- $tableB = new Table("foo");
- $tableB->addColumn('id', 'integer', array('autoincrement' => true));
+ $tableB = new Table('foo');
+ $tableB->addColumn('id', 'integer', ['autoincrement' => true]);
- $c = new Comparator();
+ $c = new Comparator();
$tableDiff = $c->diffTable($tableA, $tableB);
- self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
+ self::assertInstanceOf(TableDiff::class, $tableDiff);
self::assertArrayHasKey('id', $tableDiff->changedColumns);
}
@@ -785,25 +804,25 @@ public function testDetectChangeIdentifierType()
*/
public function testDiff()
{
- $table = new \Doctrine\DBAL\Schema\Table('twitter_users');
- $table->addColumn('id', 'integer', array('autoincrement' => true));
+ $table = new Table('twitter_users');
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('twitterId', 'integer');
$table->addColumn('displayName', 'string');
- $table->setPrimaryKey(array('id'));
+ $table->setPrimaryKey(['id']);
- $newtable = new \Doctrine\DBAL\Schema\Table('twitter_users');
- $newtable->addColumn('id', 'integer', array('autoincrement' => true));
+ $newtable = new Table('twitter_users');
+ $newtable->addColumn('id', 'integer', ['autoincrement' => true]);
$newtable->addColumn('twitter_id', 'integer');
$newtable->addColumn('display_name', 'string');
$newtable->addColumn('logged_in_at', 'datetime');
- $newtable->setPrimaryKey(array('id'));
+ $newtable->setPrimaryKey(['id']);
- $c = new Comparator();
+ $c = new Comparator();
$tableDiff = $c->diffTable($table, $newtable);
- self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff);
- self::assertEquals(array('twitterid', 'displayname'), array_keys($tableDiff->renamedColumns));
- self::assertEquals(array('logged_in_at'), array_keys($tableDiff->addedColumns));
+ self::assertInstanceOf(TableDiff::class, $tableDiff);
+ self::assertEquals(['twitterid', 'displayname'], array_keys($tableDiff->renamedColumns));
+ self::assertEquals(['logged_in_at'], array_keys($tableDiff->addedColumns));
self::assertCount(0, $tableDiff->removedColumns);
}
@@ -813,17 +832,17 @@ public function testDiff()
*/
public function testChangedSequence()
{
- $schema = new Schema();
+ $schema = new Schema();
$sequence = $schema->createSequence('baz');
$schemaNew = clone $schema;
- /* @var $schemaNew Schema */
+ /** @var Schema $schemaNew */
$schemaNew->getSequence('baz')->setAllocationSize(20);
- $c = new \Doctrine\DBAL\Schema\Comparator;
+ $c = new Comparator();
$diff = $c->compare($schema, $schemaNew);
- self::assertSame($diff->changedSequences[0] , $schemaNew->getSequence('baz'));
+ self::assertSame($diff->changedSequences[0], $schemaNew->getSequence('baz'));
}
/**
@@ -837,7 +856,7 @@ public function testDiffDecimalWithNullPrecision()
$column2 = new Column('foo', Type::getType('decimal'));
$c = new Comparator();
- self::assertEquals(array(), $c->diffColumn($column, $column2));
+ self::assertEquals([], $c->diffColumn($column, $column2));
}
/**
@@ -846,15 +865,15 @@ public function testDiffDecimalWithNullPrecision()
public function testFqnSchemaComparison()
{
$config = new SchemaConfig();
- $config->setName("foo");
+ $config->setName('foo');
- $oldSchema = new Schema(array(), array(), $config);
+ $oldSchema = new Schema([], [], $config);
$oldSchema->createTable('bar');
- $newSchema= new Schema(array(), array(), $config);
+ $newSchema = new Schema([], [], $config);
$newSchema->createTable('foo.bar');
- $expected = new SchemaDiff();
+ $expected = new SchemaDiff();
$expected->fromSchema = $oldSchema;
self::assertEquals($expected, Comparator::compareSchemas($oldSchema, $newSchema));
@@ -866,24 +885,24 @@ public function testFqnSchemaComparison()
public function testNamespacesComparison()
{
$config = new SchemaConfig();
- $config->setName("schemaName");
+ $config->setName('schemaName');
- $oldSchema = new Schema(array(), array(), $config);
+ $oldSchema = new Schema([], [], $config);
$oldSchema->createTable('taz');
$oldSchema->createTable('war.tab');
- $newSchema= new Schema(array(), array(), $config);
+ $newSchema = new Schema([], [], $config);
$newSchema->createTable('bar.tab');
$newSchema->createTable('baz.tab');
$newSchema->createTable('war.tab');
- $expected = new SchemaDiff();
- $expected->fromSchema = $oldSchema;
- $expected->newNamespaces = array('bar' => 'bar', 'baz' => 'baz');
+ $expected = new SchemaDiff();
+ $expected->fromSchema = $oldSchema;
+ $expected->newNamespaces = ['bar' => 'bar', 'baz' => 'baz'];
$diff = Comparator::compareSchemas($oldSchema, $newSchema);
- self::assertEquals(array('bar' => 'bar', 'baz' => 'baz'), $diff->newNamespaces);
+ self::assertEquals(['bar' => 'bar', 'baz' => 'baz'], $diff->newNamespaces);
self::assertCount(2, $diff->newTables);
}
@@ -893,15 +912,15 @@ public function testNamespacesComparison()
public function testFqnSchemaComparisonDifferentSchemaNameButSameTableNoDiff()
{
$config = new SchemaConfig();
- $config->setName("foo");
+ $config->setName('foo');
- $oldSchema = new Schema(array(), array(), $config);
+ $oldSchema = new Schema([], [], $config);
$oldSchema->createTable('foo.bar');
$newSchema = new Schema();
$newSchema->createTable('bar');
- $expected = new SchemaDiff();
+ $expected = new SchemaDiff();
$expected->fromSchema = $oldSchema;
self::assertEquals($expected, Comparator::compareSchemas($oldSchema, $newSchema));
@@ -913,14 +932,14 @@ public function testFqnSchemaComparisonDifferentSchemaNameButSameTableNoDiff()
public function testFqnSchemaComparisonNoSchemaSame()
{
$config = new SchemaConfig();
- $config->setName("foo");
- $oldSchema = new Schema(array(), array(), $config);
+ $config->setName('foo');
+ $oldSchema = new Schema([], [], $config);
$oldSchema->createTable('bar');
$newSchema = new Schema();
$newSchema->createTable('bar');
- $expected = new SchemaDiff();
+ $expected = new SchemaDiff();
$expected->fromSchema = $oldSchema;
self::assertEquals($expected, Comparator::compareSchemas($oldSchema, $newSchema));
@@ -932,17 +951,17 @@ public function testFqnSchemaComparisonNoSchemaSame()
public function testAutoIncrementSequences()
{
$oldSchema = new Schema();
- $table = $oldSchema->createTable("foo");
- $table->addColumn("id", "integer", array("autoincrement" => true));
- $table->setPrimaryKey(array("id"));
- $oldSchema->createSequence("foo_id_seq");
+ $table = $oldSchema->createTable('foo');
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
+ $table->setPrimaryKey(['id']);
+ $oldSchema->createSequence('foo_id_seq');
$newSchema = new Schema();
- $table = $newSchema->createTable("foo");
- $table->addColumn("id", "integer", array("autoincrement" => true));
- $table->setPrimaryKey(array("id"));
+ $table = $newSchema->createTable('foo');
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
+ $table->setPrimaryKey(['id']);
- $c = new Comparator();
+ $c = new Comparator();
$diff = $c->compare($oldSchema, $newSchema);
self::assertCount(0, $diff->removedSequences);
@@ -951,22 +970,23 @@ public function testAutoIncrementSequences()
/**
* Check that added autoincrement sequence is not populated in newSequences
+ *
* @group DBAL-562
*/
public function testAutoIncrementNoSequences()
{
$oldSchema = new Schema();
- $table = $oldSchema->createTable("foo");
- $table->addColumn("id", "integer", array("autoincrement" => true));
- $table->setPrimaryKey(array("id"));
+ $table = $oldSchema->createTable('foo');
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
+ $table->setPrimaryKey(['id']);
$newSchema = new Schema();
- $table = $newSchema->createTable("foo");
- $table->addColumn("id", "integer", array("autoincrement" => true));
- $table->setPrimaryKey(array("id"));
- $newSchema->createSequence("foo_id_seq");
+ $table = $newSchema->createTable('foo');
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
+ $table->setPrimaryKey(['id']);
+ $newSchema->createSequence('foo_id_seq');
- $c = new Comparator();
+ $c = new Comparator();
$diff = $c->compare($oldSchema, $newSchema);
self::assertCount(0, $diff->newSequences);
@@ -992,8 +1012,8 @@ public function testAvoidMultipleDropForeignKey()
$tableC->addColumn('table_a_id', 'integer');
$tableC->addColumn('table_b_id', 'integer');
- $tableC->addForeignKeyConstraint($tableA, array('table_a_id'), array('id'));
- $tableC->addForeignKeyConstraint($tableB, array('table_b_id'), array('id'));
+ $tableC->addForeignKeyConstraint($tableA, ['table_a_id'], ['id']);
+ $tableC->addForeignKeyConstraint($tableB, ['table_b_id'], ['id']);
$newSchema = new Schema();
@@ -1018,16 +1038,16 @@ public function testCompareChangedColumn()
$tableFoo->addColumn('id', 'integer');
$newSchema = new Schema();
- $table = $newSchema->createTable('foo');
+ $table = $newSchema->createTable('foo');
$table->addColumn('id', 'string');
- $expected = new SchemaDiff();
- $expected->fromSchema = $oldSchema;
- $tableDiff = $expected->changedTables['foo'] = new TableDiff('foo');
- $tableDiff->fromTable = $tableFoo;
- $columnDiff = $tableDiff->changedColumns['id'] = new ColumnDiff('id', $table->getColumn('id'));
- $columnDiff->fromColumn = $tableFoo->getColumn('id');
- $columnDiff->changedProperties = array('type');
+ $expected = new SchemaDiff();
+ $expected->fromSchema = $oldSchema;
+ $tableDiff = $expected->changedTables['foo'] = new TableDiff('foo');
+ $tableDiff->fromTable = $tableFoo;
+ $columnDiff = $tableDiff->changedColumns['id'] = new ColumnDiff('id', $table->getColumn('id'));
+ $columnDiff->fromColumn = $tableFoo->getColumn('id');
+ $columnDiff->changedProperties = ['type'];
self::assertEquals($expected, Comparator::compareSchemas($oldSchema, $newSchema));
}
@@ -1040,16 +1060,16 @@ public function testCompareChangedBinaryColumn()
$tableFoo->addColumn('id', 'binary');
$newSchema = new Schema();
- $table = $newSchema->createTable('foo');
- $table->addColumn('id', 'binary', array('length' => 42, 'fixed' => true));
+ $table = $newSchema->createTable('foo');
+ $table->addColumn('id', 'binary', ['length' => 42, 'fixed' => true]);
- $expected = new SchemaDiff();
- $expected->fromSchema = $oldSchema;
- $tableDiff = $expected->changedTables['foo'] = new TableDiff('foo');
- $tableDiff->fromTable = $tableFoo;
- $columnDiff = $tableDiff->changedColumns['id'] = new ColumnDiff('id', $table->getColumn('id'));
- $columnDiff->fromColumn = $tableFoo->getColumn('id');
- $columnDiff->changedProperties = array('length', 'fixed');
+ $expected = new SchemaDiff();
+ $expected->fromSchema = $oldSchema;
+ $tableDiff = $expected->changedTables['foo'] = new TableDiff('foo');
+ $tableDiff->fromTable = $tableFoo;
+ $columnDiff = $tableDiff->changedColumns['id'] = new ColumnDiff('id', $table->getColumn('id'));
+ $columnDiff->fromColumn = $tableFoo->getColumn('id');
+ $columnDiff->changedProperties = ['length', 'fixed'];
self::assertEquals($expected, Comparator::compareSchemas($oldSchema, $newSchema));
}
@@ -1059,11 +1079,11 @@ public function testCompareChangedBinaryColumn()
*/
public function testCompareQuotedAndUnquotedForeignKeyColumns()
{
- $fk1 = new ForeignKeyConstraint(array("foo"), "bar", array("baz"), "fk1", array('onDelete' => 'NO ACTION'));
- $fk2 = new ForeignKeyConstraint(array("`foo`"), "bar", array("`baz`"), "fk1", array('onDelete' => 'NO ACTION'));
+ $fk1 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'NO ACTION']);
+ $fk2 = new ForeignKeyConstraint(['`foo`'], 'bar', ['`baz`'], 'fk1', ['onDelete' => 'NO ACTION']);
$comparator = new Comparator();
- $diff = $comparator->diffForeignKey($fk1, $fk2);
+ $diff = $comparator->diffForeignKey($fk1, $fk2);
self::assertFalse($diff);
}
@@ -1074,7 +1094,7 @@ public function testCompareQuotedAndUnquotedForeignKeyColumns()
* @param int $changeTableCount
* @param int $removeTableCount
*/
- public function assertSchemaTableChangeCount($diff, $newTableCount=0, $changeTableCount=0, $removeTableCount=0)
+ public function assertSchemaTableChangeCount($diff, $newTableCount = 0, $changeTableCount = 0, $removeTableCount = 0)
{
self::assertCount($newTableCount, $diff->newTables);
self::assertCount($changeTableCount, $diff->changedTables);
@@ -1087,45 +1107,45 @@ public function assertSchemaTableChangeCount($diff, $newTableCount=0, $changeTab
* @param int $changeSequenceCount
* @param int $changeSequenceCount
*/
- public function assertSchemaSequenceChangeCount($diff, $newSequenceCount=0, $changeSequenceCount=0, $removeSequenceCount=0)
+ public function assertSchemaSequenceChangeCount($diff, $newSequenceCount = 0, $changeSequenceCount = 0, $removeSequenceCount = 0)
{
- self::assertCount($newSequenceCount, $diff->newSequences, "Expected number of new sequences is wrong.");
- self::assertCount($changeSequenceCount, $diff->changedSequences, "Expected number of changed sequences is wrong.");
- self::assertCount($removeSequenceCount, $diff->removedSequences, "Expected number of removed sequences is wrong.");
+ self::assertCount($newSequenceCount, $diff->newSequences, 'Expected number of new sequences is wrong.');
+ self::assertCount($changeSequenceCount, $diff->changedSequences, 'Expected number of changed sequences is wrong.');
+ self::assertCount($removeSequenceCount, $diff->removedSequences, 'Expected number of removed sequences is wrong.');
}
public function testDiffColumnPlatformOptions()
{
- $column1 = new Column('foo', Type::getType('string'), array('platformOptions' => array('foo' => 'foo', 'bar' => 'bar')));
- $column2 = new Column('foo', Type::getType('string'), array('platformOptions' => array('foo' => 'foo', 'foobar' => 'foobar')));
- $column3 = new Column('foo', Type::getType('string'), array('platformOptions' => array('foo' => 'foo', 'bar' => 'rab')));
+ $column1 = new Column('foo', Type::getType('string'), ['platformOptions' => ['foo' => 'foo', 'bar' => 'bar']]);
+ $column2 = new Column('foo', Type::getType('string'), ['platformOptions' => ['foo' => 'foo', 'foobar' => 'foobar']]);
+ $column3 = new Column('foo', Type::getType('string'), ['platformOptions' => ['foo' => 'foo', 'bar' => 'rab']]);
$column4 = new Column('foo', Type::getType('string'));
$comparator = new Comparator();
- self::assertEquals(array(), $comparator->diffColumn($column1, $column2));
- self::assertEquals(array(), $comparator->diffColumn($column2, $column1));
- self::assertEquals(array('bar'), $comparator->diffColumn($column1, $column3));
- self::assertEquals(array('bar'), $comparator->diffColumn($column3, $column1));
- self::assertEquals(array(), $comparator->diffColumn($column1, $column4));
- self::assertEquals(array(), $comparator->diffColumn($column4, $column1));
+ self::assertEquals([], $comparator->diffColumn($column1, $column2));
+ self::assertEquals([], $comparator->diffColumn($column2, $column1));
+ self::assertEquals(['bar'], $comparator->diffColumn($column1, $column3));
+ self::assertEquals(['bar'], $comparator->diffColumn($column3, $column1));
+ self::assertEquals([], $comparator->diffColumn($column1, $column4));
+ self::assertEquals([], $comparator->diffColumn($column4, $column1));
}
public function testComplexDiffColumn()
{
- $column1 = new Column('foo', Type::getType('string'), array(
- 'platformOptions' => array('foo' => 'foo'),
- 'customSchemaOptions' => array('foo' => 'bar'),
- ));
+ $column1 = new Column('foo', Type::getType('string'), [
+ 'platformOptions' => ['foo' => 'foo'],
+ 'customSchemaOptions' => ['foo' => 'bar'],
+ ]);
- $column2 = new Column('foo', Type::getType('string'), array(
- 'platformOptions' => array('foo' => 'bar'),
- ));
+ $column2 = new Column('foo', Type::getType('string'), [
+ 'platformOptions' => ['foo' => 'bar'],
+ ]);
$comparator = new Comparator();
- self::assertEquals(array(), $comparator->diffColumn($column1, $column2));
- self::assertEquals(array(), $comparator->diffColumn($column2, $column1));
+ self::assertEquals([], $comparator->diffColumn($column1, $column2));
+ self::assertEquals([], $comparator->diffColumn($column2, $column1));
}
/**
@@ -1134,16 +1154,16 @@ public function testComplexDiffColumn()
public function testComparesNamespaces()
{
$comparator = new Comparator();
- $fromSchema = $this->getMockBuilder('Doctrine\DBAL\Schema\Schema')
- ->setMethods(array('getNamespaces', 'hasNamespace'))
+ $fromSchema = $this->getMockBuilder(Schema::class)
+ ->setMethods(['getNamespaces', 'hasNamespace'])
->getMock();
- $toSchema = $this->getMockBuilder('Doctrine\DBAL\Schema\Schema')
- ->setMethods(array('getNamespaces', 'hasNamespace'))
+ $toSchema = $this->getMockBuilder(Schema::class)
+ ->setMethods(['getNamespaces', 'hasNamespace'])
->getMock();
$fromSchema->expects($this->once())
->method('getNamespaces')
- ->will($this->returnValue(array('foo', 'bar')));
+ ->will($this->returnValue(['foo', 'bar']));
$fromSchema->expects($this->at(0))
->method('hasNamespace')
@@ -1157,7 +1177,7 @@ public function testComparesNamespaces()
$toSchema->expects($this->once())
->method('getNamespaces')
- ->will($this->returnValue(array('bar', 'baz')));
+ ->will($this->returnValue(['bar', 'baz']));
$toSchema->expects($this->at(1))
->method('hasNamespace')
@@ -1169,10 +1189,10 @@ public function testComparesNamespaces()
->with('bar')
->will($this->returnValue(true));
- $expected = new SchemaDiff();
- $expected->fromSchema = $fromSchema;
- $expected->newNamespaces = array('baz' => 'baz');
- $expected->removedNamespaces = array('foo' => 'foo');
+ $expected = new SchemaDiff();
+ $expected->fromSchema = $fromSchema;
+ $expected->newNamespaces = ['baz' => 'baz'];
+ $expected->removedNamespaces = ['foo' => 'foo'];
self::assertEquals($expected, $comparator->compare($fromSchema, $toSchema));
}
@@ -1181,30 +1201,29 @@ public function testCompareGuidColumns()
{
$comparator = new Comparator();
- $column1 = new Column('foo', Type::getType('guid'), array('comment' => 'GUID 1'));
+ $column1 = new Column('foo', Type::getType('guid'), ['comment' => 'GUID 1']);
$column2 = new Column(
'foo',
Type::getType('guid'),
- array('notnull' => false, 'length' => '36', 'fixed' => true, 'default' => 'NEWID()', 'comment' => 'GUID 2.')
+ ['notnull' => false, 'length' => '36', 'fixed' => true, 'default' => 'NEWID()', 'comment' => 'GUID 2.']
);
- self::assertEquals(array('notnull', 'default', 'comment'), $comparator->diffColumn($column1, $column2));
- self::assertEquals(array('notnull', 'default', 'comment'), $comparator->diffColumn($column2, $column1));
+ self::assertEquals(['notnull', 'default', 'comment'], $comparator->diffColumn($column1, $column2));
+ self::assertEquals(['notnull', 'default', 'comment'], $comparator->diffColumn($column2, $column1));
}
/**
* @group DBAL-1009
- *
* @dataProvider getCompareColumnComments
*/
public function testCompareColumnComments($comment1, $comment2, $equals)
{
- $column1 = new Column('foo', Type::getType('integer'), array('comment' => $comment1));
- $column2 = new Column('foo', Type::getType('integer'), array('comment' => $comment2));
+ $column1 = new Column('foo', Type::getType('integer'), ['comment' => $comment1]);
+ $column2 = new Column('foo', Type::getType('integer'), ['comment' => $comment2]);
$comparator = new Comparator();
- $expectedDiff = $equals ? array() : array('comment');
+ $expectedDiff = $equals ? [] : ['comment'];
$actualDiff = $comparator->diffColumn($column1, $column2);
@@ -1217,66 +1236,74 @@ public function testCompareColumnComments($comment1, $comment2, $equals)
public function getCompareColumnComments()
{
- return array(
- array(null, null, true),
- array('', '', true),
- array(' ', ' ', true),
- array('0', '0', true),
- array('foo', 'foo', true),
-
- array(null, '', true),
- array(null, ' ', false),
- array(null, '0', false),
- array(null, 'foo', false),
-
- array('', ' ', false),
- array('', '0', false),
- array('', 'foo', false),
-
- array(' ', '0', false),
- array(' ', 'foo', false),
-
- array('0', 'foo', false),
- );
+ return [
+ [null, null, true],
+ ['', '', true],
+ [' ', ' ', true],
+ ['0', '0', true],
+ ['foo', 'foo', true],
+
+ [null, '', true],
+ [null, ' ', false],
+ [null, '0', false],
+ [null, 'foo', false],
+
+ ['', ' ', false],
+ ['', '0', false],
+ ['', 'foo', false],
+
+ [' ', '0', false],
+ [' ', 'foo', false],
+
+ ['0', 'foo', false],
+ ];
}
public function testForeignKeyRemovalWithRenamedLocalColumn()
{
- $fromSchema = new Schema( array(
- 'table1' => new Table('table1',
- array(
+ $fromSchema = new Schema([
+ 'table1' => new Table(
+ 'table1',
+ [
'id' => new Column('id', Type::getType('integer')),
- )),
- 'table2' => new Table('table2',
- array(
+ ]
+ ),
+ 'table2' => new Table(
+ 'table2',
+ [
'id' => new Column('id', Type::getType('integer')),
- 'id_table1' => new Column('id_table1', Type::getType('integer'))
- ),
- array(),
- array(
- new ForeignKeyConstraint(array('id_table1'), 'table1', array('id'), 'fk_table2_table1')
- ))
- ));
- $toSchema = new Schema( array(
- 'table2' => new Table('table2',
- array(
+ 'id_table1' => new Column('id_table1', Type::getType('integer')),
+ ],
+ [],
+ [
+ new ForeignKeyConstraint(['id_table1'], 'table1', ['id'], 'fk_table2_table1'),
+ ]
+ ),
+ ]);
+ $toSchema = new Schema([
+ 'table2' => new Table(
+ 'table2',
+ [
'id' => new Column('id', Type::getType('integer')),
- 'id_table3' => new Column('id_table3', Type::getType('integer'))
- ),
- array(),
- array(
- new ForeignKeyConstraint(array('id_table3'), 'table3', array('id'), 'fk_table2_table3')
- )),
- 'table3' => new Table('table3',
- array(
- 'id' => new Column('id', Type::getType('integer'))
- ))
- ));
- $actual = Comparator::compareSchemas($fromSchema, $toSchema);
- self::assertArrayHasKey("table2", $actual->changedTables);
+ 'id_table3' => new Column('id_table3', Type::getType('integer')),
+ ],
+ [],
+ [
+ new ForeignKeyConstraint(['id_table3'], 'table3', ['id'], 'fk_table2_table3'),
+ ]
+ ),
+ 'table3' => new Table(
+ 'table3',
+ [
+ 'id' => new Column('id', Type::getType('integer')),
+ ]
+ ),
+ ]);
+ $actual = Comparator::compareSchemas($fromSchema, $toSchema);
+ self::assertArrayHasKey('table2', $actual->changedTables);
self::assertCount(1, $actual->orphanedForeignKeys);
- self::assertEquals("fk_table2_table1", $actual->orphanedForeignKeys[0]->getName());
- self::assertCount(1, $actual->changedTables['table2']->addedForeignKeys, "FK to table3 should be added.");
- self::assertEquals("table3", $actual->changedTables['table2']->addedForeignKeys[0]->getForeignTableName());
+ self::assertEquals('fk_table2_table1', $actual->orphanedForeignKeys[0]->getName());
+ self::assertCount(1, $actual->changedTables['table2']->addedForeignKeys, 'FK to table3 should be added.');
+ self::assertEquals('table3', $actual->changedTables['table2']->addedForeignKeys[0]->getForeignTableName());
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php
index d5592a4cbde..053ead6c1bc 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php
@@ -8,28 +8,26 @@
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Schema\DB2SchemaManager;
+use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_MockObject;
/**
* @covers \Doctrine\DBAL\Schema\DB2SchemaManager
*/
-final class DB2SchemaManagerTest extends \PHPUnit\Framework\TestCase
+final class DB2SchemaManagerTest extends TestCase
{
- /**
- * @var Connection|\PHPUnit_Framework_MockObject_MockObject
- */
+ /** @var Connection|PHPUnit_Framework_MockObject_MockObject */
private $conn;
- /**
- * @var DB2SchemaManager
- */
+ /** @var DB2SchemaManager */
private $manager;
protected function setUp()
{
- $eventManager = new EventManager();
- $driverMock = $this->createMock(Driver::class);
- $platform = $this->createMock(DB2Platform::class);
- $this->conn = $this
+ $eventManager = new EventManager();
+ $driverMock = $this->createMock(Driver::class);
+ $platform = $this->createMock(DB2Platform::class);
+ $this->conn = $this
->getMockBuilder(Connection::class)
->setMethods(['fetchAll'])
->setConstructorArgs([['platform' => $platform], $driverMock, new Configuration(), $eventManager])
@@ -38,26 +36,20 @@ protected function setUp()
}
/**
- * @group DBAL-2701
* @see https://github.com/doctrine/dbal/issues/2701
+ *
* @return void
+ *
+ * @group DBAL-2701
*/
public function testListTableNamesFiltersAssetNamesCorrectly()
{
$this->conn->getConfiguration()->setFilterSchemaAssetsExpression('/^(?!T_)/');
$this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue([
- [
- 'name' => 'FOO',
- ],
- [
- 'name' => 'T_FOO',
- ],
- [
- 'name' => 'BAR',
- ],
- [
- 'name' => 'T_BAR',
- ],
+ ['name' => 'FOO'],
+ ['name' => 'T_FOO'],
+ ['name' => 'BAR'],
+ ['name' => 'T_BAR'],
]));
self::assertSame(
diff --git a/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php b/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php
index 291731bab6d..2c317fc5dea 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php
@@ -3,19 +3,22 @@
namespace Doctrine\Tests\DBAL\Schema;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
+use Doctrine\DBAL\Schema\Index;
+use PHPUnit\Framework\TestCase;
-class ForeignKeyConstraintTest extends \PHPUnit\Framework\TestCase
+class ForeignKeyConstraintTest extends TestCase
{
/**
- * @group DBAL-1062
+ * @param string[] $indexColumns
*
+ * @group DBAL-1062
* @dataProvider getIntersectsIndexColumnsData
*/
public function testIntersectsIndexColumns(array $indexColumns, $expectedResult)
{
- $foreignKey = new ForeignKeyConstraint(array('foo', 'bar'), 'foreign_table', array('fk_foo', 'fk_bar'));
+ $foreignKey = new ForeignKeyConstraint(['foo', 'bar'], 'foreign_table', ['fk_foo', 'fk_bar']);
- $index = $this->getMockBuilder('Doctrine\DBAL\Schema\Index')
+ $index = $this->getMockBuilder(Index::class)
->disableOriginalConstructor()
->getMock();
$index->expects($this->once())
@@ -26,31 +29,31 @@ public function testIntersectsIndexColumns(array $indexColumns, $expectedResult)
}
/**
- * @return array
+ * @return mixed[]
*/
public function getIntersectsIndexColumnsData()
{
- return array(
- array(array('baz'), false),
- array(array('baz', 'bloo'), false),
+ return [
+ [['baz'], false],
+ [['baz', 'bloo'], false],
- array(array('foo'), true),
- array(array('bar'), true),
+ [['foo'], true],
+ [['bar'], true],
- array(array('foo', 'bar'), true),
- array(array('bar', 'foo'), true),
+ [['foo', 'bar'], true],
+ [['bar', 'foo'], true],
- array(array('foo', 'baz'), true),
- array(array('baz', 'foo'), true),
+ [['foo', 'baz'], true],
+ [['baz', 'foo'], true],
- array(array('bar', 'baz'), true),
- array(array('baz', 'bar'), true),
+ [['bar', 'baz'], true],
+ [['baz', 'bar'], true],
- array(array('foo', 'bloo', 'baz'), true),
- array(array('bloo', 'foo', 'baz'), true),
- array(array('bloo', 'baz', 'foo'), true),
+ [['foo', 'bloo', 'baz'], true],
+ [['bloo', 'foo', 'baz'], true],
+ [['bloo', 'baz', 'foo'], true],
- array(array('FOO'), true),
- );
+ [['FOO'], true],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php b/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php
index 1f49fd5e14d..af962f95f95 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php
@@ -3,21 +3,22 @@
namespace Doctrine\Tests\DBAL\Schema;
use Doctrine\DBAL\Schema\Index;
+use PHPUnit\Framework\TestCase;
-class IndexTest extends \PHPUnit\Framework\TestCase
+class IndexTest extends TestCase
{
- public function createIndex($unique = false, $primary = false, $options = array())
+ public function createIndex($unique = false, $primary = false, $options = [])
{
- return new Index("foo", array("bar", "baz"), $unique, $primary, array(), $options);
+ return new Index('foo', ['bar', 'baz'], $unique, $primary, [], $options);
}
public function testCreateIndex()
{
$idx = $this->createIndex();
- self::assertEquals("foo", $idx->getName());
+ self::assertEquals('foo', $idx->getName());
$columns = $idx->getColumns();
self::assertCount(2, $columns);
- self::assertEquals(array("bar", "baz"), $columns);
+ self::assertEquals(['bar', 'baz'], $columns);
self::assertFalse($idx->isUnique());
self::assertFalse($idx->isPrimary());
}
@@ -69,7 +70,7 @@ public function testFulfilledByIndex()
{
$idx1 = $this->createIndex();
$idx2 = $this->createIndex();
- $pri = $this->createIndex(true, true);
+ $pri = $this->createIndex(true, true);
$uniq = $this->createIndex(true);
self::assertTrue($idx1->isFullfilledBy($idx2));
@@ -79,9 +80,9 @@ public function testFulfilledByIndex()
public function testFulfilledWithPartial()
{
- $without = new Index('without', array('col1', 'col2'), true, false, array(), array());
- $partial = new Index('partial', array('col1', 'col2'), true, false, array(), array('where' => 'col1 IS NULL'));
- $another = new Index('another', array('col1', 'col2'), true, false, array(), array('where' => 'col1 IS NULL'));
+ $without = new Index('without', ['col1', 'col2'], true, false, [], []);
+ $partial = new Index('partial', ['col1', 'col2'], true, false, [], ['where' => 'col1 IS NULL']);
+ $another = new Index('another', ['col1', 'col2'], true, false, [], ['where' => 'col1 IS NULL']);
self::assertFalse($partial->isFullfilledBy($without));
self::assertFalse($without->isFullfilledBy($partial));
@@ -94,9 +95,9 @@ public function testFulfilledWithPartial()
public function testOverrulesWithPartial()
{
- $without = new Index('without', array('col1', 'col2'), true, false, array(), array());
- $partial = new Index('partial', array('col1', 'col2'), true, false, array(), array('where' => 'col1 IS NULL'));
- $another = new Index('another', array('col1', 'col2'), true, false, array(), array('where' => 'col1 IS NULL'));
+ $without = new Index('without', ['col1', 'col2'], true, false, [], []);
+ $partial = new Index('partial', ['col1', 'col2'], true, false, [], ['where' => 'col1 IS NULL']);
+ $another = new Index('another', ['col1', 'col2'], true, false, [], ['where' => 'col1 IS NULL']);
self::assertFalse($partial->overrules($without));
self::assertFalse($without->overrules($partial));
@@ -119,7 +120,7 @@ public function testFlags()
$idx1->addFlag('clustered');
self::assertTrue($idx1->hasFlag('clustered'));
self::assertTrue($idx1->hasFlag('CLUSTERED'));
- self::assertSame(array('clustered'), $idx1->getFlags());
+ self::assertSame(['clustered'], $idx1->getFlags());
$idx1->removeFlag('clustered');
self::assertFalse($idx1->hasFlag('clustered'));
@@ -131,14 +132,14 @@ public function testFlags()
*/
public function testIndexQuotes()
{
- $index = new Index("foo", array("`bar`", "`baz`"));
+ $index = new Index('foo', ['`bar`', '`baz`']);
- self::assertTrue($index->spansColumns(array("bar", "baz")));
- self::assertTrue($index->hasColumnAtPosition("bar", 0));
- self::assertTrue($index->hasColumnAtPosition("baz", 1));
+ self::assertTrue($index->spansColumns(['bar', 'baz']));
+ self::assertTrue($index->hasColumnAtPosition('bar', 0));
+ self::assertTrue($index->hasColumnAtPosition('baz', 1));
- self::assertFalse($index->hasColumnAtPosition("bar", 1));
- self::assertFalse($index->hasColumnAtPosition("baz", 0));
+ self::assertFalse($index->hasColumnAtPosition('bar', 1));
+ self::assertFalse($index->hasColumnAtPosition('baz', 0));
}
public function testOptions()
@@ -147,11 +148,11 @@ public function testOptions()
self::assertFalse($idx1->hasOption('where'));
self::assertEmpty($idx1->getOptions());
- $idx2 = $this->createIndex(false, false, array('where' => 'name IS NULL'));
+ $idx2 = $this->createIndex(false, false, ['where' => 'name IS NULL']);
self::assertTrue($idx2->hasOption('where'));
self::assertTrue($idx2->hasOption('WHERE'));
self::assertSame('name IS NULL', $idx2->getOption('where'));
self::assertSame('name IS NULL', $idx2->getOption('WHERE'));
- self::assertSame(array('where' => 'name IS NULL'), $idx2->getOptions());
+ self::assertSame(['where' => 'name IS NULL'], $idx2->getOptions());
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php b/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php
index c5b7ad0dd77..b9c0f1d73ec 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php
@@ -7,6 +7,7 @@
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\MySqlSchemaManager;
@@ -37,8 +38,8 @@ public function testInheritTableOptionsFromDatabase() : void
public function testTableOptions() : void
{
$eventManager = new EventManager();
- $driverMock = $this->createMock('Doctrine\DBAL\Driver');
- $platform = new \Doctrine\DBAL\Platforms\MySqlPlatform();
+ $driverMock = $this->createMock(Driver::class);
+ $platform = new MySqlPlatform();
// default, no overrides
$table = new Table('foobar', [new Column('aa', Type::getType('integer'))]);
@@ -72,7 +73,7 @@ public function testTableOptions() : void
private function getTableOptionsForOverride(array $overrideOptions = []) : array
{
$eventManager = new EventManager();
- $driverMock = $this->createMock('Doctrine\DBAL\Driver');
+ $driverMock = $this->createMock(Driver::class);
$platform = new MySqlPlatform();
$connOptions = array_merge(['platform' => $platform], $overrideOptions);
$conn = new Connection($connOptions, $driverMock, new Configuration(), $eventManager);
diff --git a/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php
index e8129d3a20f..737a8223812 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php
@@ -5,14 +5,17 @@
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver;
+use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Schema\AbstractSchemaManager;
+use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\MySqlSchemaManager;
+use PHPUnit\Framework\TestCase;
use function array_map;
-class MySqlSchemaManagerTest extends \PHPUnit\Framework\TestCase
+class MySqlSchemaManagerTest extends TestCase
{
- /**
- * @var \Doctrine\DBAL\Schema\AbstractSchemaManager
- */
+ /** @var AbstractSchemaManager */
private $manager;
/** @var Connection */
@@ -20,12 +23,12 @@ class MySqlSchemaManagerTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
- $eventManager = new EventManager();
- $driverMock = $this->createMock('Doctrine\DBAL\Driver');
- $platform = $this->createMock('Doctrine\DBAL\Platforms\MySqlPlatform');
- $this->conn = $this->getMockBuilder('Doctrine\DBAL\Connection')
- ->setMethods(array('fetchAll'))
- ->setConstructorArgs(array(array('platform' => $platform), $driverMock, new Configuration(), $eventManager))
+ $eventManager = new EventManager();
+ $driverMock = $this->createMock(Driver::class);
+ $platform = $this->createMock(MySqlPlatform::class);
+ $this->conn = $this->getMockBuilder(Connection::class)
+ ->setMethods(['fetchAll'])
+ ->setConstructorArgs([['platform' => $platform], $driverMock, new Configuration(), $eventManager])
->getMock();
$this->manager = new MySqlSchemaManager($this->conn);
}
@@ -34,40 +37,40 @@ public function testCompositeForeignKeys()
{
$this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue($this->getFKDefinition()));
$fkeys = $this->manager->listTableForeignKeys('dummy');
- self::assertCount(1, $fkeys, "Table has to have one foreign key.");
+ self::assertCount(1, $fkeys, 'Table has to have one foreign key.');
- self::assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]);
- self::assertEquals(array('column_1', 'column_2', 'column_3'), array_map('strtolower', $fkeys[0]->getLocalColumns()));
- self::assertEquals(array('column_1', 'column_2', 'column_3'), array_map('strtolower', $fkeys[0]->getForeignColumns()));
+ self::assertInstanceOf(ForeignKeyConstraint::class, $fkeys[0]);
+ self::assertEquals(['column_1', 'column_2', 'column_3'], array_map('strtolower', $fkeys[0]->getLocalColumns()));
+ self::assertEquals(['column_1', 'column_2', 'column_3'], array_map('strtolower', $fkeys[0]->getForeignColumns()));
}
public function getFKDefinition()
{
- return array(
- array(
- "CONSTRAINT_NAME" => "FK_C1B1712387FE737264DE5A5511B8B3E",
- "COLUMN_NAME" => "column_1",
- "REFERENCED_TABLE_NAME" => "dummy",
- "REFERENCED_COLUMN_NAME" => "column_1",
- "update_rule" => "RESTRICT",
- "delete_rule" => "RESTRICT",
- ),
- array(
- "CONSTRAINT_NAME" => "FK_C1B1712387FE737264DE5A5511B8B3E",
- "COLUMN_NAME" => "column_2",
- "REFERENCED_TABLE_NAME" => "dummy",
- "REFERENCED_COLUMN_NAME" => "column_2",
- "update_rule" => "RESTRICT",
- "delete_rule" => "RESTRICT",
- ),
- array(
- "CONSTRAINT_NAME" => "FK_C1B1712387FE737264DE5A5511B8B3E",
- "COLUMN_NAME" => "column_3",
- "REFERENCED_TABLE_NAME" => "dummy",
- "REFERENCED_COLUMN_NAME" => "column_3",
- "update_rule" => "RESTRICT",
- "delete_rule" => "RESTRICT",
- )
- );
+ return [
+ [
+ 'CONSTRAINT_NAME' => 'FK_C1B1712387FE737264DE5A5511B8B3E',
+ 'COLUMN_NAME' => 'column_1',
+ 'REFERENCED_TABLE_NAME' => 'dummy',
+ 'REFERENCED_COLUMN_NAME' => 'column_1',
+ 'update_rule' => 'RESTRICT',
+ 'delete_rule' => 'RESTRICT',
+ ],
+ [
+ 'CONSTRAINT_NAME' => 'FK_C1B1712387FE737264DE5A5511B8B3E',
+ 'COLUMN_NAME' => 'column_2',
+ 'REFERENCED_TABLE_NAME' => 'dummy',
+ 'REFERENCED_COLUMN_NAME' => 'column_2',
+ 'update_rule' => 'RESTRICT',
+ 'delete_rule' => 'RESTRICT',
+ ],
+ [
+ 'CONSTRAINT_NAME' => 'FK_C1B1712387FE737264DE5A5511B8B3E',
+ 'COLUMN_NAME' => 'column_3',
+ 'REFERENCED_TABLE_NAME' => 'dummy',
+ 'REFERENCED_COLUMN_NAME' => 'column_3',
+ 'update_rule' => 'RESTRICT',
+ 'delete_rule' => 'RESTRICT',
+ ],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php b/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php
index ff8e9b32256..0d45a5ef5e5 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php
@@ -2,44 +2,45 @@
namespace Doctrine\Tests\DBAL\Schema\Platforms;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\Table;
+use PHPUnit\Framework\TestCase;
-class MySQLSchemaTest extends \PHPUnit\Framework\TestCase
+class MySQLSchemaTest extends TestCase
{
/** @var Comparator */
private $comparator;
- /**
- *
- * @var \Doctrine\DBAL\Platforms\AbstractPlatform
- */
+ /** @var AbstractPlatform */
private $platform;
protected function setUp()
{
$this->comparator = new Comparator();
- $this->platform = new \Doctrine\DBAL\Platforms\MySqlPlatform;
+ $this->platform = new MySqlPlatform();
}
public function testSwitchPrimaryKeyOrder()
{
- $tableOld = new Table("test");
+ $tableOld = new Table('test');
$tableOld->addColumn('foo_id', 'integer');
$tableOld->addColumn('bar_id', 'integer');
$tableNew = clone $tableOld;
- $tableOld->setPrimaryKey(array('foo_id', 'bar_id'));
- $tableNew->setPrimaryKey(array('bar_id', 'foo_id'));
+ $tableOld->setPrimaryKey(['foo_id', 'bar_id']);
+ $tableNew->setPrimaryKey(['bar_id', 'foo_id']);
$diff = $this->comparator->diffTable($tableOld, $tableNew);
- $sql = $this->platform->getAlterTableSQL($diff);
+ $sql = $this->platform->getAlterTableSQL($diff);
self::assertEquals(
- array(
+ [
'ALTER TABLE test DROP PRIMARY KEY',
- 'ALTER TABLE test ADD PRIMARY KEY (bar_id, foo_id)'
- ), $sql
+ 'ALTER TABLE test ADD PRIMARY KEY (bar_id, foo_id)',
+ ],
+ $sql
);
}
@@ -48,16 +49,16 @@ public function testSwitchPrimaryKeyOrder()
*/
public function testGenerateForeignKeySQL()
{
- $tableOld = new Table("test");
+ $tableOld = new Table('test');
$tableOld->addColumn('foo_id', 'integer');
- $tableOld->addUnnamedForeignKeyConstraint('test_foreign', array('foo_id'), array('foo_id'));
+ $tableOld->addUnnamedForeignKeyConstraint('test_foreign', ['foo_id'], ['foo_id']);
- $sqls = array();
+ $sqls = [];
foreach ($tableOld->getForeignKeys() as $fk) {
$sqls[] = $this->platform->getCreateForeignKeySQL($fk, $tableOld);
}
- self::assertEquals(array("ALTER TABLE test ADD CONSTRAINT FK_D87F7E0C8E48560F FOREIGN KEY (foo_id) REFERENCES test_foreign (foo_id)"), $sqls);
+ self::assertEquals(['ALTER TABLE test ADD CONSTRAINT FK_D87F7E0C8E48560F FOREIGN KEY (foo_id) REFERENCES test_foreign (foo_id)'], $sqls);
}
/**
@@ -65,18 +66,18 @@ public function testGenerateForeignKeySQL()
*/
public function testClobNoAlterTable()
{
- $tableOld = new Table("test");
+ $tableOld = new Table('test');
$tableOld->addColumn('id', 'integer');
- $tableOld->addColumn('description', 'string', array('length' => 65536));
+ $tableOld->addColumn('description', 'string', ['length' => 65536]);
$tableNew = clone $tableOld;
- $tableNew->setPrimaryKey(array('id'));
+ $tableNew->setPrimaryKey(['id']);
$diff = $this->comparator->diffTable($tableOld, $tableNew);
- $sql = $this->platform->getAlterTableSQL($diff);
+ $sql = $this->platform->getAlterTableSQL($diff);
self::assertEquals(
- array('ALTER TABLE test ADD PRIMARY KEY (id)'),
+ ['ALTER TABLE test ADD PRIMARY KEY (id)'],
$sql
);
}
diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php
index 5541bb04396..8a6d9575bce 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php
@@ -2,40 +2,43 @@
namespace Doctrine\Tests\DBAL\Schema;
+use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\SchemaDiff;
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
+use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use PHPUnit\Framework\TestCase;
-class SchemaDiffTest extends \PHPUnit\Framework\TestCase
+class SchemaDiffTest extends TestCase
{
public function testSchemaDiffToSql()
{
- $diff = $this->createSchemaDiff();
+ $diff = $this->createSchemaDiff();
$platform = $this->createPlatform(true);
$sql = $diff->toSql($platform);
- $expected = array('create_schema', 'drop_orphan_fk', 'alter_seq', 'drop_seq', 'create_seq', 'create_table', 'create_foreign_key', 'drop_table', 'alter_table');
+ $expected = ['create_schema', 'drop_orphan_fk', 'alter_seq', 'drop_seq', 'create_seq', 'create_table', 'create_foreign_key', 'drop_table', 'alter_table'];
self::assertEquals($expected, $sql);
}
public function testSchemaDiffToSaveSql()
{
- $diff = $this->createSchemaDiff();
+ $diff = $this->createSchemaDiff();
$platform = $this->createPlatform(false);
$sql = $diff->toSaveSql($platform);
- $expected = array('create_schema', 'alter_seq', 'create_seq', 'create_table', 'create_foreign_key', 'alter_table');
+ $expected = ['create_schema', 'alter_seq', 'create_seq', 'create_table', 'create_foreign_key', 'alter_table'];
self::assertEquals($expected, $sql);
}
public function createPlatform($unsafe = false)
{
- $platform = $this->createMock('Doctrine\Tests\DBAL\Mocks\MockPlatform');
+ $platform = $this->createMock(MockPlatform::class);
$platform->expects($this->exactly(1))
->method('getCreateSchemaSQL')
->with('foo_ns')
@@ -43,41 +46,41 @@ public function createPlatform($unsafe = false)
if ($unsafe) {
$platform->expects($this->exactly(1))
->method('getDropSequenceSql')
- ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence'))
+ ->with($this->isInstanceOf(Sequence::class))
->will($this->returnValue('drop_seq'));
}
$platform->expects($this->exactly(1))
->method('getAlterSequenceSql')
- ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence'))
+ ->with($this->isInstanceOf(Sequence::class))
->will($this->returnValue('alter_seq'));
$platform->expects($this->exactly(1))
->method('getCreateSequenceSql')
- ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence'))
+ ->with($this->isInstanceOf(Sequence::class))
->will($this->returnValue('create_seq'));
if ($unsafe) {
$platform->expects($this->exactly(1))
->method('getDropTableSql')
- ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Table'))
+ ->with($this->isInstanceOf(Table::class))
->will($this->returnValue('drop_table'));
}
$platform->expects($this->exactly(1))
->method('getCreateTableSql')
- ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Table'))
- ->will($this->returnValue(array('create_table')));
+ ->with($this->isInstanceOf(Table::class))
+ ->will($this->returnValue(['create_table']));
$platform->expects($this->exactly(1))
->method('getCreateForeignKeySQL')
- ->with($this->isInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint'))
+ ->with($this->isInstanceOf(ForeignKeyConstraint::class))
->will($this->returnValue('create_foreign_key'));
$platform->expects($this->exactly(1))
->method('getAlterTableSql')
- ->with($this->isInstanceOf('Doctrine\DBAL\Schema\TableDiff'))
- ->will($this->returnValue(array('alter_table')));
+ ->with($this->isInstanceOf(TableDiff::class))
+ ->will($this->returnValue(['alter_table']));
if ($unsafe) {
$platform->expects($this->exactly(1))
->method('getDropForeignKeySql')
->with(
- $this->isInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint'),
- $this->isInstanceOf('Doctrine\DBAL\Schema\Table')
+ $this->isInstanceOf(ForeignKeyConstraint::class),
+ $this->isInstanceOf(Table::class)
)
->will($this->returnValue('drop_orphan_fk'));
}
@@ -95,18 +98,18 @@ public function createPlatform($unsafe = false)
public function createSchemaDiff()
{
- $diff = new SchemaDiff();
- $diff->newNamespaces['foo_ns'] = 'foo_ns';
+ $diff = new SchemaDiff();
+ $diff->newNamespaces['foo_ns'] = 'foo_ns';
$diff->removedNamespaces['bar_ns'] = 'bar_ns';
$diff->changedSequences['foo_seq'] = new Sequence('foo_seq');
- $diff->newSequences['bar_seq'] = new Sequence('bar_seq');
+ $diff->newSequences['bar_seq'] = new Sequence('bar_seq');
$diff->removedSequences['baz_seq'] = new Sequence('baz_seq');
- $diff->newTables['foo_table'] = new Table('foo_table');
- $diff->removedTables['bar_table'] = new Table('bar_table');
- $diff->changedTables['baz_table'] = new TableDiff('baz_table');
+ $diff->newTables['foo_table'] = new Table('foo_table');
+ $diff->removedTables['bar_table'] = new Table('bar_table');
+ $diff->changedTables['baz_table'] = new TableDiff('baz_table');
$diff->newTables['foo_table']->addColumn('foreign_id', 'integer');
- $diff->newTables['foo_table']->addForeignKeyConstraint('foreign_table', array('foreign_id'), array('id'));
- $fk = new \Doctrine\DBAL\Schema\ForeignKeyConstraint(array('id'), 'foreign_table', array('id'));
+ $diff->newTables['foo_table']->addForeignKeyConstraint('foreign_table', ['foreign_id'], ['id']);
+ $fk = new ForeignKeyConstraint(['id'], 'foreign_table', ['id']);
$fk->setLocalTable(new Table('local_table'));
$diff->orphanedForeignKeys[] = $fk;
return $diff;
diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php
index 81db2c51e08..f7254c97cb7 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php
@@ -3,19 +3,24 @@
namespace Doctrine\Tests\DBAL\Schema;
use Doctrine\DBAL\Schema\Schema;
+use Doctrine\DBAL\Schema\SchemaConfig;
+use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
+use Doctrine\DBAL\Schema\Visitor\AbstractVisitor;
+use Doctrine\DBAL\Schema\Visitor\Visitor;
+use PHPUnit\Framework\TestCase;
use function current;
use function strlen;
-class SchemaTest extends \PHPUnit\Framework\TestCase
+class SchemaTest extends TestCase
{
public function testAddTable()
{
- $tableName = "public.foo";
- $table = new Table($tableName);
+ $tableName = 'public.foo';
+ $table = new Table($tableName);
- $schema = new Schema(array($table));
+ $schema = new Schema([$table]);
self::assertTrue($schema->hasTable($tableName));
@@ -28,11 +33,11 @@ public function testAddTable()
public function testTableMatchingCaseInsensitive()
{
- $table = new Table("Foo");
+ $table = new Table('Foo');
- $schema = new Schema(array($table));
- self::assertTrue($schema->hasTable("foo"));
- self::assertTrue($schema->hasTable("FOO"));
+ $schema = new Schema([$table]);
+ self::assertTrue($schema->hasTable('foo'));
+ self::assertTrue($schema->hasTable('FOO'));
self::assertSame($table, $schema->getTable('FOO'));
self::assertSame($table, $schema->getTable('foo'));
@@ -41,70 +46,70 @@ public function testTableMatchingCaseInsensitive()
public function testGetUnknownTableThrowsException()
{
- $this->expectException("Doctrine\DBAL\Schema\SchemaException");
+ $this->expectException(SchemaException::class);
$schema = new Schema();
- $schema->getTable("unknown");
+ $schema->getTable('unknown');
}
public function testCreateTableTwiceThrowsException()
{
- $this->expectException("Doctrine\DBAL\Schema\SchemaException");
+ $this->expectException(SchemaException::class);
- $tableName = "foo";
- $table = new Table($tableName);
- $tables = array($table, $table);
+ $tableName = 'foo';
+ $table = new Table($tableName);
+ $tables = [$table, $table];
$schema = new Schema($tables);
}
public function testRenameTable()
{
- $tableName = "foo";
- $table = new Table($tableName);
- $schema = new Schema(array($table));
-
- self::assertTrue($schema->hasTable("foo"));
- $schema->renameTable("foo", "bar");
- self::assertFalse($schema->hasTable("foo"));
- self::assertTrue($schema->hasTable("bar"));
- self::assertSame($table, $schema->getTable("bar"));
+ $tableName = 'foo';
+ $table = new Table($tableName);
+ $schema = new Schema([$table]);
+
+ self::assertTrue($schema->hasTable('foo'));
+ $schema->renameTable('foo', 'bar');
+ self::assertFalse($schema->hasTable('foo'));
+ self::assertTrue($schema->hasTable('bar'));
+ self::assertSame($table, $schema->getTable('bar'));
}
public function testDropTable()
{
- $tableName = "foo";
- $table = new Table($tableName);
- $schema = new Schema(array($table));
+ $tableName = 'foo';
+ $table = new Table($tableName);
+ $schema = new Schema([$table]);
- self::assertTrue($schema->hasTable("foo"));
+ self::assertTrue($schema->hasTable('foo'));
- $schema->dropTable("foo");
+ $schema->dropTable('foo');
- self::assertFalse($schema->hasTable("foo"));
+ self::assertFalse($schema->hasTable('foo'));
}
public function testCreateTable()
{
$schema = new Schema();
- self::assertFalse($schema->hasTable("foo"));
+ self::assertFalse($schema->hasTable('foo'));
- $table = $schema->createTable("foo");
+ $table = $schema->createTable('foo');
- self::assertInstanceOf('Doctrine\DBAL\Schema\Table', $table);
- self::assertEquals("foo", $table->getName());
- self::assertTrue($schema->hasTable("foo"));
+ self::assertInstanceOf(Table::class, $table);
+ self::assertEquals('foo', $table->getName());
+ self::assertTrue($schema->hasTable('foo'));
}
public function testAddSequences()
{
- $sequence = new Sequence("a_seq", 1, 1);
+ $sequence = new Sequence('a_seq', 1, 1);
- $schema = new Schema(array(), array($sequence));
+ $schema = new Schema([], [$sequence]);
- self::assertTrue($schema->hasSequence("a_seq"));
- self::assertInstanceOf('Doctrine\DBAL\Schema\Sequence', $schema->getSequence("a_seq"));
+ self::assertTrue($schema->hasSequence('a_seq'));
+ self::assertInstanceOf(Sequence::class, $schema->getSequence('a_seq'));
$sequences = $schema->getSequences();
self::assertArrayHasKey('public.a_seq', $sequences);
@@ -112,9 +117,9 @@ public function testAddSequences()
public function testSequenceAccessCaseInsensitive()
{
- $sequence = new Sequence("a_Seq");
+ $sequence = new Sequence('a_Seq');
- $schema = new Schema(array(), array($sequence));
+ $schema = new Schema([], [$sequence]);
self::assertTrue($schema->hasSequence('a_seq'));
self::assertTrue($schema->hasSequence('a_Seq'));
self::assertTrue($schema->hasSequence('A_SEQ'));
@@ -126,23 +131,23 @@ public function testSequenceAccessCaseInsensitive()
public function testGetUnknownSequenceThrowsException()
{
- $this->expectException("Doctrine\DBAL\Schema\SchemaException");
+ $this->expectException(SchemaException::class);
$schema = new Schema();
- $schema->getSequence("unknown");
+ $schema->getSequence('unknown');
}
public function testCreateSequence()
{
- $schema = new Schema();
+ $schema = new Schema();
$sequence = $schema->createSequence('a_seq', 10, 20);
self::assertEquals('a_seq', $sequence->getName());
self::assertEquals(10, $sequence->getAllocationSize());
self::assertEquals(20, $sequence->getInitialValue());
- self::assertTrue($schema->hasSequence("a_seq"));
- self::assertInstanceOf('Doctrine\DBAL\Schema\Sequence', $schema->getSequence("a_seq"));
+ self::assertTrue($schema->hasSequence('a_seq'));
+ self::assertInstanceOf(Sequence::class, $schema->getSequence('a_seq'));
$sequences = $schema->getSequences();
self::assertArrayHasKey('public.a_seq', $sequences);
@@ -150,32 +155,32 @@ public function testCreateSequence()
public function testDropSequence()
{
- $sequence = new Sequence("a_seq", 1, 1);
+ $sequence = new Sequence('a_seq', 1, 1);
- $schema = new Schema(array(), array($sequence));
+ $schema = new Schema([], [$sequence]);
- $schema->dropSequence("a_seq");
- self::assertFalse($schema->hasSequence("a_seq"));
+ $schema->dropSequence('a_seq');
+ self::assertFalse($schema->hasSequence('a_seq'));
}
public function testAddSequenceTwiceThrowsException()
{
- $this->expectException("Doctrine\DBAL\Schema\SchemaException");
+ $this->expectException(SchemaException::class);
- $sequence = new Sequence("a_seq", 1, 1);
+ $sequence = new Sequence('a_seq', 1, 1);
- $schema = new Schema(array(), array($sequence, $sequence));
+ $schema = new Schema([], [$sequence, $sequence]);
}
public function testConfigMaxIdentifierLength()
{
- $schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig();
+ $schemaConfig = new SchemaConfig();
$schemaConfig->setMaxIdentifierLength(5);
- $schema = new Schema(array(), array(), $schemaConfig);
- $table = $schema->createTable("smalltable");
+ $schema = new Schema([], [], $schemaConfig);
+ $table = $schema->createTable('smalltable');
$table->addColumn('long_id', 'integer');
- $table->addIndex(array('long_id'));
+ $table->addIndex(['long_id']);
$index = current($table->getIndexes());
self::assertEquals(5, strlen($index->getName()));
@@ -183,7 +188,7 @@ public function testConfigMaxIdentifierLength()
public function testDeepClone()
{
- $schema = new Schema();
+ $schema = new Schema();
$sequence = $schema->createSequence('baz');
$tableA = $schema->createTable('foo');
@@ -192,7 +197,7 @@ public function testDeepClone()
$tableB = $schema->createTable('bar');
$tableB->addColumn('id', 'integer');
$tableB->addColumn('foo_id', 'integer');
- $tableB->addForeignKeyConstraint($tableA, array('foo_id'), array('id'));
+ $tableB->addForeignKeyConstraint($tableA, ['foo_id'], ['id']);
$schemaNew = clone $schema;
@@ -269,12 +274,11 @@ public function testCreatesNamespace()
self::assertTrue($schema->hasNamespace('`bar`'));
self::assertTrue($schema->hasNamespace('`BAR`'));
- self::assertSame(array('foo' => 'foo', 'bar' => '`bar`'), $schema->getNamespaces());
+ self::assertSame(['foo' => 'foo', 'bar' => '`bar`'], $schema->getNamespaces());
}
/**
* @group DBAL-669
- *
* @expectedException \Doctrine\DBAL\Schema\SchemaException
*/
public function testThrowsExceptionOnCreatingNamespaceTwice()
@@ -350,8 +354,8 @@ public function testCreatesNamespaceThroughAddingSequenceImplicitly()
*/
public function testVisitsVisitor()
{
- $schema = new Schema();
- $visitor = $this->createMock('Doctrine\DBAL\Schema\Visitor\Visitor');
+ $schema = new Schema();
+ $visitor = $this->createMock(Visitor::class);
$schema->createNamespace('foo');
$schema->createNamespace('bar');
@@ -396,8 +400,8 @@ public function testVisitsVisitor()
*/
public function testVisitsNamespaceVisitor()
{
- $schema = new Schema();
- $visitor = $this->createMock('Doctrine\DBAL\Schema\Visitor\AbstractVisitor');
+ $schema = new Schema();
+ $visitor = $this->createMock(AbstractVisitor::class);
$schema->createNamespace('foo');
$schema->createNamespace('bar');
diff --git a/tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php b/tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php
index 9414830b48a..b3a72017c16 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php
@@ -4,21 +4,22 @@
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
+use Doctrine\Tests\DbalTestCase;
-class SequenceTest extends \Doctrine\Tests\DbalTestCase
+class SequenceTest extends DbalTestCase
{
/**
* @group DDC-1657
*/
public function testIsAutoincrementFor()
{
- $table = new Table("foo");
- $table->addColumn("id", "integer", array("autoincrement" => true));
- $table->setPrimaryKey(array("id"));
+ $table = new Table('foo');
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
+ $table->setPrimaryKey(['id']);
- $sequence = new Sequence("foo_id_seq");
- $sequence2 = new Sequence("bar_id_seq");
- $sequence3 = new Sequence("other.foo_id_seq");
+ $sequence = new Sequence('foo_id_seq');
+ $sequence2 = new Sequence('bar_id_seq');
+ $sequence3 = new Sequence('other.foo_id_seq');
self::assertTrue($sequence->isAutoIncrementsFor($table));
self::assertFalse($sequence2->isAutoIncrementsFor($table));
@@ -28,14 +29,14 @@ public function testIsAutoincrementFor()
public function testIsAutoincrementForCaseInsensitive()
{
$table = new Table('foo');
- $table->addColumn('ID', 'integer', array('autoincrement' => true));
- $table->setPrimaryKey(array('ID'));
+ $table->addColumn('ID', 'integer', ['autoincrement' => true]);
+ $table->setPrimaryKey(['ID']);
- $sequence = new Sequence("foo_id_seq");
- $sequence1 = new Sequence("foo_ID_seq");
- $sequence2 = new Sequence("bar_id_seq");
- $sequence3 = new Sequence("bar_ID_seq");
- $sequence4 = new Sequence("other.foo_id_seq");
+ $sequence = new Sequence('foo_id_seq');
+ $sequence1 = new Sequence('foo_ID_seq');
+ $sequence2 = new Sequence('bar_id_seq');
+ $sequence3 = new Sequence('bar_ID_seq');
+ $sequence4 = new Sequence('other.foo_id_seq');
self::assertTrue($sequence->isAutoIncrementsFor($table));
self::assertTrue($sequence1->isAutoIncrementsFor($table));
@@ -44,4 +45,3 @@ public function testIsAutoincrementForCaseInsensitive()
self::assertFalse($sequence4->isAutoIncrementsFor($table));
}
}
-
diff --git a/tests/Doctrine/Tests/DBAL/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/SqliteSchemaManagerTest.php
index 8a6759663e7..7b3031624af 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/SqliteSchemaManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/SqliteSchemaManagerTest.php
@@ -5,12 +5,13 @@
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\SqliteSchemaManager;
+use PHPUnit\Framework\TestCase;
+use ReflectionMethod;
-class SqliteSchemaManagerTest extends \PHPUnit\Framework\TestCase
+class SqliteSchemaManagerTest extends TestCase
{
/**
* @dataProvider getDataColumnCollation
- *
* @group 2865
*/
public function testParseColumnCollation(?string $collation, string $column, string $sql) : void
@@ -19,7 +20,7 @@ public function testParseColumnCollation(?string $collation, string $column, str
$conn->method('getDatabasePlatform')->willReturn(new SqlitePlatform());
$manager = new SqliteSchemaManager($conn);
- $ref = new \ReflectionMethod($manager, 'parseColumnCollationFromSQL');
+ $ref = new ReflectionMethod($manager, 'parseColumnCollationFromSQL');
$ref->setAccessible(true);
self::assertSame($collation, $ref->invoke($manager, $column, $sql));
@@ -49,7 +50,6 @@ public function getDataColumnCollation()
/**
* @dataProvider getDataColumnComment
- *
* @group 2865
*/
public function testParseColumnCommentFromSQL(?string $comment, string $column, string $sql) : void
@@ -58,7 +58,7 @@ public function testParseColumnCommentFromSQL(?string $comment, string $column,
$conn->method('getDatabasePlatform')->willReturn(new SqlitePlatform());
$manager = new SqliteSchemaManager($conn);
- $ref = new \ReflectionMethod($manager, 'parseColumnCommentFromSQL');
+ $ref = new ReflectionMethod($manager, 'parseColumnCommentFromSQL');
$ref->setAccessible(true);
self::assertSame($comment, $ref->invoke($manager, $column, $sql));
@@ -68,40 +68,58 @@ public function getDataColumnComment()
{
return [
'Single column with no comment' => [
- null, 'a', 'CREATE TABLE "a" ("a" TEXT DEFAULT "a" COLLATE RTRIM)',
+ null,
+ 'a',
+ 'CREATE TABLE "a" ("a" TEXT DEFAULT "a" COLLATE RTRIM)',
],
'Single column with type comment' => [
- '(DC2Type:x)', 'a', 'CREATE TABLE "a" ("a" CLOB DEFAULT NULL COLLATE BINARY --(DC2Type:x)
+ '(DC2Type:x)',
+ 'a',
+ 'CREATE TABLE "a" ("a" CLOB DEFAULT NULL COLLATE BINARY --(DC2Type:x)
)',
],
'Multiple similar columns with type comment 1' => [
- null, 'b', 'CREATE TABLE "a" (a TEXT COLLATE RTRIM, "b" TEXT DEFAULT "a" COLLATE RTRIM, "bb" CLOB DEFAULT NULL COLLATE BINARY --(DC2Type:x)
+ null,
+ 'b',
+ 'CREATE TABLE "a" (a TEXT COLLATE RTRIM, "b" TEXT DEFAULT "a" COLLATE RTRIM, "bb" CLOB DEFAULT NULL COLLATE BINARY --(DC2Type:x)
)',
],
'Multiple similar columns with type comment 2' => [
- '(DC2Type:x)', 'b', 'CREATE TABLE "a" (a TEXT COLLATE RTRIM, "bb" TEXT DEFAULT "a" COLLATE RTRIM, "b" CLOB DEFAULT NULL COLLATE BINARY --(DC2Type:x)
+ '(DC2Type:x)',
+ 'b',
+ 'CREATE TABLE "a" (a TEXT COLLATE RTRIM, "bb" TEXT DEFAULT "a" COLLATE RTRIM, "b" CLOB DEFAULT NULL COLLATE BINARY --(DC2Type:x)
)',
],
'Multiple similar columns on different lines, with type comment 1' => [
- null, 'bb', 'CREATE TABLE "a" (a TEXT COLLATE RTRIM, "b" CLOB DEFAULT NULL COLLATE BINARY --(DC2Type:x)
+ null,
+ 'bb',
+ 'CREATE TABLE "a" (a TEXT COLLATE RTRIM, "b" CLOB DEFAULT NULL COLLATE BINARY --(DC2Type:x)
, "bb" TEXT DEFAULT "a" COLLATE RTRIM',
],
'Multiple similar columns on different lines, with type comment 2' => [
- '(DC2Type:x)', 'bb', 'CREATE TABLE "a" (a TEXT COLLATE RTRIM, "bb" CLOB DEFAULT NULL COLLATE BINARY --(DC2Type:x)
+ '(DC2Type:x)',
+ 'bb',
+ 'CREATE TABLE "a" (a TEXT COLLATE RTRIM, "bb" CLOB DEFAULT NULL COLLATE BINARY --(DC2Type:x)
, "b" TEXT DEFAULT "a" COLLATE RTRIM',
],
'Column with numeric but no comment 1' => [
- null, 'a', 'CREATE TABLE "a" ("a" NUMERIC(10, 0) NOT NULL, "b" CLOB NOT NULL --(DC2Type:array)
+ null,
+ 'a',
+ 'CREATE TABLE "a" ("a" NUMERIC(10, 0) NOT NULL, "b" CLOB NOT NULL --(DC2Type:array)
, "c" CHAR(36) NOT NULL --(DC2Type:guid)
)',
],
'Column with numeric but no comment 2' => [
- null, 'a', 'CREATE TABLE "b" ("a" NUMERIC(10, 0) NOT NULL, "b" CLOB NOT NULL --(DC2Type:array)
+ null,
+ 'a',
+ 'CREATE TABLE "b" ("a" NUMERIC(10, 0) NOT NULL, "b" CLOB NOT NULL --(DC2Type:array)
, "c" CHAR(36) NOT NULL --(DC2Type:guid)
)',
],
'Column with numeric but no comment 3' => [
- '(DC2Type:guid)', 'c', 'CREATE TABLE "b" ("a" NUMERIC(10, 0) NOT NULL, "b" CLOB NOT NULL --(DC2Type:array)
+ '(DC2Type:guid)',
+ 'c',
+ 'CREATE TABLE "b" ("a" NUMERIC(10, 0) NOT NULL, "b" CLOB NOT NULL --(DC2Type:array)
, "c" CHAR(36) NOT NULL --(DC2Type:guid)
)',
],
diff --git a/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php b/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php
index 0071d217280..cedc3583137 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php
@@ -1,91 +1,78 @@
.
- */
namespace Doctrine\Tests\DBAL\Schema\Synchronizer;
+use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer;
+use PHPUnit\Framework\TestCase;
/**
* @requires extension pdo_sqlite
*/
-class SingleDatabaseSynchronizerTest extends \PHPUnit\Framework\TestCase
+class SingleDatabaseSynchronizerTest extends TestCase
{
+ /** @var Connection */
private $conn;
+
+ /** @var SingleDatabaseSynchronizer */
private $synchronizer;
protected function setUp()
{
- $this->conn = DriverManager::getConnection(array(
+ $this->conn = DriverManager::getConnection([
'driver' => 'pdo_sqlite',
'memory' => true,
- ));
+ ]);
$this->synchronizer = new SingleDatabaseSynchronizer($this->conn);
}
public function testGetCreateSchema()
{
$schema = new Schema();
- $table = $schema->createTable('test');
+ $table = $schema->createTable('test');
$table->addColumn('id', 'integer');
- $table->setPrimaryKey(array('id'));
+ $table->setPrimaryKey(['id']);
$sql = $this->synchronizer->getCreateSchema($schema);
- self::assertEquals(array('CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'), $sql);
+ self::assertEquals(['CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'], $sql);
}
public function testGetUpdateSchema()
{
$schema = new Schema();
- $table = $schema->createTable('test');
+ $table = $schema->createTable('test');
$table->addColumn('id', 'integer');
- $table->setPrimaryKey(array('id'));
+ $table->setPrimaryKey(['id']);
$sql = $this->synchronizer->getUpdateSchema($schema);
- self::assertEquals(array('CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'), $sql);
+ self::assertEquals(['CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'], $sql);
}
public function testGetDropSchema()
{
$schema = new Schema();
- $table = $schema->createTable('test');
+ $table = $schema->createTable('test');
$table->addColumn('id', 'integer');
- $table->setPrimaryKey(array('id'));
+ $table->setPrimaryKey(['id']);
$this->synchronizer->createSchema($schema);
$sql = $this->synchronizer->getDropSchema($schema);
- self::assertEquals(array('DROP TABLE test'), $sql);
+ self::assertEquals(['DROP TABLE test'], $sql);
}
public function testGetDropAllSchema()
{
$schema = new Schema();
- $table = $schema->createTable('test');
+ $table = $schema->createTable('test');
$table->addColumn('id', 'integer');
- $table->setPrimaryKey(array('id'));
+ $table->setPrimaryKey(['id']);
$this->synchronizer->createSchema($schema);
$sql = $this->synchronizer->getDropAllSchema();
- self::assertEquals(array('DROP TABLE test'), $sql);
+ self::assertEquals(['DROP TABLE test'], $sql);
}
}
-
diff --git a/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php
index f78d9519a12..80b9ef7b2c2 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php
@@ -3,10 +3,12 @@
namespace Doctrine\Tests\DBAL\Schema;
use Doctrine\DBAL\Schema\Identifier;
+use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use PHPUnit\Framework\TestCase;
-class TableDiffTest extends \PHPUnit\Framework\TestCase
+class TableDiffTest extends TestCase
{
/**
* @group DBAL-1013
@@ -24,11 +26,11 @@ public function testReturnsName()
public function testPrefersNameFromTableObject()
{
$platformMock = new MockPlatform();
- $tableMock = $this->getMockBuilder('Doctrine\DBAL\Schema\Table')
+ $tableMock = $this->getMockBuilder(Table::class)
->disableOriginalConstructor()
->getMock();
- $tableDiff = new TableDiff('foo');
+ $tableDiff = new TableDiff('foo');
$tableDiff->fromTable = $tableMock;
$tableMock->expects($this->once())
diff --git a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php
index 9c4dee07eed..ac5fead5bcf 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php
@@ -3,50 +3,54 @@
namespace Doctrine\Tests\DBAL\Schema;
use Doctrine\DBAL\DBALException;
+use Doctrine\DBAL\Platforms\MySqlPlatform;
+use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index;
+use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
+use Doctrine\Tests\DbalTestCase;
use function array_shift;
use function current;
-class TableTest extends \Doctrine\Tests\DbalTestCase
+class TableTest extends DbalTestCase
{
public function testCreateWithInvalidTableName()
{
$this->expectException(DBALException::class);
- new \Doctrine\DBAL\Schema\Table('');
+ new Table('');
}
public function testGetName()
{
- $table = new Table("foo", array(), array(), array());
- self::assertEquals("foo", $table->getName());
+ $table = new Table('foo', [], [], []);
+ self::assertEquals('foo', $table->getName());
}
public function testColumns()
{
- $type = Type::getType('integer');
- $columns = array();
- $columns[] = new Column("foo", $type);
- $columns[] = new Column("bar", $type);
- $table = new Table("foo", $columns, array(), array());
+ $type = Type::getType('integer');
+ $columns = [];
+ $columns[] = new Column('foo', $type);
+ $columns[] = new Column('bar', $type);
+ $table = new Table('foo', $columns, [], []);
- self::assertTrue($table->hasColumn("foo"));
- self::assertTrue($table->hasColumn("bar"));
- self::assertFalse($table->hasColumn("baz"));
+ self::assertTrue($table->hasColumn('foo'));
+ self::assertTrue($table->hasColumn('bar'));
+ self::assertFalse($table->hasColumn('baz'));
- self::assertInstanceOf('Doctrine\DBAL\Schema\Column', $table->getColumn("foo"));
- self::assertInstanceOf('Doctrine\DBAL\Schema\Column', $table->getColumn("bar"));
+ self::assertInstanceOf(Column::class, $table->getColumn('foo'));
+ self::assertInstanceOf(Column::class, $table->getColumn('bar'));
self::assertCount(2, $table->getColumns());
}
public function testColumnsCaseInsensitive()
{
- $table = new Table("foo");
+ $table = new Table('foo');
$column = $table->addColumn('Foo', 'integer');
self::assertTrue($table->hasColumn('Foo'));
@@ -62,74 +66,74 @@ public function testCreateColumn()
{
$type = Type::getType('integer');
- $table = new Table("foo");
+ $table = new Table('foo');
- self::assertFalse($table->hasColumn("bar"));
- $table->addColumn("bar", 'integer');
- self::assertTrue($table->hasColumn("bar"));
- self::assertSame($type, $table->getColumn("bar")->getType());
+ self::assertFalse($table->hasColumn('bar'));
+ $table->addColumn('bar', 'integer');
+ self::assertTrue($table->hasColumn('bar'));
+ self::assertSame($type, $table->getColumn('bar')->getType());
}
public function testDropColumn()
{
- $type = Type::getType('integer');
- $columns = array();
- $columns[] = new Column("foo", $type);
- $columns[] = new Column("bar", $type);
- $table = new Table("foo", $columns, array(), array());
+ $type = Type::getType('integer');
+ $columns = [];
+ $columns[] = new Column('foo', $type);
+ $columns[] = new Column('bar', $type);
+ $table = new Table('foo', $columns, [], []);
- self::assertTrue($table->hasColumn("foo"));
- self::assertTrue($table->hasColumn("bar"));
+ self::assertTrue($table->hasColumn('foo'));
+ self::assertTrue($table->hasColumn('bar'));
- $table->dropColumn("foo")->dropColumn("bar");
+ $table->dropColumn('foo')->dropColumn('bar');
- self::assertFalse($table->hasColumn("foo"));
- self::assertFalse($table->hasColumn("bar"));
+ self::assertFalse($table->hasColumn('foo'));
+ self::assertFalse($table->hasColumn('bar'));
}
public function testGetUnknownColumnThrowsException()
{
- $this->expectException("Doctrine\DBAL\Schema\SchemaException");
+ $this->expectException(SchemaException::class);
- $table = new Table("foo", array(), array(), array());
+ $table = new Table('foo', [], [], []);
$table->getColumn('unknown');
}
public function testAddColumnTwiceThrowsException()
{
- $this->expectException("Doctrine\DBAL\Schema\SchemaException");
+ $this->expectException(SchemaException::class);
- $type = \Doctrine\DBAL\Types\Type::getType('integer');
- $columns = array();
- $columns[] = new Column("foo", $type);
- $columns[] = new Column("foo", $type);
- $table = new Table("foo", $columns, array(), array());
+ $type = Type::getType('integer');
+ $columns = [];
+ $columns[] = new Column('foo', $type);
+ $columns[] = new Column('foo', $type);
+ $table = new Table('foo', $columns, [], []);
}
public function testCreateIndex()
{
- $type = \Doctrine\DBAL\Types\Type::getType('integer');
- $columns = array(new Column("foo", $type), new Column("bar", $type), new Column("baz", $type));
- $table = new Table("foo", $columns);
+ $type = Type::getType('integer');
+ $columns = [new Column('foo', $type), new Column('bar', $type), new Column('baz', $type)];
+ $table = new Table('foo', $columns);
- $table->addIndex(array("foo", "bar"), "foo_foo_bar_idx");
- $table->addUniqueIndex(array("bar", "baz"), "foo_bar_baz_uniq");
+ $table->addIndex(['foo', 'bar'], 'foo_foo_bar_idx');
+ $table->addUniqueIndex(['bar', 'baz'], 'foo_bar_baz_uniq');
- self::assertTrue($table->hasIndex("foo_foo_bar_idx"));
- self::assertTrue($table->hasIndex("foo_bar_baz_uniq"));
+ self::assertTrue($table->hasIndex('foo_foo_bar_idx'));
+ self::assertTrue($table->hasIndex('foo_bar_baz_uniq'));
}
public function testIndexCaseInsensitive()
{
- $type = \Doctrine\DBAL\Types\Type::getType('integer');
- $columns = array(
- new Column("foo", $type),
- new Column("bar", $type),
- new Column("baz", $type)
- );
- $table = new Table("foo", $columns);
+ $type = Type::getType('integer');
+ $columns = [
+ new Column('foo', $type),
+ new Column('bar', $type),
+ new Column('baz', $type),
+ ];
+ $table = new Table('foo', $columns);
- $table->addIndex(array("foo", "bar", "baz"), "Foo_Idx");
+ $table->addIndex(['foo', 'bar', 'baz'], 'Foo_Idx');
self::assertTrue($table->hasIndex('foo_idx'));
self::assertTrue($table->hasIndex('Foo_Idx'));
@@ -138,65 +142,65 @@ public function testIndexCaseInsensitive()
public function testAddIndexes()
{
- $type = \Doctrine\DBAL\Types\Type::getType('integer');
- $columns = array(
- new Column("foo", $type),
- new Column("bar", $type),
- );
- $indexes = array(
- new Index("the_primary", array("foo"), true, true),
- new Index("bar_idx", array("bar"), false, false),
- );
- $table = new Table("foo", $columns, $indexes, array());
-
- self::assertTrue($table->hasIndex("the_primary"));
- self::assertTrue($table->hasIndex("bar_idx"));
- self::assertFalse($table->hasIndex("some_idx"));
+ $type = Type::getType('integer');
+ $columns = [
+ new Column('foo', $type),
+ new Column('bar', $type),
+ ];
+ $indexes = [
+ new Index('the_primary', ['foo'], true, true),
+ new Index('bar_idx', ['bar'], false, false),
+ ];
+ $table = new Table('foo', $columns, $indexes, []);
+
+ self::assertTrue($table->hasIndex('the_primary'));
+ self::assertTrue($table->hasIndex('bar_idx'));
+ self::assertFalse($table->hasIndex('some_idx'));
- self::assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getPrimaryKey());
- self::assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getIndex('the_primary'));
- self::assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getIndex('bar_idx'));
+ self::assertInstanceOf(Index::class, $table->getPrimaryKey());
+ self::assertInstanceOf(Index::class, $table->getIndex('the_primary'));
+ self::assertInstanceOf(Index::class, $table->getIndex('bar_idx'));
}
public function testGetUnknownIndexThrowsException()
{
- $this->expectException("Doctrine\DBAL\Schema\SchemaException");
+ $this->expectException(SchemaException::class);
- $table = new Table("foo", array(), array(), array());
- $table->getIndex("unknownIndex");
+ $table = new Table('foo', [], [], []);
+ $table->getIndex('unknownIndex');
}
public function testAddTwoPrimaryThrowsException()
{
- $this->expectException("Doctrine\DBAL\Schema\SchemaException");
+ $this->expectException(SchemaException::class);
- $type = \Doctrine\DBAL\Types\Type::getType('integer');
- $columns = array(new Column("foo", $type), new Column("bar", $type));
- $indexes = array(
- new Index("the_primary", array("foo"), true, true),
- new Index("other_primary", array("bar"), true, true),
- );
- $table = new Table("foo", $columns, $indexes, array());
+ $type = Type::getType('integer');
+ $columns = [new Column('foo', $type), new Column('bar', $type)];
+ $indexes = [
+ new Index('the_primary', ['foo'], true, true),
+ new Index('other_primary', ['bar'], true, true),
+ ];
+ $table = new Table('foo', $columns, $indexes, []);
}
public function testAddTwoIndexesWithSameNameThrowsException()
{
- $this->expectException("Doctrine\DBAL\Schema\SchemaException");
+ $this->expectException(SchemaException::class);
- $type = \Doctrine\DBAL\Types\Type::getType('integer');
- $columns = array(new Column("foo", $type), new Column("bar", $type));
- $indexes = array(
- new Index("an_idx", array("foo"), false, false),
- new Index("an_idx", array("bar"), false, false),
- );
- $table = new Table("foo", $columns, $indexes, array());
+ $type = Type::getType('integer');
+ $columns = [new Column('foo', $type), new Column('bar', $type)];
+ $indexes = [
+ new Index('an_idx', ['foo'], false, false),
+ new Index('an_idx', ['bar'], false, false),
+ ];
+ $table = new Table('foo', $columns, $indexes, []);
}
public function testConstraints()
{
- $constraint = new ForeignKeyConstraint(array(), "foo", array());
+ $constraint = new ForeignKeyConstraint([], 'foo', []);
- $tableA = new Table("foo", array(), array(), array($constraint));
+ $tableA = new Table('foo', [], [], [$constraint]);
$constraints = $tableA->getForeignKeys();
self::assertCount(1, $constraints);
@@ -205,140 +209,140 @@ public function testConstraints()
public function testOptions()
{
- $table = new Table("foo", array(), array(), array(), false, array("foo" => "bar"));
+ $table = new Table('foo', [], [], [], false, ['foo' => 'bar']);
- self::assertTrue($table->hasOption("foo"));
- self::assertEquals("bar", $table->getOption("foo"));
+ self::assertTrue($table->hasOption('foo'));
+ self::assertEquals('bar', $table->getOption('foo'));
}
public function testBuilderSetPrimaryKey()
{
- $table = new Table("foo");
+ $table = new Table('foo');
- $table->addColumn("bar", 'integer');
- $table->setPrimaryKey(array("bar"));
+ $table->addColumn('bar', 'integer');
+ $table->setPrimaryKey(['bar']);
- self::assertTrue($table->hasIndex("primary"));
- self::assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getPrimaryKey());
- self::assertTrue($table->getIndex("primary")->isUnique());
- self::assertTrue($table->getIndex("primary")->isPrimary());
+ self::assertTrue($table->hasIndex('primary'));
+ self::assertInstanceOf(Index::class, $table->getPrimaryKey());
+ self::assertTrue($table->getIndex('primary')->isUnique());
+ self::assertTrue($table->getIndex('primary')->isPrimary());
}
public function testBuilderAddUniqueIndex()
{
- $table = new Table("foo");
+ $table = new Table('foo');
- $table->addColumn("bar", 'integer');
- $table->addUniqueIndex(array("bar"), "my_idx");
+ $table->addColumn('bar', 'integer');
+ $table->addUniqueIndex(['bar'], 'my_idx');
- self::assertTrue($table->hasIndex("my_idx"));
- self::assertTrue($table->getIndex("my_idx")->isUnique());
- self::assertFalse($table->getIndex("my_idx")->isPrimary());
+ self::assertTrue($table->hasIndex('my_idx'));
+ self::assertTrue($table->getIndex('my_idx')->isUnique());
+ self::assertFalse($table->getIndex('my_idx')->isPrimary());
}
public function testBuilderAddIndex()
{
- $table = new Table("foo");
+ $table = new Table('foo');
- $table->addColumn("bar", 'integer');
- $table->addIndex(array("bar"), "my_idx");
+ $table->addColumn('bar', 'integer');
+ $table->addIndex(['bar'], 'my_idx');
- self::assertTrue($table->hasIndex("my_idx"));
- self::assertFalse($table->getIndex("my_idx")->isUnique());
- self::assertFalse($table->getIndex("my_idx")->isPrimary());
+ self::assertTrue($table->hasIndex('my_idx'));
+ self::assertFalse($table->getIndex('my_idx')->isUnique());
+ self::assertFalse($table->getIndex('my_idx')->isPrimary());
}
public function testBuilderAddIndexWithInvalidNameThrowsException()
{
- $this->expectException("Doctrine\DBAL\Schema\SchemaException");
+ $this->expectException(SchemaException::class);
- $table = new Table("foo");
- $table->addColumn("bar",'integer');
- $table->addIndex(array("bar"), "invalid name %&/");
+ $table = new Table('foo');
+ $table->addColumn('bar', 'integer');
+ $table->addIndex(['bar'], 'invalid name %&/');
}
public function testBuilderAddIndexWithUnknownColumnThrowsException()
{
- $this->expectException("Doctrine\DBAL\Schema\SchemaException");
+ $this->expectException(SchemaException::class);
- $table = new Table("foo");
- $table->addIndex(array("bar"), "invalidName");
+ $table = new Table('foo');
+ $table->addIndex(['bar'], 'invalidName');
}
public function testBuilderOptions()
{
- $table = new Table("foo");
- $table->addOption("foo", "bar");
- self::assertTrue($table->hasOption("foo"));
- self::assertEquals("bar", $table->getOption("foo"));
+ $table = new Table('foo');
+ $table->addOption('foo', 'bar');
+ self::assertTrue($table->hasOption('foo'));
+ self::assertEquals('bar', $table->getOption('foo'));
}
- public function testAddForeignKeyConstraint_UnknownLocalColumn_ThrowsException()
+ public function testAddForeignKeyConstraintUnknownLocalColumnThrowsException()
{
- $this->expectException("Doctrine\DBAL\Schema\SchemaException");
+ $this->expectException(SchemaException::class);
- $table = new Table("foo");
- $table->addColumn("id", 'integer');
+ $table = new Table('foo');
+ $table->addColumn('id', 'integer');
- $foreignTable = new Table("bar");
- $foreignTable->addColumn("id", 'integer');
+ $foreignTable = new Table('bar');
+ $foreignTable->addColumn('id', 'integer');
- $table->addForeignKeyConstraint($foreignTable, array("foo"), array("id"));
+ $table->addForeignKeyConstraint($foreignTable, ['foo'], ['id']);
}
- public function testAddForeignKeyConstraint_UnknownForeignColumn_ThrowsException()
+ public function testAddForeignKeyConstraintUnknownForeignColumnThrowsException()
{
- $this->expectException("Doctrine\DBAL\Schema\SchemaException");
+ $this->expectException(SchemaException::class);
- $table = new Table("foo");
- $table->addColumn("id", 'integer');
+ $table = new Table('foo');
+ $table->addColumn('id', 'integer');
- $foreignTable = new Table("bar");
- $foreignTable->addColumn("id", 'integer');
+ $foreignTable = new Table('bar');
+ $foreignTable->addColumn('id', 'integer');
- $table->addForeignKeyConstraint($foreignTable, array("id"), array("foo"));
+ $table->addForeignKeyConstraint($foreignTable, ['id'], ['foo']);
}
public function testAddForeignKeyConstraint()
{
- $table = new Table("foo");
- $table->addColumn("id", 'integer');
+ $table = new Table('foo');
+ $table->addColumn('id', 'integer');
- $foreignTable = new Table("bar");
- $foreignTable->addColumn("id", 'integer');
+ $foreignTable = new Table('bar');
+ $foreignTable->addColumn('id', 'integer');
- $table->addForeignKeyConstraint($foreignTable, array("id"), array("id"), array("foo" => "bar"));
+ $table->addForeignKeyConstraint($foreignTable, ['id'], ['id'], ['foo' => 'bar']);
$constraints = $table->getForeignKeys();
self::assertCount(1, $constraints);
$constraint = current($constraints);
- self::assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $constraint);
+ self::assertInstanceOf(ForeignKeyConstraint::class, $constraint);
- self::assertTrue($constraint->hasOption("foo"));
- self::assertEquals("bar", $constraint->getOption("foo"));
+ self::assertTrue($constraint->hasOption('foo'));
+ self::assertEquals('bar', $constraint->getOption('foo'));
}
public function testAddIndexWithCaseSensitiveColumnProblem()
{
- $table = new Table("foo");
- $table->addColumn("id", 'integer');
+ $table = new Table('foo');
+ $table->addColumn('id', 'integer');
- $table->addIndex(array("ID"), "my_idx");
+ $table->addIndex(['ID'], 'my_idx');
self::assertTrue($table->hasIndex('my_idx'));
- self::assertEquals(array("ID"), $table->getIndex("my_idx")->getColumns());
- self::assertTrue($table->getIndex('my_idx')->spansColumns(array('id')));
+ self::assertEquals(['ID'], $table->getIndex('my_idx')->getColumns());
+ self::assertTrue($table->getIndex('my_idx')->spansColumns(['id']));
}
- public function testAddPrimaryKey_ColumnsAreExplicitlySetToNotNull()
+ public function testAddPrimaryKeyColumnsAreExplicitlySetToNotNull()
{
- $table = new Table("foo");
- $column = $table->addColumn("id", 'integer', array('notnull' => false));
+ $table = new Table('foo');
+ $column = $table->addColumn('id', 'integer', ['notnull' => false]);
self::assertFalse($column->getNotnull());
- $table->setPrimaryKey(array('id'));
+ $table->setPrimaryKey(['id']);
self::assertTrue($column->getNotnull());
}
@@ -348,9 +352,9 @@ public function testAddPrimaryKey_ColumnsAreExplicitlySetToNotNull()
*/
public function testAllowImplicitSchemaTableInAutogeneratedIndexNames()
{
- $table = new Table("foo.bar");
- $table->addColumn('baz', 'integer', array());
- $table->addIndex(array('baz'));
+ $table = new Table('foo.bar');
+ $table->addColumn('baz', 'integer', []);
+ $table->addIndex(['baz']);
self::assertCount(1, $table->getIndexes());
}
@@ -360,20 +364,20 @@ public function testAllowImplicitSchemaTableInAutogeneratedIndexNames()
*/
public function testAddForeignKeyIndexImplicitly()
{
- $table = new Table("foo");
- $table->addColumn("id", 'integer');
+ $table = new Table('foo');
+ $table->addColumn('id', 'integer');
- $foreignTable = new Table("bar");
- $foreignTable->addColumn("id", 'integer');
+ $foreignTable = new Table('bar');
+ $foreignTable->addColumn('id', 'integer');
- $table->addForeignKeyConstraint($foreignTable, array("id"), array("id"), array("foo" => "bar"));
+ $table->addForeignKeyConstraint($foreignTable, ['id'], ['id'], ['foo' => 'bar']);
$indexes = $table->getIndexes();
self::assertCount(1, $indexes);
$index = current($indexes);
self::assertTrue($table->hasIndex($index->getName()));
- self::assertEquals(array('id'), $index->getColumns());
+ self::assertEquals(['id'], $index->getColumns());
}
/**
@@ -383,16 +387,16 @@ public function testAddForeignKeyDoesNotCreateDuplicateIndex()
{
$table = new Table('foo');
$table->addColumn('bar', 'integer');
- $table->addIndex(array('bar'), 'bar_idx');
+ $table->addIndex(['bar'], 'bar_idx');
$foreignTable = new Table('bar');
$foreignTable->addColumn('foo', 'integer');
- $table->addForeignKeyConstraint($foreignTable, array('bar'), array('foo'));
+ $table->addForeignKeyConstraint($foreignTable, ['bar'], ['foo']);
self::assertCount(1, $table->getIndexes());
self::assertTrue($table->hasIndex('bar_idx'));
- self::assertSame(array('bar'), $table->getIndex('bar_idx')->getColumns());
+ self::assertSame(['bar'], $table->getIndex('bar_idx')->getColumns());
}
/**
@@ -404,22 +408,22 @@ public function testAddForeignKeyAddsImplicitIndexIfIndexColumnsDoNotSpan()
$table->addColumn('bar', 'integer');
$table->addColumn('baz', 'string');
$table->addColumn('bloo', 'string');
- $table->addIndex(array('baz', 'bar'), 'composite_idx');
- $table->addIndex(array('bar', 'baz', 'bloo'), 'full_idx');
+ $table->addIndex(['baz', 'bar'], 'composite_idx');
+ $table->addIndex(['bar', 'baz', 'bloo'], 'full_idx');
$foreignTable = new Table('bar');
$foreignTable->addColumn('foo', 'integer');
$foreignTable->addColumn('baz', 'string');
- $table->addForeignKeyConstraint($foreignTable, array('bar', 'baz'), array('foo', 'baz'));
+ $table->addForeignKeyConstraint($foreignTable, ['bar', 'baz'], ['foo', 'baz']);
self::assertCount(3, $table->getIndexes());
self::assertTrue($table->hasIndex('composite_idx'));
self::assertTrue($table->hasIndex('full_idx'));
self::assertTrue($table->hasIndex('idx_8c73652176ff8caa78240498'));
- self::assertSame(array('baz', 'bar'), $table->getIndex('composite_idx')->getColumns());
- self::assertSame(array('bar', 'baz', 'bloo'), $table->getIndex('full_idx')->getColumns());
- self::assertSame(array('bar', 'baz'), $table->getIndex('idx_8c73652176ff8caa78240498')->getColumns());
+ self::assertSame(['baz', 'bar'], $table->getIndex('composite_idx')->getColumns());
+ self::assertSame(['bar', 'baz', 'bloo'], $table->getIndex('full_idx')->getColumns());
+ self::assertSame(['bar', 'baz'], $table->getIndex('idx_8c73652176ff8caa78240498')->getColumns());
}
/**
@@ -428,15 +432,15 @@ public function testAddForeignKeyAddsImplicitIndexIfIndexColumnsDoNotSpan()
*/
public function testOverrulingIndexDoesNotDropOverruledIndex()
{
- $table = new Table("bar");
- $table->addColumn('baz', 'integer', array());
- $table->addIndex(array('baz'));
+ $table = new Table('bar');
+ $table->addColumn('baz', 'integer', []);
+ $table->addIndex(['baz']);
$indexes = $table->getIndexes();
self::assertCount(1, $indexes);
$index = current($indexes);
- $table->addUniqueIndex(array('baz'));
+ $table->addUniqueIndex(['baz']);
self::assertCount(2, $table->getIndexes());
self::assertTrue($table->hasIndex($index->getName()));
}
@@ -448,14 +452,14 @@ public function testAllowsAddingDuplicateIndexesBasedOnColumns()
{
$table = new Table('foo');
$table->addColumn('bar', 'integer');
- $table->addIndex(array('bar'), 'bar_idx');
- $table->addIndex(array('bar'), 'duplicate_idx');
+ $table->addIndex(['bar'], 'bar_idx');
+ $table->addIndex(['bar'], 'duplicate_idx');
self::assertCount(2, $table->getIndexes());
self::assertTrue($table->hasIndex('bar_idx'));
self::assertTrue($table->hasIndex('duplicate_idx'));
- self::assertSame(array('bar'), $table->getIndex('bar_idx')->getColumns());
- self::assertSame(array('bar'), $table->getIndex('duplicate_idx')->getColumns());
+ self::assertSame(['bar'], $table->getIndex('bar_idx')->getColumns());
+ self::assertSame(['bar'], $table->getIndex('duplicate_idx')->getColumns());
}
/**
@@ -466,14 +470,14 @@ public function testAllowsAddingFulfillingIndexesBasedOnColumns()
$table = new Table('foo');
$table->addColumn('bar', 'integer');
$table->addColumn('baz', 'string');
- $table->addIndex(array('bar'), 'bar_idx');
- $table->addIndex(array('bar', 'baz'), 'fulfilling_idx');
+ $table->addIndex(['bar'], 'bar_idx');
+ $table->addIndex(['bar', 'baz'], 'fulfilling_idx');
self::assertCount(2, $table->getIndexes());
self::assertTrue($table->hasIndex('bar_idx'));
self::assertTrue($table->hasIndex('fulfilling_idx'));
- self::assertSame(array('bar'), $table->getIndex('bar_idx')->getColumns());
- self::assertSame(array('bar', 'baz'), $table->getIndex('fulfilling_idx')->getColumns());
+ self::assertSame(['bar'], $table->getIndex('bar_idx')->getColumns());
+ self::assertSame(['bar', 'baz'], $table->getIndex('fulfilling_idx')->getColumns());
}
/**
@@ -482,14 +486,14 @@ public function testAllowsAddingFulfillingIndexesBasedOnColumns()
*/
public function testPrimaryKeyOverrulingUniqueIndexDoesNotDropUniqueIndex()
{
- $table = new Table("bar");
- $table->addColumn('baz', 'integer', array());
- $table->addUniqueIndex(array('baz'), 'idx_unique');
+ $table = new Table('bar');
+ $table->addColumn('baz', 'integer', []);
+ $table->addUniqueIndex(['baz'], 'idx_unique');
- $table->setPrimaryKey(array('baz'));
+ $table->setPrimaryKey(['baz']);
$indexes = $table->getIndexes();
- self::assertCount(2, $indexes, "Table should only contain both the primary key table index and the unique one, even though it was overruled.");
+ self::assertCount(2, $indexes, 'Table should only contain both the primary key table index and the unique one, even though it was overruled.');
self::assertTrue($table->hasPrimaryKey());
self::assertTrue($table->hasIndex('idx_unique'));
@@ -502,11 +506,11 @@ public function testAddingFulfillingRegularIndexOverridesImplicitForeignKeyConst
$localTable = new Table('local');
$localTable->addColumn('id', 'integer');
- $localTable->addForeignKeyConstraint($foreignTable, array('id'), array('id'));
+ $localTable->addForeignKeyConstraint($foreignTable, ['id'], ['id']);
self::assertCount(1, $localTable->getIndexes());
- $localTable->addIndex(array('id'), 'explicit_idx');
+ $localTable->addIndex(['id'], 'explicit_idx');
self::assertCount(1, $localTable->getIndexes());
self::assertTrue($localTable->hasIndex('explicit_idx'));
@@ -519,11 +523,11 @@ public function testAddingFulfillingUniqueIndexOverridesImplicitForeignKeyConstr
$localTable = new Table('local');
$localTable->addColumn('id', 'integer');
- $localTable->addForeignKeyConstraint($foreignTable, array('id'), array('id'));
+ $localTable->addForeignKeyConstraint($foreignTable, ['id'], ['id']);
self::assertCount(1, $localTable->getIndexes());
- $localTable->addUniqueIndex(array('id'), 'explicit_idx');
+ $localTable->addUniqueIndex(['id'], 'explicit_idx');
self::assertCount(1, $localTable->getIndexes());
self::assertTrue($localTable->hasIndex('explicit_idx'));
@@ -536,11 +540,11 @@ public function testAddingFulfillingPrimaryKeyOverridesImplicitForeignKeyConstra
$localTable = new Table('local');
$localTable->addColumn('id', 'integer');
- $localTable->addForeignKeyConstraint($foreignTable, array('id'), array('id'));
+ $localTable->addForeignKeyConstraint($foreignTable, ['id'], ['id']);
self::assertCount(1, $localTable->getIndexes());
- $localTable->setPrimaryKey(array('id'), 'explicit_idx');
+ $localTable->setPrimaryKey(['id'], 'explicit_idx');
self::assertCount(1, $localTable->getIndexes());
self::assertTrue($localTable->hasIndex('explicit_idx'));
@@ -553,14 +557,14 @@ public function testAddingFulfillingExplicitIndexOverridingImplicitForeignKeyCon
$localTable = new Table('local');
$localTable->addColumn('id', 'integer');
- $localTable->addForeignKeyConstraint($foreignTable, array('id'), array('id'));
+ $localTable->addForeignKeyConstraint($foreignTable, ['id'], ['id']);
self::assertCount(1, $localTable->getIndexes());
self::assertTrue($localTable->hasIndex('IDX_8BD688E8BF396750'));
$implicitIndex = $localTable->getIndex('IDX_8BD688E8BF396750');
- $localTable->addIndex(array('id'), 'IDX_8BD688E8BF396750');
+ $localTable->addIndex(['id'], 'IDX_8BD688E8BF396750');
self::assertCount(1, $localTable->getIndexes());
self::assertTrue($localTable->hasIndex('IDX_8BD688E8BF396750'));
@@ -572,10 +576,10 @@ public function testAddingFulfillingExplicitIndexOverridingImplicitForeignKeyCon
*/
public function testQuotedTableName()
{
- $table = new Table("`bar`");
+ $table = new Table('`bar`');
- $mysqlPlatform = new \Doctrine\DBAL\Platforms\MySqlPlatform();
- $sqlitePlatform = new \Doctrine\DBAL\Platforms\SqlitePlatform();
+ $mysqlPlatform = new MySqlPlatform();
+ $sqlitePlatform = new SqlitePlatform();
self::assertEquals('bar', $table->getName());
self::assertEquals('`bar`', $table->getQuotedName($mysqlPlatform));
@@ -587,12 +591,12 @@ public function testQuotedTableName()
*/
public function testTableHasPrimaryKey()
{
- $table = new Table("test");
+ $table = new Table('test');
self::assertFalse($table->hasPrimaryKey());
- $table->addColumn("foo", "integer");
- $table->setPrimaryKey(array("foo"));
+ $table->addColumn('foo', 'integer');
+ $table->setPrimaryKey(['foo']);
self::assertTrue($table->hasPrimaryKey());
}
@@ -602,7 +606,7 @@ public function testTableHasPrimaryKey()
*/
public function testAddIndexWithQuotedColumns()
{
- $table = new Table("test");
+ $table = new Table('test');
$table->addColumn('"foo"', 'integer');
$table->addColumn('bar', 'integer');
$table->addIndex(['"foo"', '"bar"']);
@@ -615,10 +619,10 @@ public function testAddIndexWithQuotedColumns()
*/
public function testAddForeignKeyWithQuotedColumnsAndTable()
{
- $table = new Table("test");
+ $table = new Table('test');
$table->addColumn('"foo"', 'integer');
$table->addColumn('bar', 'integer');
- $table->addForeignKeyConstraint('"boing"', ['"foo"', '"bar"'], ["id"]);
+ $table->addForeignKeyConstraint('"boing"', ['"foo"', '"bar"'], ['id']);
self::assertCount(1, $table->getForeignKeys());
}
@@ -628,9 +632,9 @@ public function testAddForeignKeyWithQuotedColumnsAndTable()
*/
public function testQuoteSchemaPrefixed()
{
- $table = new Table("`test`.`test`");
- self::assertEquals("test.test", $table->getName());
- self::assertEquals("`test`.`test`", $table->getQuotedName(new \Doctrine\DBAL\Platforms\MySqlPlatform));
+ $table = new Table('`test`.`test`');
+ self::assertEquals('test.test', $table->getName());
+ self::assertEquals('`test`.`test`', $table->getQuotedName(new MySqlPlatform()));
}
/**
@@ -638,13 +642,13 @@ public function testQuoteSchemaPrefixed()
*/
public function testFullQualifiedTableName()
{
- $table = new Table("`test`.`test`");
- self::assertEquals('test.test', $table->getFullQualifiedName("test"));
- self::assertEquals('test.test', $table->getFullQualifiedName("other"));
+ $table = new Table('`test`.`test`');
+ self::assertEquals('test.test', $table->getFullQualifiedName('test'));
+ self::assertEquals('test.test', $table->getFullQualifiedName('other'));
- $table = new Table("test");
- self::assertEquals('test.test', $table->getFullQualifiedName("test"));
- self::assertEquals('other.test', $table->getFullQualifiedName("other"));
+ $table = new Table('test');
+ self::assertEquals('test.test', $table->getFullQualifiedName('test'));
+ self::assertEquals('other.test', $table->getFullQualifiedName('other'));
}
/**
@@ -652,9 +656,9 @@ public function testFullQualifiedTableName()
*/
public function testDropIndex()
{
- $table = new Table("test");
+ $table = new Table('test');
$table->addColumn('id', 'integer');
- $table->addIndex(array('id'), 'idx');
+ $table->addIndex(['id'], 'idx');
self::assertTrue($table->hasIndex('idx'));
@@ -667,9 +671,9 @@ public function testDropIndex()
*/
public function testDropPrimaryKey()
{
- $table = new Table("test");
+ $table = new Table('test');
$table->addColumn('id', 'integer');
- $table->setPrimaryKey(array('id'));
+ $table->setPrimaryKey(['id']);
self::assertTrue($table->hasPrimaryKey());
@@ -682,14 +686,14 @@ public function testDropPrimaryKey()
*/
public function testRenameIndex()
{
- $table = new Table("test");
+ $table = new Table('test');
$table->addColumn('id', 'integer');
$table->addColumn('foo', 'integer');
$table->addColumn('bar', 'integer');
$table->addColumn('baz', 'integer');
- $table->setPrimaryKey(array('id'), 'pk');
- $table->addIndex(array('foo'), 'idx', array('flag'));
- $table->addUniqueIndex(array('bar', 'baz'), 'uniq');
+ $table->setPrimaryKey(['id'], 'pk');
+ $table->addIndex(['foo'], 'idx', ['flag']);
+ $table->addUniqueIndex(['bar', 'baz'], 'uniq');
// Rename to custom name.
self::assertSame($table, $table->renameIndex('pk', 'pk_new'));
@@ -705,13 +709,13 @@ public function testRenameIndex()
self::assertFalse($table->hasIndex('idx'));
self::assertFalse($table->hasIndex('uniq'));
- self::assertEquals(new Index('pk_new', array('id'), true, true), $table->getPrimaryKey());
- self::assertEquals(new Index('pk_new', array('id'), true, true), $table->getIndex('pk_new'));
+ self::assertEquals(new Index('pk_new', ['id'], true, true), $table->getPrimaryKey());
+ self::assertEquals(new Index('pk_new', ['id'], true, true), $table->getIndex('pk_new'));
self::assertEquals(
- new Index('idx_new', array('foo'), false, false, array('flag')),
+ new Index('idx_new', ['foo'], false, false, ['flag']),
$table->getIndex('idx_new')
);
- self::assertEquals(new Index('uniq_new', array('bar', 'baz'), true), $table->getIndex('uniq_new'));
+ self::assertEquals(new Index('uniq_new', ['bar', 'baz'], true), $table->getIndex('uniq_new'));
// Rename to auto-generated name.
self::assertSame($table, $table->renameIndex('pk_new', null));
@@ -727,14 +731,14 @@ public function testRenameIndex()
self::assertFalse($table->hasIndex('idx_new'));
self::assertFalse($table->hasIndex('uniq_new'));
- self::assertEquals(new Index('primary', array('id'), true, true), $table->getPrimaryKey());
- self::assertEquals(new Index('primary', array('id'), true, true), $table->getIndex('primary'));
+ self::assertEquals(new Index('primary', ['id'], true, true), $table->getPrimaryKey());
+ self::assertEquals(new Index('primary', ['id'], true, true), $table->getIndex('primary'));
self::assertEquals(
- new Index('IDX_D87F7E0C8C736521', array('foo'), false, false, array('flag')),
+ new Index('IDX_D87F7E0C8C736521', ['foo'], false, false, ['flag']),
$table->getIndex('IDX_D87F7E0C8C736521')
);
self::assertEquals(
- new Index('UNIQ_D87F7E0C76FF8CAA78240498', array('bar', 'baz'), true),
+ new Index('UNIQ_D87F7E0C76FF8CAA78240498', ['bar', 'baz'], true),
$table->getIndex('UNIQ_D87F7E0C76FF8CAA78240498')
);
@@ -756,11 +760,11 @@ public function testKeepsIndexOptionsOnRenamingRegularIndex()
{
$table = new Table('foo');
$table->addColumn('id', 'integer');
- $table->addIndex(array('id'), 'idx_bar', array(), array('where' => '1 = 1'));
+ $table->addIndex(['id'], 'idx_bar', [], ['where' => '1 = 1']);
$table->renameIndex('idx_bar', 'idx_baz');
- self::assertSame(array('where' => '1 = 1'), $table->getIndex('idx_baz')->getOptions());
+ self::assertSame(['where' => '1 = 1'], $table->getIndex('idx_baz')->getOptions());
}
/**
@@ -770,11 +774,11 @@ public function testKeepsIndexOptionsOnRenamingUniqueIndex()
{
$table = new Table('foo');
$table->addColumn('id', 'integer');
- $table->addUniqueIndex(array('id'), 'idx_bar', array('where' => '1 = 1'));
+ $table->addUniqueIndex(['id'], 'idx_bar', ['where' => '1 = 1']);
$table->renameIndex('idx_bar', 'idx_baz');
- self::assertSame(array('where' => '1 = 1'), $table->getIndex('idx_baz')->getOptions());
+ self::assertSame(['where' => '1 = 1'], $table->getIndex('idx_baz')->getOptions());
}
/**
@@ -783,9 +787,9 @@ public function testKeepsIndexOptionsOnRenamingUniqueIndex()
*/
public function testThrowsExceptionOnRenamingNonExistingIndex()
{
- $table = new Table("test");
+ $table = new Table('test');
$table->addColumn('id', 'integer');
- $table->addIndex(array('id'), 'idx');
+ $table->addIndex(['id'], 'idx');
$table->renameIndex('foo', 'bar');
}
@@ -796,11 +800,11 @@ public function testThrowsExceptionOnRenamingNonExistingIndex()
*/
public function testThrowsExceptionOnRenamingToAlreadyExistingIndex()
{
- $table = new Table("test");
+ $table = new Table('test');
$table->addColumn('id', 'integer');
$table->addColumn('foo', 'integer');
- $table->addIndex(array('id'), 'idx_id');
- $table->addIndex(array('foo'), 'idx_foo');
+ $table->addIndex(['id'], 'idx_id');
+ $table->addIndex(['foo'], 'idx_foo');
$table->renameIndex('idx_id', 'idx_foo');
}
@@ -814,23 +818,23 @@ public function testNormalizesColumnNames($assetName)
$table = new Table('test');
$table->addColumn($assetName, 'integer');
- $table->addIndex(array($assetName), $assetName);
- $table->addForeignKeyConstraint('test', array($assetName), array($assetName), array(), $assetName);
+ $table->addIndex([$assetName], $assetName);
+ $table->addForeignKeyConstraint('test', [$assetName], [$assetName], [], $assetName);
self::assertTrue($table->hasColumn($assetName));
self::assertTrue($table->hasColumn('foo'));
- self::assertInstanceOf('Doctrine\DBAL\Schema\Column', $table->getColumn($assetName));
- self::assertInstanceOf('Doctrine\DBAL\Schema\Column', $table->getColumn('foo'));
+ self::assertInstanceOf(Column::class, $table->getColumn($assetName));
+ self::assertInstanceOf(Column::class, $table->getColumn('foo'));
self::assertTrue($table->hasIndex($assetName));
self::assertTrue($table->hasIndex('foo'));
- self::assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getIndex($assetName));
- self::assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getIndex('foo'));
+ self::assertInstanceOf(Index::class, $table->getIndex($assetName));
+ self::assertInstanceOf(Index::class, $table->getIndex('foo'));
self::assertTrue($table->hasForeignKey($assetName));
self::assertTrue($table->hasForeignKey('foo'));
- self::assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $table->getForeignKey($assetName));
- self::assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $table->getForeignKey('foo'));
+ self::assertInstanceOf(ForeignKeyConstraint::class, $table->getForeignKey($assetName));
+ self::assertInstanceOf(ForeignKeyConstraint::class, $table->getForeignKey('foo'));
$table->renameIndex($assetName, $assetName);
self::assertTrue($table->hasIndex($assetName));
@@ -865,15 +869,15 @@ public function testNormalizesColumnNames($assetName)
public function getNormalizesAssetNames()
{
- return array(
- array('foo'),
- array('FOO'),
- array('`foo`'),
- array('`FOO`'),
- array('"foo"'),
- array('"FOO"'),
- array('"foo"'),
- array('"FOO"'),
- );
+ return [
+ ['foo'],
+ ['FOO'],
+ ['`foo`'],
+ ['`FOO`'],
+ ['"foo"'],
+ ['"FOO"'],
+ ['"foo"'],
+ ['"FOO"'],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php
index bc76b62010a..e64b4c523f3 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php
@@ -2,18 +2,20 @@
namespace Doctrine\Tests\DBAL\Schema\Visitor;
-use \Doctrine\DBAL\Schema\Visitor\CreateSchemaSqlCollector;
-
-class CreateSchemaSqlCollectorTest extends \PHPUnit\Framework\TestCase
+use Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Schema\ForeignKeyConstraint;
+use Doctrine\DBAL\Schema\Sequence;
+use Doctrine\DBAL\Schema\Table;
+use Doctrine\DBAL\Schema\Visitor\CreateSchemaSqlCollector;
+use PHPUnit\Framework\TestCase;
+use PHPUnit_Framework_MockObject_MockObject;
+
+class CreateSchemaSqlCollectorTest extends TestCase
{
- /**
- * @var \Doctrine\DBAL\Platforms\AbstractPlatform|\PHPUnit_Framework_MockObject_MockObject
- */
+ /** @var AbstractPlatform|PHPUnit_Framework_MockObject_MockObject */
private $platformMock;
- /**
- * @var \Doctrine\DBAL\Schema\Visitor\CreateSchemaSqlCollector
- */
+ /** @var CreateSchemaSqlCollector */
private $visitor;
/**
@@ -23,21 +25,21 @@ protected function setUp()
{
parent::setUp();
- $this->platformMock = $this->getMockBuilder('Doctrine\DBAL\Platforms\AbstractPlatform')
+ $this->platformMock = $this->getMockBuilder(AbstractPlatform::class)
->setMethods(
- array(
+ [
'getCreateForeignKeySQL',
'getCreateSchemaSQL',
'getCreateSequenceSQL',
'getCreateTableSQL',
'supportsForeignKeyConstraints',
- 'supportsSchemas'
- )
+ 'supportsSchemas',
+ ]
)
->getMockForAbstractClass();
- $this->visitor = new CreateSchemaSqlCollector($this->platformMock);
+ $this->visitor = new CreateSchemaSqlCollector($this->platformMock);
- foreach (array('getCreateSchemaSQL', 'getCreateTableSQL', 'getCreateForeignKeySQL', 'getCreateSequenceSQL') as $method) {
+ foreach (['getCreateSchemaSQL', 'getCreateTableSQL', 'getCreateForeignKeySQL', 'getCreateSequenceSQL'] as $method) {
$this->platformMock->expects($this->any())
->method($method)
->will($this->returnValue('foo'));
@@ -60,7 +62,7 @@ public function testAcceptsNamespace()
$this->visitor->acceptNamespace('foo');
- self::assertSame(array('foo'), $this->visitor->getQueries());
+ self::assertSame(['foo'], $this->visitor->getQueries());
}
public function testAcceptsTable()
@@ -69,7 +71,7 @@ public function testAcceptsTable()
$this->visitor->acceptTable($table);
- self::assertSame(array('foo'), $this->visitor->getQueries());
+ self::assertSame(['foo'], $this->visitor->getQueries());
}
public function testAcceptsForeignKey()
@@ -82,7 +84,7 @@ public function testAcceptsForeignKey()
->method('supportsForeignKeyConstraints')
->will($this->returnValue(true));
- $table = $this->createTableMock();
+ $table = $this->createTableMock();
$foreignKey = $this->createForeignKeyConstraintMock();
$this->visitor->acceptForeignKey($table, $foreignKey);
@@ -91,7 +93,7 @@ public function testAcceptsForeignKey()
$this->visitor->acceptForeignKey($table, $foreignKey);
- self::assertSame(array('foo'), $this->visitor->getQueries());
+ self::assertSame(['foo'], $this->visitor->getQueries());
}
public function testAcceptsSequences()
@@ -100,20 +102,20 @@ public function testAcceptsSequences()
$this->visitor->acceptSequence($sequence);
- self::assertSame(array('foo'), $this->visitor->getQueries());
+ self::assertSame(['foo'], $this->visitor->getQueries());
}
public function testResetsQueries()
{
- foreach (array('supportsSchemas', 'supportsForeignKeyConstraints') as $method) {
+ foreach (['supportsSchemas', 'supportsForeignKeyConstraints'] as $method) {
$this->platformMock->expects($this->any())
->method($method)
->will($this->returnValue(true));
}
- $table = $this->createTableMock();
+ $table = $this->createTableMock();
$foreignKey = $this->createForeignKeyConstraintMock();
- $sequence = $this->createSequenceMock();
+ $sequence = $this->createSequenceMock();
$this->visitor->acceptNamespace('foo');
$this->visitor->acceptTable($table);
@@ -128,31 +130,31 @@ public function testResetsQueries()
}
/**
- * @return \Doctrine\DBAL\Schema\ForeignKeyConstraint|\PHPUnit_Framework_MockObject_MockObject
+ * @return ForeignKeyConstraint|PHPUnit_Framework_MockObject_MockObject
*/
private function createForeignKeyConstraintMock()
{
- return $this->getMockBuilder('Doctrine\DBAL\Schema\ForeignKeyConstraint')
+ return $this->getMockBuilder(ForeignKeyConstraint::class)
->disableOriginalConstructor()
->getMock();
}
/**
- * @return \Doctrine\DBAL\Schema\Sequence|\PHPUnit_Framework_MockObject_MockObject
+ * @return Sequence|PHPUnit_Framework_MockObject_MockObject
*/
private function createSequenceMock()
{
- return $this->getMockBuilder('Doctrine\DBAL\Schema\Sequence')
+ return $this->getMockBuilder(Sequence::class)
->disableOriginalConstructor()
->getMock();
}
/**
- * @return \Doctrine\DBAL\Schema\Table|\PHPUnit_Framework_MockObject_MockObject
+ * @return Table|PHPUnit_Framework_MockObject_MockObject
*/
private function createTableMock()
{
- return $this->getMockBuilder('Doctrine\DBAL\Schema\Table')
+ return $this->getMockBuilder(Table::class)
->disableOriginalConstructor()
->getMock();
}
diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php
index 20e20127f04..b2aff283871 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php
@@ -2,12 +2,17 @@
namespace Doctrine\Tests\DBAL\Schema\Visitor;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Schema\ForeignKeyConstraint;
+use Doctrine\DBAL\Schema\SchemaException;
+use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector;
+use PHPUnit\Framework\TestCase;
/**
* @covers Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector
*/
-class DropSchemaSqlCollectorTest extends \PHPUnit\Framework\TestCase
+class DropSchemaSqlCollectorTest extends TestCase
{
public function testGetQueriesUsesAcceptedForeignKeys()
{
@@ -17,8 +22,8 @@ public function testGetQueriesUsesAcceptedForeignKeys()
$keyConstraintOne = $this->getStubKeyConstraint('first');
$keyConstraintTwo = $this->getStubKeyConstraint('second');
- $platform = $this->getMockBuilder('Doctrine\DBAL\Platforms\AbstractPlatform')
- ->setMethods(array('getDropForeignKeySQL'))
+ $platform = $this->getMockBuilder(AbstractPlatform::class)
+ ->setMethods(['getDropForeignKeySQL'])
->getMockForAbstractClass();
$collector = new DropSchemaSqlCollector($platform);
@@ -42,7 +47,7 @@ public function testGetQueriesUsesAcceptedForeignKeys()
private function getTableMock()
{
- return $this->getMockWithoutArguments('Doctrine\DBAL\Schema\Table');
+ return $this->getMockWithoutArguments(Table::class);
}
private function getMockWithoutArguments($className)
@@ -52,7 +57,7 @@ private function getMockWithoutArguments($className)
private function getStubKeyConstraint($name)
{
- $constraint = $this->getMockWithoutArguments('Doctrine\DBAL\Schema\ForeignKeyConstraint');
+ $constraint = $this->getMockWithoutArguments(ForeignKeyConstraint::class);
$constraint->expects($this->any())
->method('getName')
@@ -60,22 +65,22 @@ private function getStubKeyConstraint($name)
$constraint->expects($this->any())
->method('getForeignColumns')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$constraint->expects($this->any())
->method('getColumns')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
return $constraint;
}
- public function testGivenForeignKeyWithZeroLength_acceptForeignKeyThrowsException()
+ public function testGivenForeignKeyWithZeroLengthAcceptForeignKeyThrowsException()
{
$collector = new DropSchemaSqlCollector(
- $this->getMockForAbstractClass('Doctrine\DBAL\Platforms\AbstractPlatform')
+ $this->getMockForAbstractClass(AbstractPlatform::class)
);
- $this->expectException( 'Doctrine\DBAL\Schema\SchemaException' );
+ $this->expectException(SchemaException::class);
$collector->acceptForeignKey($this->getTableMock(), $this->getStubKeyConstraint(''));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php
index 356295d56b9..c3e52b0ffaf 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php
@@ -6,27 +6,28 @@
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaConfig;
use Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets;
+use PHPUnit\Framework\TestCase;
use function array_keys;
-class RemoveNamespacedAssetsTest extends \PHPUnit\Framework\TestCase
+class RemoveNamespacedAssetsTest extends TestCase
{
/**
* @group DBAL-204
*/
public function testRemoveNamespacedAssets()
{
- $config = new SchemaConfig;
- $config->setName("test");
- $schema = new Schema(array(), array(), $config);
+ $config = new SchemaConfig();
+ $config->setName('test');
+ $schema = new Schema([], [], $config);
- $schema->createTable("test.test");
- $schema->createTable("foo.bar");
- $schema->createTable("baz");
+ $schema->createTable('test.test');
+ $schema->createTable('foo.bar');
+ $schema->createTable('baz');
$schema->visit(new RemoveNamespacedAssets());
$tables = $schema->getTables();
- self::assertEquals(array("test.test", "test.baz"), array_keys($tables), "Only 2 tables should be present, both in 'test' namespace.");
+ self::assertEquals(['test.test', 'test.baz'], array_keys($tables), "Only 2 tables should be present, both in 'test' namespace.");
}
/**
@@ -34,22 +35,22 @@ public function testRemoveNamespacedAssets()
*/
public function testCleanupForeignKeys()
{
- $config = new SchemaConfig;
- $config->setName("test");
- $schema = new Schema(array(), array(), $config);
+ $config = new SchemaConfig();
+ $config->setName('test');
+ $schema = new Schema([], [], $config);
- $fooTable = $schema->createTable("foo.bar");
+ $fooTable = $schema->createTable('foo.bar');
$fooTable->addColumn('id', 'integer');
- $testTable = $schema->createTable("test.test");
+ $testTable = $schema->createTable('test.test');
$testTable->addColumn('id', 'integer');
- $testTable->addForeignKeyConstraint("foo.bar", array("id"), array("id"));
+ $testTable->addForeignKeyConstraint('foo.bar', ['id'], ['id']);
$schema->visit(new RemoveNamespacedAssets());
$sql = $schema->toSql(new MySqlPlatform());
- self::assertCount(1, $sql, "Just one CREATE TABLE statement, no foreign key and table to foo.bar");
+ self::assertCount(1, $sql, 'Just one CREATE TABLE statement, no foreign key and table to foo.bar');
}
/**
@@ -57,21 +58,21 @@ public function testCleanupForeignKeys()
*/
public function testCleanupForeignKeysDifferentOrder()
{
- $config = new SchemaConfig;
- $config->setName("test");
- $schema = new Schema(array(), array(), $config);
+ $config = new SchemaConfig();
+ $config->setName('test');
+ $schema = new Schema([], [], $config);
- $testTable = $schema->createTable("test.test");
+ $testTable = $schema->createTable('test.test');
$testTable->addColumn('id', 'integer');
- $fooTable = $schema->createTable("foo.bar");
+ $fooTable = $schema->createTable('foo.bar');
$fooTable->addColumn('id', 'integer');
- $testTable->addForeignKeyConstraint("foo.bar", array("id"), array("id"));
+ $testTable->addForeignKeyConstraint('foo.bar', ['id'], ['id']);
$schema->visit(new RemoveNamespacedAssets());
$sql = $schema->toSql(new MySqlPlatform());
- self::assertCount(1, $sql, "Just one CREATE TABLE statement, no foreign key and table to foo.bar");
+ self::assertCount(1, $sql, 'Just one CREATE TABLE statement, no foreign key and table to foo.bar');
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php
index 96a441210e1..4ebfd1cac54 100644
--- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php
+++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php
@@ -2,52 +2,54 @@
namespace Doctrine\Tests\DBAL\Schema\Visitor;
+use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\Schema;
+use PHPUnit\Framework\TestCase;
-class SchemaSqlCollectorTest extends \PHPUnit\Framework\TestCase
+class SchemaSqlCollectorTest extends TestCase
{
public function testCreateSchema()
{
- $platformMock = $this->getMockBuilder('Doctrine\DBAL\Platforms\MySqlPlatform')
- ->setMethods(array('getCreateTableSql', 'getCreateSequenceSql', 'getCreateForeignKeySql'))
+ $platformMock = $this->getMockBuilder(MySqlPlatform::class)
+ ->setMethods(['getCreateTableSql', 'getCreateSequenceSql', 'getCreateForeignKeySql'])
->getMock();
$platformMock->expects($this->exactly(2))
->method('getCreateTableSql')
- ->will($this->returnValue(array("foo")));
+ ->will($this->returnValue(['foo']));
$platformMock->expects($this->exactly(1))
->method('getCreateSequenceSql')
- ->will($this->returnValue("bar"));
+ ->will($this->returnValue('bar'));
$platformMock->expects($this->exactly(1))
->method('getCreateForeignKeySql')
- ->will($this->returnValue("baz"));
+ ->will($this->returnValue('baz'));
$schema = $this->createFixtureSchema();
$sql = $schema->toSql($platformMock);
- self::assertEquals(array("foo", "foo", "bar", "baz"), $sql);
+ self::assertEquals(['foo', 'foo', 'bar', 'baz'], $sql);
}
public function testDropSchema()
{
- $platformMock = $this->getMockBuilder('Doctrine\DBAL\Platforms\MySqlPlatform')
- ->setMethods(array('getDropTableSql', 'getDropSequenceSql', 'getDropForeignKeySql'))
+ $platformMock = $this->getMockBuilder(MySqlPlatform::class)
+ ->setMethods(['getDropTableSql', 'getDropSequenceSql', 'getDropForeignKeySql'])
->getMock();
$platformMock->expects($this->exactly(2))
->method('getDropTableSql')
- ->will($this->returnValue("tbl"));
+ ->will($this->returnValue('tbl'));
$platformMock->expects($this->exactly(1))
->method('getDropSequenceSql')
- ->will($this->returnValue("seq"));
+ ->will($this->returnValue('seq'));
$platformMock->expects($this->exactly(1))
->method('getDropForeignKeySql')
- ->will($this->returnValue("fk"));
+ ->will($this->returnValue('fk'));
$schema = $this->createFixtureSchema();
$sql = $schema->toDropSql($platformMock);
- self::assertEquals(array("fk", "seq", "tbl", "tbl"), $sql);
+ self::assertEquals(['fk', 'seq', 'tbl', 'tbl'], $sql);
}
/**
@@ -56,18 +58,18 @@ public function testDropSchema()
public function createFixtureSchema()
{
$schema = new Schema();
- $tableA = $schema->createTable("foo");
- $tableA->addColumn("id", 'integer');
- $tableA->addColumn("bar", 'string', array('length' => 255));
- $tableA->setPrimaryKey(array("id"));
+ $tableA = $schema->createTable('foo');
+ $tableA->addColumn('id', 'integer');
+ $tableA->addColumn('bar', 'string', ['length' => 255]);
+ $tableA->setPrimaryKey(['id']);
- $schema->createSequence("foo_seq");
+ $schema->createSequence('foo_seq');
- $tableB = $schema->createTable("bar");
- $tableB->addColumn("id", 'integer');
- $tableB->setPrimaryKey(array("id"));
+ $tableB = $schema->createTable('bar');
+ $tableB->addColumn('id', 'integer');
+ $tableB->setPrimaryKey(['id']);
- $tableA->addForeignKeyConstraint($tableB, array("bar"), array("id"));
+ $tableA->addForeignKeyConstraint($tableB, ['bar'], ['id']);
return $schema;
}
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php
index 9c96cbfc975..4985605c60d 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php
@@ -1,44 +1,31 @@
.
- */
namespace Doctrine\Tests\DBAL\Sharding;
use Doctrine\DBAL\DriverManager;
+use Doctrine\DBAL\Sharding\PoolingShardConnection;
use Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser;
+use Doctrine\DBAL\Sharding\ShardingException;
+use PHPUnit\Framework\TestCase;
+use stdClass;
/**
* @requires extension pdo_sqlite
*/
-class PoolingShardConnectionTest extends \PHPUnit\Framework\TestCase
+class PoolingShardConnectionTest extends TestCase
{
public function testConnect()
{
- $conn = DriverManager::getConnection(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ $conn = DriverManager::getConnection([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
- 'global' => array('memory' => true),
- 'shards' => array(
- array('id' => 1, 'memory' => true),
- array('id' => 2, 'memory' => true),
- ),
- 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser',
- ));
+ 'global' => ['memory' => true],
+ 'shards' => [
+ ['id' => 1, 'memory' => true],
+ ['id' => 2, 'memory' => true],
+ ],
+ 'shardChoser' => MultiTenantShardChoser::class,
+ ]);
self::assertFalse($conn->isConnected(0));
$conn->connect(0);
@@ -66,15 +53,15 @@ public function testNoGlobalServerException()
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage("Connection Parameters require 'global' and 'shards' configurations.");
- DriverManager::getConnection(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ DriverManager::getConnection([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
- 'shards' => array(
- array('id' => 1, 'memory' => true),
- array('id' => 2, 'memory' => true),
- ),
- 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser',
- ));
+ 'shards' => [
+ ['id' => 1, 'memory' => true],
+ ['id' => 2, 'memory' => true],
+ ],
+ 'shardChoser' => MultiTenantShardChoser::class,
+ ]);
}
public function testNoShardsServersException()
@@ -82,12 +69,12 @@ public function testNoShardsServersException()
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage("Connection Parameters require 'global' and 'shards' configurations.");
- DriverManager::getConnection(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ DriverManager::getConnection([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
- 'global' => array('memory' => true),
- 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser',
- ));
+ 'global' => ['memory' => true],
+ 'shardChoser' => MultiTenantShardChoser::class,
+ ]);
}
public function testNoShardsChoserException()
@@ -95,15 +82,15 @@ public function testNoShardsChoserException()
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage("Missing Shard Choser configuration 'shardChoser'");
- DriverManager::getConnection(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ DriverManager::getConnection([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
- 'global' => array('memory' => true),
- 'shards' => array(
- array('id' => 1, 'memory' => true),
- array('id' => 2, 'memory' => true),
- ),
- ));
+ 'global' => ['memory' => true],
+ 'shards' => [
+ ['id' => 1, 'memory' => true],
+ ['id' => 2, 'memory' => true],
+ ],
+ ]);
}
public function testShardChoserWrongInstance()
@@ -111,16 +98,16 @@ public function testShardChoserWrongInstance()
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage("The 'shardChoser' configuration is not a valid instance of Doctrine\DBAL\Sharding\ShardChoser\ShardChoser");
- DriverManager::getConnection(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ DriverManager::getConnection([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
- 'global' => array('memory' => true),
- 'shards' => array(
- array('id' => 1, 'memory' => true),
- array('id' => 2, 'memory' => true),
- ),
- 'shardChoser' => new \stdClass,
- ));
+ 'global' => ['memory' => true],
+ 'shards' => [
+ ['id' => 1, 'memory' => true],
+ ['id' => 2, 'memory' => true],
+ ],
+ 'shardChoser' => new stdClass(),
+ ]);
}
public function testShardNonNumericId()
@@ -128,15 +115,15 @@ public function testShardNonNumericId()
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Shard Id has to be a non-negative number.');
- DriverManager::getConnection(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ DriverManager::getConnection([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
- 'global' => array('memory' => true),
- 'shards' => array(
- array('id' => 'foo', 'memory' => true),
- ),
- 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser',
- ));
+ 'global' => ['memory' => true],
+ 'shards' => [
+ ['id' => 'foo', 'memory' => true],
+ ],
+ 'shardChoser' => MultiTenantShardChoser::class,
+ ]);
}
public function testShardMissingId()
@@ -144,15 +131,15 @@ public function testShardMissingId()
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage("Missing 'id' for one configured shard. Please specify a unique shard-id.");
- DriverManager::getConnection(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ DriverManager::getConnection([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
- 'global' => array('memory' => true),
- 'shards' => array(
- array('memory' => true),
- ),
- 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser',
- ));
+ 'global' => ['memory' => true],
+ 'shards' => [
+ ['memory' => true],
+ ],
+ 'shardChoser' => MultiTenantShardChoser::class,
+ ]);
}
public function testDuplicateShardId()
@@ -160,48 +147,48 @@ public function testDuplicateShardId()
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Shard 1 is duplicated in the configuration.');
- DriverManager::getConnection(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ DriverManager::getConnection([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
- 'global' => array('memory' => true),
- 'shards' => array(
- array('id' => 1, 'memory' => true),
- array('id' => 1, 'memory' => true),
- ),
- 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser',
- ));
+ 'global' => ['memory' => true],
+ 'shards' => [
+ ['id' => 1, 'memory' => true],
+ ['id' => 1, 'memory' => true],
+ ],
+ 'shardChoser' => MultiTenantShardChoser::class,
+ ]);
}
public function testSwitchShardWithOpenTransactionException()
{
- $conn = DriverManager::getConnection(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ $conn = DriverManager::getConnection([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
- 'global' => array('memory' => true),
- 'shards' => array(
- array('id' => 1, 'memory' => true),
- ),
- 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser',
- ));
+ 'global' => ['memory' => true],
+ 'shards' => [
+ ['id' => 1, 'memory' => true],
+ ],
+ 'shardChoser' => MultiTenantShardChoser::class,
+ ]);
$conn->beginTransaction();
- $this->expectException('Doctrine\DBAL\Sharding\ShardingException');
+ $this->expectException(ShardingException::class);
$this->expectExceptionMessage('Cannot switch shard when transaction is active.');
$conn->connect(1);
}
public function testGetActiveShardId()
{
- $conn = DriverManager::getConnection(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ $conn = DriverManager::getConnection([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
- 'global' => array('memory' => true),
- 'shards' => array(
- array('id' => 1, 'memory' => true),
- ),
- 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser',
- ));
+ 'global' => ['memory' => true],
+ 'shards' => [
+ ['id' => 1, 'memory' => true],
+ ],
+ 'shardChoser' => MultiTenantShardChoser::class,
+ ]);
self::assertNull($conn->getActiveShardId());
@@ -217,55 +204,55 @@ public function testGetActiveShardId()
public function testGetParamsOverride()
{
- $conn = DriverManager::getConnection(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ $conn = DriverManager::getConnection([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
- 'global' => array('memory' => true, 'host' => 'localhost'),
- 'shards' => array(
- array('id' => 1, 'memory' => true, 'host' => 'foo'),
- ),
- 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser',
- ));
-
- self::assertEquals(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ 'global' => ['memory' => true, 'host' => 'localhost'],
+ 'shards' => [
+ ['id' => 1, 'memory' => true, 'host' => 'foo'],
+ ],
+ 'shardChoser' => MultiTenantShardChoser::class,
+ ]);
+
+ self::assertEquals([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
- 'global' => array('memory' => true, 'host' => 'localhost'),
- 'shards' => array(
- array('id' => 1, 'memory' => true, 'host' => 'foo'),
- ),
+ 'global' => ['memory' => true, 'host' => 'localhost'],
+ 'shards' => [
+ ['id' => 1, 'memory' => true, 'host' => 'foo'],
+ ],
'shardChoser' => new MultiTenantShardChoser(),
'memory' => true,
'host' => 'localhost',
- ), $conn->getParams());
+ ], $conn->getParams());
$conn->connect(1);
- self::assertEquals(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ self::assertEquals([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
- 'global' => array('memory' => true, 'host' => 'localhost'),
- 'shards' => array(
- array('id' => 1, 'memory' => true, 'host' => 'foo'),
- ),
+ 'global' => ['memory' => true, 'host' => 'localhost'],
+ 'shards' => [
+ ['id' => 1, 'memory' => true, 'host' => 'foo'],
+ ],
'shardChoser' => new MultiTenantShardChoser(),
'id' => 1,
'memory' => true,
'host' => 'foo',
- ), $conn->getParams());
+ ], $conn->getParams());
}
public function testGetHostOverride()
{
- $conn = DriverManager::getConnection(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ $conn = DriverManager::getConnection([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
'host' => 'localhost',
- 'global' => array('memory' => true),
- 'shards' => array(
- array('id' => 1, 'memory' => true, 'host' => 'foo'),
- ),
- 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser',
- ));
+ 'global' => ['memory' => true],
+ 'shards' => [
+ ['id' => 1, 'memory' => true, 'host' => 'foo'],
+ ],
+ 'shardChoser' => MultiTenantShardChoser::class,
+ ]);
self::assertEquals('localhost', $conn->getHost());
@@ -275,16 +262,16 @@ public function testGetHostOverride()
public function testGetPortOverride()
{
- $conn = DriverManager::getConnection(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ $conn = DriverManager::getConnection([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
'port' => 3306,
- 'global' => array('memory' => true),
- 'shards' => array(
- array('id' => 1, 'memory' => true, 'port' => 3307),
- ),
- 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser',
- ));
+ 'global' => ['memory' => true],
+ 'shards' => [
+ ['id' => 1, 'memory' => true, 'port' => 3307],
+ ],
+ 'shardChoser' => MultiTenantShardChoser::class,
+ ]);
self::assertEquals(3306, $conn->getPort());
@@ -294,16 +281,16 @@ public function testGetPortOverride()
public function testGetUsernameOverride()
{
- $conn = DriverManager::getConnection(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ $conn = DriverManager::getConnection([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
'user' => 'foo',
- 'global' => array('memory' => true),
- 'shards' => array(
- array('id' => 1, 'memory' => true, 'user' => 'bar'),
- ),
- 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser',
- ));
+ 'global' => ['memory' => true],
+ 'shards' => [
+ ['id' => 1, 'memory' => true, 'user' => 'bar'],
+ ],
+ 'shardChoser' => MultiTenantShardChoser::class,
+ ]);
self::assertEquals('foo', $conn->getUsername());
@@ -313,16 +300,16 @@ public function testGetUsernameOverride()
public function testGetPasswordOverride()
{
- $conn = DriverManager::getConnection(array(
- 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection',
+ $conn = DriverManager::getConnection([
+ 'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
'password' => 'foo',
- 'global' => array('memory' => true),
- 'shards' => array(
- array('id' => 1, 'memory' => true, 'password' => 'bar'),
- ),
- 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser',
- ));
+ 'global' => ['memory' => true],
+ 'shards' => [
+ ['id' => 1, 'memory' => true, 'password' => 'bar'],
+ ],
+ 'shardChoser' => MultiTenantShardChoser::class,
+ ]);
self::assertEquals('foo', $conn->getPassword());
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php
index dccb1b1c53d..fc1b1ddb0c7 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php
@@ -18,33 +18,38 @@
*/
namespace Doctrine\Tests\DBAL\Sharding;
+use Doctrine\DBAL\Sharding\PoolingShardConnection;
use Doctrine\DBAL\Sharding\PoolingShardManager;
+use Doctrine\DBAL\Sharding\ShardChoser\ShardChoser;
+use PHPUnit\Framework\TestCase;
-class PoolingShardManagerTest extends \PHPUnit\Framework\TestCase
+class PoolingShardManagerTest extends TestCase
{
private function createConnectionMock()
{
- return $this->getMockBuilder('Doctrine\DBAL\Sharding\PoolingShardConnection')
- ->setMethods(array('connect', 'getParams', 'fetchAll'))
+ return $this->getMockBuilder(PoolingShardConnection::class)
+ ->setMethods(['connect', 'getParams', 'fetchAll'])
->disableOriginalConstructor()
->getMock();
}
private function createPassthroughShardChoser()
{
- $mock = $this->createMock('Doctrine\DBAL\Sharding\ShardChoser\ShardChoser');
+ $mock = $this->createMock(ShardChoser::class);
$mock->expects($this->any())
->method('pickShard')
- ->will($this->returnCallback(function($value) { return $value; }));
+ ->will($this->returnCallback(static function ($value) {
+ return $value;
+ }));
return $mock;
}
- private function createStaticShardChoser()
+ private function createStaticShardChooser()
{
- $mock = $this->createMock('Doctrine\DBAL\Sharding\ShardChoser\ShardChoser');
+ $mock = $this->createMock(ShardChoser::class);
$mock->expects($this->any())
->method('pickShard')
- ->will($this->returnCallback(function($value) { return 1; }));
+ ->willReturn(1);
return $mock;
}
@@ -62,8 +67,8 @@ public function testSelectGlobal()
public function testSelectShard()
{
$shardId = 10;
- $conn = $this->createConnectionMock();
- $conn->expects($this->at(0))->method('getParams')->will($this->returnValue(array('shardChoser' => $this->createPassthroughShardChoser())));
+ $conn = $this->createConnectionMock();
+ $conn->expects($this->at(0))->method('getParams')->will($this->returnValue(['shardChoser' => $this->createPassthroughShardChoser()]));
$conn->expects($this->at(1))->method('connect')->with($this->equalTo($shardId));
$shardManager = new PoolingShardManager($conn);
@@ -77,73 +82,73 @@ public function testGetShards()
$conn = $this->createConnectionMock();
$conn->expects($this->any())->method('getParams')->will(
$this->returnValue(
- array('shards' => array( array('id' => 1), array('id' => 2) ), 'shardChoser' => $this->createPassthroughShardChoser())
+ ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createPassthroughShardChoser()]
)
);
$shardManager = new PoolingShardManager($conn);
- $shards = $shardManager->getShards();
+ $shards = $shardManager->getShards();
- self::assertEquals(array(array('id' => 1), array('id' => 2)), $shards);
+ self::assertEquals([['id' => 1], ['id' => 2]], $shards);
}
public function testQueryAll()
{
- $sql = "SELECT * FROM table";
- $params = array(1);
- $types = array(1);
+ $sql = 'SELECT * FROM table';
+ $params = [1];
+ $types = [1];
$conn = $this->createConnectionMock();
$conn->expects($this->at(0))->method('getParams')->will($this->returnValue(
- array('shards' => array( array('id' => 1), array('id' => 2) ), 'shardChoser' => $this->createPassthroughShardChoser())
+ ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createPassthroughShardChoser()]
));
$conn->expects($this->at(1))->method('getParams')->will($this->returnValue(
- array('shards' => array( array('id' => 1), array('id' => 2) ), 'shardChoser' => $this->createPassthroughShardChoser())
+ ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createPassthroughShardChoser()]
));
$conn->expects($this->at(2))->method('connect')->with($this->equalTo(1));
$conn->expects($this->at(3))
->method('fetchAll')
->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types))
- ->will($this->returnValue(array( array('id' => 1) ) ));
+ ->will($this->returnValue([ ['id' => 1] ]));
$conn->expects($this->at(4))->method('connect')->with($this->equalTo(2));
$conn->expects($this->at(5))
->method('fetchAll')
->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types))
- ->will($this->returnValue(array( array('id' => 2) ) ));
+ ->will($this->returnValue([ ['id' => 2] ]));
$shardManager = new PoolingShardManager($conn);
- $result = $shardManager->queryAll($sql, $params, $types);
+ $result = $shardManager->queryAll($sql, $params, $types);
- self::assertEquals(array(array('id' => 1), array('id' => 2)), $result);
+ self::assertEquals([['id' => 1], ['id' => 2]], $result);
}
public function testQueryAllWithStaticShardChoser()
{
- $sql = "SELECT * FROM table";
- $params = array(1);
- $types = array(1);
+ $sql = 'SELECT * FROM table';
+ $params = [1];
+ $types = [1];
$conn = $this->createConnectionMock();
$conn->expects($this->at(0))->method('getParams')->will($this->returnValue(
- array('shards' => array( array('id' => 1), array('id' => 2) ), 'shardChoser' => $this->createStaticShardChoser())
+ ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createStaticShardChooser()]
));
$conn->expects($this->at(1))->method('getParams')->will($this->returnValue(
- array('shards' => array( array('id' => 1), array('id' => 2) ), 'shardChoser' => $this->createStaticShardChoser())
+ ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createStaticShardChooser()]
));
$conn->expects($this->at(2))->method('connect')->with($this->equalTo(1));
$conn->expects($this->at(3))
->method('fetchAll')
->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types))
- ->will($this->returnValue(array( array('id' => 1) ) ));
+ ->will($this->returnValue([ ['id' => 1] ]));
$conn->expects($this->at(4))->method('connect')->with($this->equalTo(2));
$conn->expects($this->at(5))
->method('fetchAll')
->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types))
- ->will($this->returnValue(array( array('id' => 2) ) ));
+ ->will($this->returnValue([ ['id' => 2] ]));
$shardManager = new PoolingShardManager($conn);
- $result = $shardManager->queryAll($sql, $params, $types);
+ $result = $shardManager->queryAll($sql, $params, $types);
- self::assertEquals(array(array('id' => 1), array('id' => 2)), $result);
+ self::assertEquals([['id' => 1], ['id' => 2]], $result);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php
index ced8f6615e6..2e67d0a023f 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php
@@ -2,48 +2,46 @@
namespace Doctrine\Tests\DBAL\Sharding\SQLAzure;
+use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Sharding\SQLAzure\SQLAzureShardManager;
+use PHPUnit\Framework\TestCase;
use function strpos;
-abstract class AbstractTestCase extends \PHPUnit\Framework\TestCase
+abstract class AbstractTestCase extends TestCase
{
- /**
- * @var \Doctrine\DBAL\Connection
- */
+ /** @var Connection */
protected $conn;
- /**
- * @var SQLAzureShardManager
- */
+ /** @var SQLAzureShardManager */
protected $sm;
protected function setUp()
{
- if (!isset($GLOBALS['db_type']) || strpos($GLOBALS['db_type'], "sqlsrv") === false) {
+ if (! isset($GLOBALS['db_type']) || strpos($GLOBALS['db_type'], 'sqlsrv') === false) {
$this->markTestSkipped('No driver or sqlserver driver specified.');
}
- $params = array(
+ $params = [
'driver' => $GLOBALS['db_type'],
'dbname' => $GLOBALS['db_name'],
'user' => $GLOBALS['db_username'],
'password' => $GLOBALS['db_password'],
'host' => $GLOBALS['db_host'],
- 'sharding' => array(
+ 'sharding' => [
'federationName' => 'Orders_Federation',
'distributionKey' => 'CustID',
'distributionType' => 'integer',
'filteringEnabled' => false,
- ),
- 'driverOptions' => array('MultipleActiveResultSets' => false)
- );
+ ],
+ 'driverOptions' => ['MultipleActiveResultSets' => false],
+ ];
$this->conn = DriverManager::getConnection($params);
$serverEdition = $this->conn->fetchColumn("SELECT CONVERT(NVARCHAR(128), SERVERPROPERTY('Edition'))");
- if (0 !== strpos($serverEdition, 'SQL Azure')) {
+ if (strpos($serverEdition, 'SQL Azure') !== 0) {
$this->markTestSkipped('SQL Azure only test.');
}
@@ -62,8 +60,8 @@ public function createShopSchema()
$products->addColumn('ProductID', 'integer');
$products->addColumn('SupplierID', 'integer');
$products->addColumn('ProductName', 'string');
- $products->addColumn('Price', 'decimal', array('scale' => 2, 'precision' => 12));
- $products->setPrimaryKey(array('ProductID'));
+ $products->addColumn('Price', 'decimal', ['scale' => 2, 'precision' => 12]);
+ $products->setPrimaryKey(['ProductID']);
$products->addOption('azure.federated', true);
$customers = $schema->createTable('Customers');
@@ -71,7 +69,7 @@ public function createShopSchema()
$customers->addColumn('CompanyName', 'string');
$customers->addColumn('FirstName', 'string');
$customers->addColumn('LastName', 'string');
- $customers->setPrimaryKey(array('CustomerID'));
+ $customers->setPrimaryKey(['CustomerID']);
$customers->addOption('azure.federated', true);
$customers->addOption('azure.federatedOnColumnName', 'CustomerID');
@@ -79,7 +77,7 @@ public function createShopSchema()
$orders->addColumn('CustomerID', 'integer');
$orders->addColumn('OrderID', 'integer');
$orders->addColumn('OrderDate', 'datetime');
- $orders->setPrimaryKey(array('CustomerID', 'OrderID'));
+ $orders->setPrimaryKey(['CustomerID', 'OrderID']);
$orders->addOption('azure.federated', true);
$orders->addOption('azure.federatedOnColumnName', 'CustomerID');
@@ -88,7 +86,7 @@ public function createShopSchema()
$orderItems->addColumn('OrderID', 'integer');
$orderItems->addColumn('ProductID', 'integer');
$orderItems->addColumn('Quantity', 'integer');
- $orderItems->setPrimaryKey(array('CustomerID', 'OrderID', 'ProductID'));
+ $orderItems->setPrimaryKey(['CustomerID', 'OrderID', 'ProductID']);
$orderItems->addOption('azure.federated', true);
$orderItems->addOption('azure.federatedOnColumnName', 'CustomerID');
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php
index b65c99a6ebe..8a99ea70879 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php
@@ -1,4 +1,5 @@
sm->selectShard(0);
- $this->conn->insert("Products", array(
- "ProductID" => 1,
- "SupplierID" => 2,
- "ProductName" => "Test",
- "Price" => 10.45
- ));
-
- $this->conn->insert("Customers", array(
- "CustomerID" => 1,
- "CompanyName" => "Foo",
- "FirstName" => "Benjamin",
- "LastName" => "E.",
- ));
-
- $query = "SELECT * FROM Products";
- $data = $this->conn->fetchAll($query);
+ $this->conn->insert('Products', [
+ 'ProductID' => 1,
+ 'SupplierID' => 2,
+ 'ProductName' => 'Test',
+ 'Price' => 10.45,
+ ]);
+
+ $this->conn->insert('Customers', [
+ 'CustomerID' => 1,
+ 'CompanyName' => 'Foo',
+ 'FirstName' => 'Benjamin',
+ 'LastName' => 'E.',
+ ]);
+
+ $query = 'SELECT * FROM Products';
+ $data = $this->conn->fetchAll($query);
self::assertGreaterThan(0, count($data));
- $query = "SELECT * FROM Customers";
- $data = $this->conn->fetchAll($query);
+ $query = 'SELECT * FROM Customers';
+ $data = $this->conn->fetchAll($query);
self::assertGreaterThan(0, count($data));
- $data = $this->sm->queryAll("SELECT * FROM Customers");
+ $data = $this->sm->queryAll('SELECT * FROM Customers');
self::assertGreaterThan(0, count($data));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php
index 99be4eff108..94634dadb69 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php
@@ -1,65 +1,48 @@
.
- */
namespace Doctrine\Tests\DBAL\Sharding\SQLAzure;
use Doctrine\DBAL\Platforms\SQLAzurePlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Sharding\SQLAzure\Schema\MultiTenantVisitor;
+use PHPUnit\Framework\TestCase;
-class MultiTenantVisitorTest extends \PHPUnit\Framework\TestCase
+class MultiTenantVisitorTest extends TestCase
{
public function testMultiTenantPrimaryKey()
{
$platform = new SQLAzurePlatform();
- $visitor = new MultiTenantVisitor();
+ $visitor = new MultiTenantVisitor();
$schema = new Schema();
- $foo = $schema->createTable('foo');
+ $foo = $schema->createTable('foo');
$foo->addColumn('id', 'string');
- $foo->setPrimaryKey(array('id'));
+ $foo->setPrimaryKey(['id']);
$schema->visit($visitor);
- self::assertEquals(array('id', 'tenant_id'), $foo->getPrimaryKey()->getColumns());
+ self::assertEquals(['id', 'tenant_id'], $foo->getPrimaryKey()->getColumns());
self::assertTrue($foo->hasColumn('tenant_id'));
}
public function testMultiTenantNonPrimaryKey()
{
$platform = new SQLAzurePlatform();
- $visitor = new MultiTenantVisitor();
+ $visitor = new MultiTenantVisitor();
$schema = new Schema();
- $foo = $schema->createTable('foo');
+ $foo = $schema->createTable('foo');
$foo->addColumn('id', 'string');
$foo->addColumn('created', 'datetime');
- $foo->setPrimaryKey(array('id'));
- $foo->addIndex(array('created'), 'idx');
+ $foo->setPrimaryKey(['id']);
+ $foo->addIndex(['created'], 'idx');
$foo->getPrimaryKey()->addFlag('nonclustered');
$foo->getIndex('idx')->addFlag('clustered');
$schema->visit($visitor);
- self::assertEquals(array('id'), $foo->getPrimaryKey()->getColumns());
+ self::assertEquals(['id'], $foo->getPrimaryKey()->getColumns());
self::assertTrue($foo->hasColumn('tenant_id'));
- self::assertEquals(array('created', 'tenant_id'), $foo->getIndex('idx')->getColumns());
+ self::assertEquals(['created', 'tenant_id'], $foo->getIndex('idx')->getColumns());
}
}
-
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizerTest.php
index 7561b12b3ec..20e479a3e00 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizerTest.php
@@ -1,4 +1,5 @@
createShopSchema();
$synchronizer = new SQLAzureFederationsSynchronizer($this->conn, $this->sm);
- $sql = $synchronizer->getCreateSchema($schema);
+ $sql = $synchronizer->getCreateSchema($schema);
- self::assertEquals(array (
+ self::assertEquals([
"--Create Federation\nCREATE FEDERATION Orders_Federation (CustID INT RANGE)",
- "USE FEDERATION Orders_Federation (CustID = 0) WITH RESET, FILTERING = OFF;",
- "CREATE TABLE Products (ProductID INT NOT NULL, SupplierID INT NOT NULL, ProductName NVARCHAR(255) NOT NULL, Price NUMERIC(12, 2) NOT NULL, PRIMARY KEY (ProductID))",
- "CREATE TABLE Customers (CustomerID INT NOT NULL, CompanyName NVARCHAR(255) NOT NULL, FirstName NVARCHAR(255) NOT NULL, LastName NVARCHAR(255) NOT NULL, PRIMARY KEY (CustomerID))",
- "CREATE TABLE Orders (CustomerID INT NOT NULL, OrderID INT NOT NULL, OrderDate DATETIME2(6) NOT NULL, PRIMARY KEY (CustomerID, OrderID))",
- "CREATE TABLE OrderItems (CustomerID INT NOT NULL, OrderID INT NOT NULL, ProductID INT NOT NULL, Quantity INT NOT NULL, PRIMARY KEY (CustomerID, OrderID, ProductID))",
- ), $sql);
+ 'USE FEDERATION Orders_Federation (CustID = 0) WITH RESET, FILTERING = OFF;',
+ 'CREATE TABLE Products (ProductID INT NOT NULL, SupplierID INT NOT NULL, ProductName NVARCHAR(255) NOT NULL, Price NUMERIC(12, 2) NOT NULL, PRIMARY KEY (ProductID))',
+ 'CREATE TABLE Customers (CustomerID INT NOT NULL, CompanyName NVARCHAR(255) NOT NULL, FirstName NVARCHAR(255) NOT NULL, LastName NVARCHAR(255) NOT NULL, PRIMARY KEY (CustomerID))',
+ 'CREATE TABLE Orders (CustomerID INT NOT NULL, OrderID INT NOT NULL, OrderDate DATETIME2(6) NOT NULL, PRIMARY KEY (CustomerID, OrderID))',
+ 'CREATE TABLE OrderItems (CustomerID INT NOT NULL, OrderID INT NOT NULL, ProductID INT NOT NULL, Quantity INT NOT NULL, PRIMARY KEY (CustomerID, OrderID, ProductID))',
+ ], $sql);
}
public function testUpdateSchema()
@@ -31,7 +32,7 @@ public function testUpdateSchema()
$sql = $synchronizer->getUpdateSchema($schema);
- self::assertEquals(array(), $sql);
+ self::assertEquals([], $sql);
}
public function testDropSchema()
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php
index 80d510f7d12..edc88d376c9 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php
@@ -2,39 +2,42 @@
namespace Doctrine\Tests\DBAL\Sharding\SQLAzure;
+use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Sharding\ShardingException;
use Doctrine\DBAL\Sharding\SQLAzure\SQLAzureShardManager;
+use PHPUnit\Framework\TestCase;
-class SQLAzureShardManagerTest extends \PHPUnit\Framework\TestCase
+class SQLAzureShardManagerTest extends TestCase
{
public function testNoFederationName()
{
- $this->expectException('Doctrine\DBAL\Sharding\ShardingException');
+ $this->expectException(ShardingException::class);
$this->expectExceptionMessage('SQLAzure requires a federation name to be set during sharding configuration.');
- $conn = $this->createConnection(array('sharding' => array('distributionKey' => 'abc', 'distributionType' => 'integer')));
- $sm = new SQLAzureShardManager($conn);
+ $conn = $this->createConnection(['sharding' => ['distributionKey' => 'abc', 'distributionType' => 'integer']]);
+ new SQLAzureShardManager($conn);
}
public function testNoDistributionKey()
{
- $this->expectException('Doctrine\DBAL\Sharding\ShardingException');
+ $this->expectException(ShardingException::class);
$this->expectExceptionMessage('SQLAzure requires a distribution key to be set during sharding configuration.');
- $conn = $this->createConnection(array('sharding' => array('federationName' => 'abc', 'distributionType' => 'integer')));
- $sm = new SQLAzureShardManager($conn);
+ $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionType' => 'integer']]);
+ new SQLAzureShardManager($conn);
}
public function testNoDistributionType()
{
- $this->expectException('Doctrine\DBAL\Sharding\ShardingException');
+ $this->expectException(ShardingException::class);
- $conn = $this->createConnection(array('sharding' => array('federationName' => 'abc', 'distributionKey' => 'foo')));
- $sm = new SQLAzureShardManager($conn);
+ $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionKey' => 'foo']]);
+ new SQLAzureShardManager($conn);
}
public function testGetDefaultDistributionValue()
{
- $conn = $this->createConnection(array('sharding' => array('federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer')));
+ $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer']]);
$sm = new SQLAzureShardManager($conn);
self::assertNull($sm->getCurrentDistributionValue());
@@ -42,10 +45,10 @@ public function testGetDefaultDistributionValue()
public function testSelectGlobalTransactionActive()
{
- $conn = $this->createConnection(array('sharding' => array('federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer')));
+ $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer']]);
$conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(true));
- $this->expectException('Doctrine\DBAL\Sharding\ShardingException');
+ $this->expectException(ShardingException::class);
$this->expectExceptionMessage('Cannot switch shard during an active transaction.');
$sm = new SQLAzureShardManager($conn);
@@ -54,7 +57,7 @@ public function testSelectGlobalTransactionActive()
public function testSelectGlobal()
{
- $conn = $this->createConnection(array('sharding' => array('federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer')));
+ $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer']]);
$conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(false));
$conn->expects($this->at(2))->method('exec')->with($this->equalTo('USE FEDERATION ROOT WITH RESET'));
@@ -64,10 +67,10 @@ public function testSelectGlobal()
public function testSelectShard()
{
- $conn = $this->createConnection(array('sharding' => array('federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer')));
+ $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer']]);
$conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(true));
- $this->expectException('Doctrine\DBAL\Sharding\ShardingException');
+ $this->expectException(ShardingException::class);
$this->expectExceptionMessage('Cannot switch shard during an active transaction.');
$sm = new SQLAzureShardManager($conn);
@@ -78,20 +81,23 @@ public function testSelectShard()
public function testSelectShardNoDistributionValue()
{
- $conn = $this->createConnection(array('sharding' => array('federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer')));
+ $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer']]);
$conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(false));
- $this->expectException('Doctrine\DBAL\Sharding\ShardingException');
+ $this->expectException(ShardingException::class);
$this->expectExceptionMessage('You have to specify a string or integer as shard distribution value.');
$sm = new SQLAzureShardManager($conn);
$sm->selectShard(null);
}
+ /**
+ * @param mixed[] $params
+ */
private function createConnection(array $params)
{
- $conn = $this->getMockBuilder('Doctrine\DBAL\Connection')
- ->setMethods(array('getParams', 'exec', 'isTransactionActive'))
+ $conn = $this->getMockBuilder(Connection::class)
+ ->setMethods(['getParams', 'exec', 'isTransactionActive'])
->disableOriginalConstructor()
->getMock();
$conn->expects($this->at(0))->method('getParams')->will($this->returnValue($params));
diff --git a/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php b/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php
index cf4da5b317d..0c78b5c1771 100644
--- a/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php
+++ b/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php
@@ -1,32 +1,17 @@
.
- */
namespace Doctrine\Tests\DBAL\Sharding\ShardChoser;
+use Doctrine\DBAL\Sharding\PoolingShardConnection;
use Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser;
+use PHPUnit\Framework\TestCase;
-class MultiTenantShardChoserTest extends \PHPUnit\Framework\TestCase
+class MultiTenantShardChoserTest extends TestCase
{
public function testPickShard()
{
$choser = new MultiTenantShardChoser();
- $conn = $this->createConnectionMock();
+ $conn = $this->createConnectionMock();
self::assertEquals(1, $choser->pickShard(1, $conn));
self::assertEquals(2, $choser->pickShard(2, $conn));
@@ -34,10 +19,9 @@ public function testPickShard()
private function createConnectionMock()
{
- return $this->getMockBuilder('Doctrine\DBAL\Sharding\PoolingShardConnection')
- ->setMethods(array('connect', 'getParams', 'fetchAll'))
+ return $this->getMockBuilder(PoolingShardConnection::class)
+ ->setMethods(['connect', 'getParams', 'fetchAll'])
->disableOriginalConstructor()
->getMock();
}
}
-
diff --git a/tests/Doctrine/Tests/DBAL/StatementTest.php b/tests/Doctrine/Tests/DBAL/StatementTest.php
index fa22536f2d4..7f18b20936a 100644
--- a/tests/Doctrine/Tests/DBAL/StatementTest.php
+++ b/tests/Doctrine/Tests/DBAL/StatementTest.php
@@ -2,55 +2,53 @@
namespace Doctrine\Tests\DBAL;
+use Doctrine\DBAL\Configuration;
+use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver;
+use Doctrine\DBAL\Driver\Connection as DriverConnection;
+use Doctrine\DBAL\Logging\SQLLogger;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Statement;
-use Doctrine\DBAL\Logging\SQLLogger;
+use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use Doctrine\Tests\DbalTestCase;
+use Exception;
+use PDOStatement;
-class StatementTest extends \Doctrine\Tests\DbalTestCase
+class StatementTest extends DbalTestCase
{
- /**
- *
- * @var \Doctrine\DBAL\Connection
- */
+ /** @var Connection */
private $conn;
- /**
- *
- * @var \Doctrine\DBAL\Configuration
- */
+ /** @var Configuration */
private $configuration;
- /**
- * @var \PDOStatement
- */
+ /** @var PDOStatement */
private $pdoStatement;
protected function setUp()
{
- $this->pdoStatement = $this->getMockBuilder('\PDOStatement')
- ->setMethods(array('execute', 'bindParam', 'bindValue'))
+ $this->pdoStatement = $this->getMockBuilder(PDOStatement::class)
+ ->setMethods(['execute', 'bindParam', 'bindValue'])
->getMock();
- $platform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform();
- $driverConnection = $this->createMock('\Doctrine\DBAL\Driver\Connection');
+ $platform = new MockPlatform();
+ $driverConnection = $this->createMock(DriverConnection::class);
$driverConnection->expects($this->any())
->method('prepare')
->will($this->returnValue($this->pdoStatement));
- $driver = $this->createMock('\Doctrine\DBAL\Driver');
- $constructorArgs = array(
- array(
- 'platform' => $platform
- ),
- $driver
- );
- $this->conn = $this->getMockBuilder('\Doctrine\DBAL\Connection')
+ $driver = $this->createMock(Driver::class);
+ $constructorArgs = [
+ ['platform' => $platform],
+ $driver,
+ ];
+ $this->conn = $this->getMockBuilder(Connection::class)
->setConstructorArgs($constructorArgs)
->getMock();
$this->conn->expects($this->atLeastOnce())
->method('getWrappedConnection')
->will($this->returnValue($driverConnection));
- $this->configuration = $this->createMock('\Doctrine\DBAL\Configuration');
+ $this->configuration = $this->createMock(Configuration::class);
$this->conn->expects($this->any())
->method('getConfiguration')
->will($this->returnValue($this->configuration));
@@ -58,7 +56,6 @@ protected function setUp()
$this->conn->expects($this->any())
->method('getDriver')
->will($this->returnValue($driver));
-
}
public function testExecuteCallsLoggerStartQueryWithParametersWhenValuesBound()
@@ -70,7 +67,7 @@ public function testExecuteCallsLoggerStartQueryWithParametersWhenValuesBound()
$types = [$name => $type];
$sql = '';
- $logger = $this->createMock('\Doctrine\DBAL\Logging\SQLLogger');
+ $logger = $this->createMock(SQLLogger::class);
$logger->expects($this->once())
->method('startQuery')
->with($this->equalTo($sql), $this->equalTo($values), $this->equalTo($types));
@@ -86,13 +83,13 @@ public function testExecuteCallsLoggerStartQueryWithParametersWhenValuesBound()
public function testExecuteCallsLoggerStartQueryWithParametersWhenParamsPassedToExecute()
{
- $name = 'foo';
- $var = 'bar';
- $values = array($name => $var);
- $types = array();
- $sql = '';
+ $name = 'foo';
+ $var = 'bar';
+ $values = [$name => $var];
+ $types = [];
+ $sql = '';
- $logger = $this->createMock('\Doctrine\DBAL\Logging\SQLLogger');
+ $logger = $this->createMock(SQLLogger::class);
$logger->expects($this->once())
->method('startQuery')
->with($this->equalTo($sql), $this->equalTo($values), $this->equalTo($types));
@@ -132,7 +129,7 @@ public function testExecuteCallsStartQueryWithTheParametersBoundViaBindParam()
*/
public function testExecuteCallsLoggerStopQueryOnException()
{
- $logger = $this->createMock('\Doctrine\DBAL\Logging\SQLLogger');
+ $logger = $this->createMock(SQLLogger::class);
$this->configuration->expects($this->once())
->method('getSQLLogger')
@@ -141,7 +138,7 @@ public function testExecuteCallsLoggerStopQueryOnException()
// Needed to satisfy construction of DBALException
$this->conn->expects($this->any())
->method('resolveParams')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$logger->expects($this->once())
->method('startQuery');
@@ -151,9 +148,9 @@ public function testExecuteCallsLoggerStopQueryOnException()
$this->pdoStatement->expects($this->once())
->method('execute')
- ->will($this->throwException(new \Exception("Mock test exception")));
+ ->will($this->throwException(new Exception('Mock test exception')));
- $statement = new Statement("", $this->conn);
+ $statement = new Statement('', $this->conn);
$statement->execute();
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php
index 164a609198a..a85efd0a88c 100644
--- a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php
+++ b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php
@@ -2,21 +2,23 @@
namespace Doctrine\Tests\DBAL\Tools\Console;
+use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
use Doctrine\DBAL\Tools\Console\ConsoleRunner;
+use LogicException;
+use PHPUnit\Framework\TestCase;
+use RuntimeException;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
-class RunSqlCommandTest extends \PHPUnit\Framework\TestCase
+class RunSqlCommandTest extends TestCase
{
/** @var CommandTester */
private $commandTester;
/** @var RunSqlCommand */
private $command;
- /**
- * @var \Doctrine\DBAL\Connection
- */
+ /** @var Connection */
private $connectionMock;
protected function setUp()
@@ -24,12 +26,12 @@ protected function setUp()
$application = new Application();
$application->add(new RunSqlCommand());
- $this->command = $application->find('dbal:run-sql');
+ $this->command = $application->find('dbal:run-sql');
$this->commandTester = new CommandTester($this->command);
- $this->connectionMock = $this->createMock('\Doctrine\DBAL\Connection');
+ $this->connectionMock = $this->createMock(Connection::class);
$this->connectionMock->method('fetchAll')
- ->willReturn(array(array(1)));
+ ->willReturn([[1]]);
$this->connectionMock->method('executeUpdate')
->willReturn(42);
@@ -40,12 +42,12 @@ protected function setUp()
public function testMissingSqlArgument()
{
try {
- $this->commandTester->execute(array(
+ $this->commandTester->execute([
'command' => $this->command->getName(),
'sql' => null,
- ));
+ ]);
$this->fail('Expected a runtime exception when omitting sql argument');
- } catch (\RuntimeException $e) {
+ } catch (RuntimeException $e) {
self::assertContains("Argument 'SQL", $e->getMessage());
}
}
@@ -53,13 +55,13 @@ public function testMissingSqlArgument()
public function testIncorrectDepthOption()
{
try {
- $this->commandTester->execute(array(
+ $this->commandTester->execute([
'command' => $this->command->getName(),
'sql' => 'SELECT 1',
'--depth' => 'string',
- ));
+ ]);
$this->fail('Expected a logic exception when executing with a stringy depth');
- } catch (\LogicException $e) {
+ } catch (LogicException $e) {
self::assertContains("Option 'depth'", $e->getMessage());
}
}
@@ -68,10 +70,10 @@ public function testSelectStatementsPrintsResult()
{
$this->expectConnectionFetchAll();
- $this->commandTester->execute(array(
+ $this->commandTester->execute([
'command' => $this->command->getName(),
'sql' => 'SELECT 1',
- ));
+ ]);
self::assertRegExp('@int.*1.*@', $this->commandTester->getDisplay());
self::assertRegExp('@array.*1.*@', $this->commandTester->getDisplay());
@@ -81,10 +83,10 @@ public function testUpdateStatementsPrintsAffectedLines()
{
$this->expectConnectionExecuteUpdate();
- $this->commandTester->execute(array(
+ $this->commandTester->execute([
'command' => $this->command->getName(),
'sql' => 'UPDATE foo SET bar = 42',
- ));
+ ]);
self::assertRegExp('@int.*42.*@', $this->commandTester->getDisplay());
self::assertNotRegExp('@array.*1.*@', $this->commandTester->getDisplay());
@@ -114,11 +116,11 @@ public function testStatementsWithFetchResultPrintsResult()
{
$this->expectConnectionFetchAll();
- $this->commandTester->execute(array(
+ $this->commandTester->execute([
'command' => $this->command->getName(),
'sql' => '"WITH bar as (SELECT 1) SELECT * FROM bar',
'--force-fetch' => true,
- ));
+ ]);
self::assertRegExp('@int.*1.*@', $this->commandTester->getDisplay());
self::assertRegExp('@array.*1.*@', $this->commandTester->getDisplay());
diff --git a/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php b/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php
index cf4fe4d560a..2aae261561f 100644
--- a/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php
+++ b/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php
@@ -9,6 +9,7 @@
use DateTimeZone;
use Doctrine\DBAL\Tools\Dumper;
use Doctrine\Tests\DbalTestCase;
+use stdClass;
use function print_r;
use function strpos;
use function substr;
@@ -17,7 +18,7 @@ class DumperTest extends DbalTestCase
{
public function testExportObject()
{
- $obj = new \stdClass();
+ $obj = new stdClass();
$obj->foo = 'bar';
$obj->bar = 1234;
diff --git a/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php b/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php
index c6599e66d65..ecb4155f74f 100644
--- a/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php
@@ -3,33 +3,31 @@
namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use Doctrine\Tests\DbalTestCase;
use function serialize;
-class ArrayTest extends \Doctrine\Tests\DbalTestCase
+class ArrayTest extends DbalTestCase
{
- /**
- * @var AbstractPlatform
- */
- protected $_platform;
+ /** @var AbstractPlatform */
+ private $platform;
- /**
- * @var Type
- */
- protected $_type;
+ /** @var Type */
+ private $type;
protected function setUp()
{
- $this->_platform = new MockPlatform();
- $this->_type = Type::getType('array');
+ $this->platform = new MockPlatform();
+ $this->type = Type::getType('array');
}
public function testArrayConvertsToDatabaseValue()
{
self::assertInternalType(
'string',
- $this->_type->convertToDatabaseValue(array(), $this->_platform)
+ $this->type->convertToDatabaseValue([], $this->platform)
);
}
@@ -37,20 +35,20 @@ public function testArrayConvertsToPHPValue()
{
self::assertInternalType(
'array',
- $this->_type->convertToPHPValue(serialize(array()), $this->_platform)
+ $this->type->convertToPHPValue(serialize([]), $this->platform)
);
}
public function testConversionFailure()
{
- $this->expectException('Doctrine\DBAL\Types\ConversionException');
+ $this->expectException(ConversionException::class);
$this->expectExceptionMessage("Could not convert database value to 'array' as an error was triggered by the unserialization: 'unserialize(): Error at offset 0 of 7 bytes'");
- $this->_type->convertToPHPValue('abcdefg', $this->_platform);
+ $this->type->convertToPHPValue('abcdefg', $this->platform);
}
public function testNullConversion()
{
- self::assertNull($this->_type->convertToPHPValue(null, $this->_platform));
+ self::assertNull($this->type->convertToPHPValue(null, $this->platform));
}
/**
@@ -58,6 +56,6 @@ public function testNullConversion()
*/
public function testFalseConversion()
{
- self::assertFalse($this->_type->convertToPHPValue(serialize(false), $this->_platform));
+ self::assertFalse($this->type->convertToPHPValue(serialize(false), $this->platform));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php b/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php
index a86b530c247..8140cf6d109 100644
--- a/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php
+++ b/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php
@@ -2,25 +2,25 @@
namespace Doctrine\Tests\DBAL\Types;
+use DateTime;
+use DateTimeImmutable;
+use Doctrine\DBAL\Types\ConversionException;
+use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use PHPUnit\Framework\TestCase;
+use stdClass;
use function date_default_timezone_get;
use function date_default_timezone_set;
-abstract class BaseDateTypeTestCase extends \PHPUnit\Framework\TestCase
+abstract class BaseDateTypeTestCase extends TestCase
{
- /**
- * @var MockPlatform
- */
+ /** @var MockPlatform */
protected $platform;
- /**
- * @var \Doctrine\DBAL\Types\Type
- */
+ /** @var Type */
protected $type;
- /**
- * @var string
- */
+ /** @var string */
private $currentTimezone;
/**
@@ -31,7 +31,7 @@ protected function setUp()
$this->platform = new MockPlatform();
$this->currentTimezone = date_default_timezone_get();
- self::assertInstanceOf('Doctrine\DBAL\Types\Type', $this->type);
+ self::assertInstanceOf(Type::class, $this->type);
}
/**
@@ -44,17 +44,17 @@ protected function tearDown()
public function testDateConvertsToDatabaseValue()
{
- self::assertInternalType('string', $this->type->convertToDatabaseValue(new \DateTime(), $this->platform));
+ self::assertInternalType('string', $this->type->convertToDatabaseValue(new DateTime(), $this->platform));
}
/**
- * @dataProvider invalidPHPValuesProvider
- *
* @param mixed $value
+ *
+ * @dataProvider invalidPHPValuesProvider
*/
public function testInvalidTypeConversionToDatabaseValue($value)
{
- $this->expectException('Doctrine\DBAL\Types\ConversionException');
+ $this->expectException(ConversionException::class);
$this->type->convertToDatabaseValue($value, $this->platform);
}
@@ -66,7 +66,7 @@ public function testNullConversion()
public function testConvertDateTimeToPHPValue()
{
- $date = new \DateTime('now');
+ $date = new DateTime('now');
self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform));
}
@@ -80,7 +80,7 @@ public function testConvertDateTimeToPHPValue()
*/
public function testConvertDateTimeImmutableToPHPValue()
{
- $date = new \DateTimeImmutable('now');
+ $date = new DateTimeImmutable('now');
self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform));
}
@@ -96,7 +96,7 @@ public function testDateTimeImmutableConvertsToDatabaseValue()
{
self::assertInternalType(
'string',
- $this->type->convertToDatabaseValue(new \DateTimeImmutable(), $this->platform)
+ $this->type->convertToDatabaseValue(new DateTimeImmutable(), $this->platform)
);
}
@@ -112,7 +112,7 @@ public function invalidPHPValuesProvider()
['10:11:12'],
['2015-01-31'],
['2015-01-31 10:11:12'],
- [new \stdClass()],
+ [new stdClass()],
[$this],
[27],
[-1],
diff --git a/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php b/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php
index 9881c897960..fbcf5fb9357 100644
--- a/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php
@@ -3,22 +3,20 @@
namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\ParameterType;
+use Doctrine\DBAL\Types\BinaryType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use Doctrine\Tests\DbalTestCase;
use function base64_encode;
use function fopen;
use function stream_get_contents;
-class BinaryTest extends \Doctrine\Tests\DbalTestCase
+class BinaryTest extends DbalTestCase
{
- /**
- * @var \Doctrine\Tests\DBAL\Mocks\MockPlatform
- */
+ /** @var MockPlatform */
protected $platform;
- /**
- * @var \Doctrine\DBAL\Types\BinaryType
- */
+ /** @var BinaryType */
protected $type;
/**
@@ -42,7 +40,7 @@ public function testReturnsName()
public function testReturnsSQLDeclaration()
{
- self::assertSame('DUMMYBINARY', $this->type->getSQLDeclaration(array(), $this->platform));
+ self::assertSame('DUMMYBINARY', $this->type->getSQLDeclaration([], $this->platform));
}
public function testBinaryNullConvertsToPHPValue()
@@ -78,15 +76,15 @@ public function testThrowsConversionExceptionOnInvalidDatabaseValue($value)
public function getInvalidDatabaseValues()
{
- return array(
- array(false),
- array(true),
- array(0),
- array(1),
- array(-1),
- array(0.0),
- array(1.1),
- array(-1.1),
- );
+ return [
+ [false],
+ [true],
+ [0],
+ [1],
+ [-1],
+ [0.0],
+ [1.1],
+ [-1.1],
+ ];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/BlobTest.php b/tests/Doctrine/Tests/DBAL/Types/BlobTest.php
index 1ee3fefc43c..5500836cfdb 100644
--- a/tests/Doctrine/Tests/DBAL/Types/BlobTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/BlobTest.php
@@ -2,23 +2,21 @@
namespace Doctrine\Tests\DBAL\Types;
+use Doctrine\DBAL\Types\BlobType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use Doctrine\Tests\DbalTestCase;
use function base64_encode;
use function chr;
use function fopen;
use function stream_get_contents;
-class BlobTest extends \Doctrine\Tests\DbalTestCase
+class BlobTest extends DbalTestCase
{
- /**
- * @var \Doctrine\Tests\DBAL\Mocks\MockPlatform
- */
+ /** @var MockPlatform */
protected $platform;
- /**
- * @var \Doctrine\DBAL\Types\BlobType
- */
+ /** @var BlobType */
protected $type;
/**
@@ -27,7 +25,7 @@ class BlobTest extends \Doctrine\Tests\DbalTestCase
protected function setUp()
{
$this->platform = new MockPlatform();
- $this->type = Type::getType('blob');
+ $this->type = Type::getType('blob');
}
public function testBlobNullConvertsToPHPValue()
diff --git a/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php b/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php
index 0c5cb3ccecd..a7e3377107a 100644
--- a/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php
@@ -4,37 +4,34 @@
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use Doctrine\Tests\DbalTestCase;
-class BooleanTest extends \Doctrine\Tests\DbalTestCase
+class BooleanTest extends DbalTestCase
{
- /**
- * @var MockPlatform
- */
- protected $_platform;
+ /** @var MockPlatform */
+ private $platform;
- /**
- * @var Type
- */
- protected $_type;
+ /** @var Type */
+ private $type;
protected function setUp()
{
- $this->_platform = new MockPlatform();
- $this->_type = Type::getType('boolean');
+ $this->platform = new MockPlatform();
+ $this->type = Type::getType('boolean');
}
public function testBooleanConvertsToDatabaseValue()
{
- self::assertInternalType('integer', $this->_type->convertToDatabaseValue(1, $this->_platform));
+ self::assertInternalType('integer', $this->type->convertToDatabaseValue(1, $this->platform));
}
public function testBooleanConvertsToPHPValue()
{
- self::assertInternalType('bool', $this->_type->convertToPHPValue(0, $this->_platform));
+ self::assertInternalType('bool', $this->type->convertToPHPValue(0, $this->platform));
}
public function testBooleanNullConvertsToPHPValue()
{
- self::assertNull($this->_type->convertToPHPValue(null, $this->_platform));
+ self::assertNull($this->type->convertToPHPValue(null, $this->platform));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php b/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php
index a8847030c29..f0183ef854c 100644
--- a/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php
@@ -3,20 +3,23 @@
namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\Types\ConversionException;
+use Exception;
+use PHPUnit\Framework\TestCase;
+use stdClass;
use function tmpfile;
-class ConversionExceptionTest extends \PHPUnit\Framework\TestCase
+class ConversionExceptionTest extends TestCase
{
/**
- * @dataProvider scalarsProvider
- *
* @param mixed $scalarValue
+ *
+ * @dataProvider scalarsProvider
*/
public function testConversionFailedInvalidTypeWithScalar($scalarValue)
{
$exception = ConversionException::conversionFailedInvalidType($scalarValue, 'foo', ['bar', 'baz']);
- self::assertInstanceOf('Doctrine\DBAL\Types\ConversionException', $exception);
+ self::assertInstanceOf(ConversionException::class, $exception);
self::assertRegExp(
'/^Could not convert PHP value \'.*\' of type \'(string|boolean|float|double|integer)\' to type \'foo\'. '
. 'Expected one of the following types: bar, baz$/',
@@ -24,15 +27,15 @@ public function testConversionFailedInvalidTypeWithScalar($scalarValue)
);
}
/**
- * @dataProvider nonScalarsProvider
- *
* @param mixed $nonScalar
+ *
+ * @dataProvider nonScalarsProvider
*/
public function testConversionFailedInvalidTypeWithNonScalar($nonScalar)
{
$exception = ConversionException::conversionFailedInvalidType($nonScalar, 'foo', ['bar', 'baz']);
- self::assertInstanceOf('Doctrine\DBAL\Types\ConversionException', $exception);
+ self::assertInstanceOf(ConversionException::class, $exception);
self::assertRegExp(
'/^Could not convert PHP value of type \'(.*)\' to type \'foo\'. '
. 'Expected one of the following types: bar, baz$/',
@@ -42,11 +45,11 @@ public function testConversionFailedInvalidTypeWithNonScalar($nonScalar)
public function testConversionFailedFormatPreservesPreviousException()
{
- $previous = new \Exception();
+ $previous = new Exception();
$exception = ConversionException::conversionFailedFormat('foo', 'bar', 'baz', $previous);
- self::assertInstanceOf('Doctrine\DBAL\Types\ConversionException', $exception);
+ self::assertInstanceOf(ConversionException::class, $exception);
self::assertSame($previous, $exception->getPrevious());
}
@@ -60,7 +63,7 @@ public function nonScalarsProvider()
[['foo']],
[null],
[$this],
- [new \stdClass()],
+ [new stdClass()],
[tmpfile()],
];
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php
index 7c60986240e..5fd15d812d3 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php
@@ -2,28 +2,28 @@
namespace Doctrine\Tests\DBAL\Types;
+use DateTime;
+use DateTimeImmutable;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateImmutableType;
use Doctrine\DBAL\Types\Type;
+use PHPUnit\Framework\TestCase;
+use Prophecy\Prophecy\ObjectProphecy;
use function get_class;
-class DateImmutableTypeTest extends \PHPUnit\Framework\TestCase
+class DateImmutableTypeTest extends TestCase
{
- /**
- * @var \Doctrine\DBAL\Platforms\AbstractPlatform|\Prophecy\Prophecy\ObjectProphecy
- */
+ /** @var AbstractPlatform|ObjectProphecy */
private $platform;
- /**
- * @var DateImmutableType
- */
+ /** @var DateImmutableType */
private $type;
protected function setUp()
{
- $this->type = Type::getType('date_immutable');
+ $this->type = Type::getType('date_immutable');
$this->platform = $this->prophesize(AbstractPlatform::class);
}
@@ -44,7 +44,7 @@ public function testReturnsBindingType()
public function testConvertsDateTimeImmutableInstanceToDatabaseValue()
{
- $date = $this->prophesize(\DateTimeImmutable::class);
+ $date = $this->prophesize(DateTimeImmutable::class);
$this->platform->getDateFormatString()->willReturn('Y-m-d')->shouldBeCalled();
$date->format('Y-m-d')->willReturn('2016-01-01')->shouldBeCalled();
@@ -64,12 +64,12 @@ public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion()
{
$this->expectException(ConversionException::class);
- $this->type->convertToDatabaseValue(new \DateTime(), $this->platform->reveal());
+ $this->type->convertToDatabaseValue(new DateTime(), $this->platform->reveal());
}
public function testConvertsDateTimeImmutableInstanceToPHPValue()
{
- $date = new \DateTimeImmutable();
+ $date = new DateTimeImmutable();
self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform->reveal()));
}
@@ -85,7 +85,7 @@ public function testConvertsDateStringToPHPValue()
$date = $this->type->convertToPHPValue('2016-01-01', $this->platform->reveal());
- self::assertInstanceOf(\DateTimeImmutable::class, $date);
+ self::assertInstanceOf(DateTimeImmutable::class, $date);
self::assertSame('2016-01-01', $date->format('Y-m-d'));
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php b/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php
index 61919ec6c87..27d83ae7df7 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php
@@ -2,22 +2,21 @@
namespace Doctrine\Tests\DBAL\Types;
+use DateInterval;
+use DateTime;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateIntervalType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
use Doctrine\Tests\DbalTestCase;
+use stdClass;
final class DateIntervalTest extends DbalTestCase
{
- /**
- * @var MockPlatform
- */
+ /** @var MockPlatform */
private $platform;
- /**
- * @var \Doctrine\DBAL\Types\DateIntervalType
- */
+ /** @var DateIntervalType */
private $type;
/**
@@ -33,10 +32,10 @@ protected function setUp() : void
public function testDateIntervalConvertsToDatabaseValue() : void
{
- $interval = new \DateInterval('P2Y1DT1H2M3S');
+ $interval = new DateInterval('P2Y1DT1H2M3S');
$expected = '+P02Y00M01DT01H02M03S';
- $actual = $this->type->convertToDatabaseValue($interval, $this->platform);
+ $actual = $this->type->convertToDatabaseValue($interval, $this->platform);
self::assertEquals($expected, $actual);
}
@@ -45,13 +44,13 @@ public function testDateIntervalConvertsToPHPValue() : void
{
$interval = $this->type->convertToPHPValue('+P02Y00M01DT01H02M03S', $this->platform);
- self::assertInstanceOf(\DateInterval::class, $interval);
+ self::assertInstanceOf(DateInterval::class, $interval);
self::assertEquals('+P02Y00M01DT01H02M03S', $interval->format(DateIntervalType::FORMAT));
}
public function testNegativeDateIntervalConvertsToDatabaseValue() : void
{
- $interval = new \DateInterval('P2Y1DT1H2M3S');
+ $interval = new DateInterval('P2Y1DT1H2M3S');
$interval->invert = 1;
$actual = $this->type->convertToDatabaseValue($interval, $this->platform);
@@ -63,7 +62,7 @@ public function testNegativeDateIntervalConvertsToPHPValue() : void
{
$interval = $this->type->convertToPHPValue('-P02Y00M01DT01H02M03S', $this->platform);
- self::assertInstanceOf(\DateInterval::class, $interval);
+ self::assertInstanceOf(DateInterval::class, $interval);
self::assertEquals('-P02Y00M01DT01H02M03S', $interval->format(DateIntervalType::FORMAT));
}
@@ -71,7 +70,7 @@ public function testDateIntervalFormatWithoutSignConvertsToPHPValue() : void
{
$interval = $this->type->convertToPHPValue('P02Y00M01DT01H02M03S', $this->platform);
- self::assertInstanceOf(\DateInterval::class, $interval);
+ self::assertInstanceOf(DateInterval::class, $interval);
self::assertEquals('+P02Y00M01DT01H02M03S', $interval->format(DateIntervalType::FORMAT));
}
@@ -124,14 +123,14 @@ public function invalidPHPValuesProvider() : array
['10:11:12'],
['2015-01-31'],
['2015-01-31 10:11:12'],
- [new \stdClass()],
+ [new stdClass()],
[$this],
[27],
[-1],
[1.2],
[[]],
[['an array']],
- [new \DateTime()],
+ [new DateTime()],
];
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTest.php
index c68ebc7f471..a8c7327b337 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DateTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DateTest.php
@@ -2,6 +2,8 @@
namespace Doctrine\Tests\DBAL\Types;
+use DateTime;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
use function date_default_timezone_set;
@@ -21,7 +23,7 @@ public function testDateConvertsToPHPValue()
{
// Birthday of jwage and also birthday of Doctrine. Send him a present ;)
self::assertInstanceOf(
- \DateTime::class,
+ DateTime::class,
$this->type->convertToPHPValue('1985-09-01', $this->platform)
);
}
@@ -33,7 +35,7 @@ public function testDateResetsNonDatePartsToZeroUnixTimeValues()
self::assertEquals('00:00:00', $date->format('H:i:s'));
}
- public function testDateRests_SummerTimeAffection()
+ public function testDateRestsSummerTimeAffection()
{
date_default_timezone_set('Europe/Berlin');
@@ -48,7 +50,7 @@ public function testDateRests_SummerTimeAffection()
public function testInvalidDateFormatConversion()
{
- $this->expectException('Doctrine\DBAL\Types\ConversionException');
+ $this->expectException(ConversionException::class);
$this->type->convertToPHPValue('abcdefg', $this->platform);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php
index 9cb1f9c6b72..dfedcca32b1 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php
@@ -2,28 +2,28 @@
namespace Doctrine\Tests\DBAL\Types;
+use DateTime;
+use DateTimeImmutable;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateTimeImmutableType;
use Doctrine\DBAL\Types\Type;
+use PHPUnit\Framework\TestCase;
+use Prophecy\Prophecy\ObjectProphecy;
use function get_class;
-class DateTimeImmutableTypeTest extends \PHPUnit\Framework\TestCase
+class DateTimeImmutableTypeTest extends TestCase
{
- /**
- * @var \Doctrine\DBAL\Platforms\AbstractPlatform|\Prophecy\Prophecy\ObjectProphecy
- */
+ /** @var AbstractPlatform|ObjectProphecy */
private $platform;
- /**
- * @var DateTimeImmutableType
- */
+ /** @var DateTimeImmutableType */
private $type;
protected function setUp()
{
- $this->type = Type::getType('datetime_immutable');
+ $this->type = Type::getType('datetime_immutable');
$this->platform = $this->prophesize(AbstractPlatform::class);
}
@@ -44,7 +44,7 @@ public function testReturnsBindingType()
public function testConvertsDateTimeImmutableInstanceToDatabaseValue()
{
- $date = $this->prophesize(\DateTimeImmutable::class);
+ $date = $this->prophesize(DateTimeImmutable::class);
$this->platform->getDateTimeFormatString()->willReturn('Y-m-d H:i:s')->shouldBeCalled();
$date->format('Y-m-d H:i:s')->willReturn('2016-01-01 15:58:59')->shouldBeCalled();
@@ -64,12 +64,12 @@ public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion()
{
$this->expectException(ConversionException::class);
- $this->type->convertToDatabaseValue(new \DateTime(), $this->platform->reveal());
+ $this->type->convertToDatabaseValue(new DateTime(), $this->platform->reveal());
}
public function testConvertsDateTimeImmutableInstanceToPHPValue()
{
- $date = new \DateTimeImmutable();
+ $date = new DateTimeImmutable();
self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform->reveal()));
}
@@ -85,7 +85,7 @@ public function testConvertsDateTimeStringToPHPValue()
$date = $this->type->convertToPHPValue('2016-01-01 15:58:59', $this->platform->reveal());
- self::assertInstanceOf(\DateTimeImmutable::class, $date);
+ self::assertInstanceOf(DateTimeImmutable::class, $date);
self::assertSame('2016-01-01 15:58:59', $date->format('Y-m-d H:i:s'));
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php
index 3b66c260c8d..7d571f80eb2 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php
@@ -2,6 +2,8 @@
namespace Doctrine\Tests\DBAL\Types;
+use DateTime;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
class DateTimeTest extends BaseDateTypeTestCase
@@ -18,10 +20,10 @@ protected function setUp()
public function testDateTimeConvertsToDatabaseValue()
{
- $date = new \DateTime('1985-09-01 10:10:10');
+ $date = new DateTime('1985-09-01 10:10:10');
$expected = $date->format($this->platform->getDateTimeTzFormatString());
- $actual = $this->type->convertToDatabaseValue($date, $this->platform);
+ $actual = $this->type->convertToDatabaseValue($date, $this->platform);
self::assertEquals($expected, $actual);
}
@@ -36,7 +38,7 @@ public function testDateTimeConvertsToPHPValue()
public function testInvalidDateTimeFormatConversion()
{
- $this->expectException('Doctrine\DBAL\Types\ConversionException');
+ $this->expectException(ConversionException::class);
$this->type->convertToPHPValue('abcdefg', $this->platform);
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php
index 9563d968082..df47f7b3991 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php
@@ -2,28 +2,28 @@
namespace Doctrine\Tests\DBAL\Types;
+use DateTime;
+use DateTimeImmutable;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\DateTimeTzImmutableType;
use Doctrine\DBAL\Types\Type;
+use PHPUnit\Framework\TestCase;
+use Prophecy\Prophecy\ObjectProphecy;
use function get_class;
-class DateTimeTzImmutableTypeTest extends \PHPUnit\Framework\TestCase
+class DateTimeTzImmutableTypeTest extends TestCase
{
- /**
- * @var \Doctrine\DBAL\Platforms\AbstractPlatform|\Prophecy\Prophecy\ObjectProphecy
- */
+ /** @var AbstractPlatform|ObjectProphecy */
private $platform;
- /**
- * @var DateTimeTzImmutableType
- */
+ /** @var DateTimeTzImmutableType */
private $type;
protected function setUp()
{
- $this->type = Type::getType('datetimetz_immutable');
+ $this->type = Type::getType('datetimetz_immutable');
$this->platform = $this->prophesize(AbstractPlatform::class);
}
@@ -44,7 +44,7 @@ public function testReturnsBindingType()
public function testConvertsDateTimeImmutableInstanceToDatabaseValue()
{
- $date = $this->prophesize(\DateTimeImmutable::class);
+ $date = $this->prophesize(DateTimeImmutable::class);
$this->platform->getDateTimeTzFormatString()->willReturn('Y-m-d H:i:s T')->shouldBeCalled();
$date->format('Y-m-d H:i:s T')->willReturn('2016-01-01 15:58:59 UTC')->shouldBeCalled();
@@ -64,12 +64,12 @@ public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion()
{
$this->expectException(ConversionException::class);
- $this->type->convertToDatabaseValue(new \DateTime(), $this->platform->reveal());
+ $this->type->convertToDatabaseValue(new DateTime(), $this->platform->reveal());
}
public function testConvertsDateTimeImmutableInstanceToPHPValue()
{
- $date = new \DateTimeImmutable();
+ $date = new DateTimeImmutable();
self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform->reveal()));
}
@@ -85,7 +85,7 @@ public function testConvertsDateTimeWithTimezoneStringToPHPValue()
$date = $this->type->convertToPHPValue('2016-01-01 15:58:59 UTC', $this->platform->reveal());
- self::assertInstanceOf(\DateTimeImmutable::class, $date);
+ self::assertInstanceOf(DateTimeImmutable::class, $date);
self::assertSame('2016-01-01 15:58:59 UTC', $date->format('Y-m-d H:i:s T'));
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php
index bcc77b4c989..4b6c8fb208f 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php
@@ -2,6 +2,8 @@
namespace Doctrine\Tests\DBAL\Types;
+use DateTime;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
class DateTimeTzTest extends BaseDateTypeTestCase
@@ -18,10 +20,10 @@ protected function setUp()
public function testDateTimeConvertsToDatabaseValue()
{
- $date = new \DateTime('1985-09-01 10:10:10');
+ $date = new DateTime('1985-09-01 10:10:10');
$expected = $date->format($this->platform->getDateTimeTzFormatString());
- $actual = $this->type->convertToDatabaseValue($date, $this->platform);
+ $actual = $this->type->convertToDatabaseValue($date, $this->platform);
self::assertEquals($expected, $actual);
}
@@ -36,7 +38,7 @@ public function testDateTimeConvertsToPHPValue()
public function testInvalidDateFormatConversion()
{
- $this->expectException('Doctrine\DBAL\Types\ConversionException');
+ $this->expectException(ConversionException::class);
$this->type->convertToPHPValue('abcdefg', $this->platform);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php b/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php
index 9571629af25..3d1164afbfb 100644
--- a/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php
@@ -4,32 +4,29 @@
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use Doctrine\Tests\DbalTestCase;
-class DecimalTest extends \Doctrine\Tests\DbalTestCase
+class DecimalTest extends DbalTestCase
{
- /**
- * @var MockPlatform
- */
- protected $_platform;
+ /** @var MockPlatform */
+ private $platform;
- /**
- * @var Type
- */
- protected $_type;
+ /** @var Type */
+ private $type;
protected function setUp()
{
- $this->_platform = new MockPlatform();
- $this->_type = Type::getType('decimal');
+ $this->platform = new MockPlatform();
+ $this->type = Type::getType('decimal');
}
public function testDecimalConvertsToPHPValue()
{
- self::assertInternalType('string', $this->_type->convertToPHPValue('5.5', $this->_platform));
+ self::assertInternalType('string', $this->type->convertToPHPValue('5.5', $this->platform));
}
public function testDecimalNullConvertsToPHPValue()
{
- self::assertNull($this->_type->convertToPHPValue(null, $this->_platform));
+ self::assertNull($this->type->convertToPHPValue(null, $this->platform));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/FloatTest.php b/tests/Doctrine/Tests/DBAL/Types/FloatTest.php
index 036481ce10e..e68bf0bc46f 100644
--- a/tests/Doctrine/Tests/DBAL/Types/FloatTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/FloatTest.php
@@ -4,42 +4,39 @@
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use Doctrine\Tests\DbalTestCase;
-class FloatTest extends \Doctrine\Tests\DbalTestCase
+class FloatTest extends DbalTestCase
{
- /**
- * @var MockPlatform
- */
- protected $_platform;
+ /** @var MockPlatform */
+ private $platform;
- /**
- * @var Type
- */
- protected $_type;
+ /** @var Type */
+ private $type;
protected function setUp()
{
- $this->_platform = new MockPlatform();
- $this->_type = Type::getType('float');
+ $this->platform = new MockPlatform();
+ $this->type = Type::getType('float');
}
public function testFloatConvertsToPHPValue()
{
- self::assertInternalType('float', $this->_type->convertToPHPValue('5.5', $this->_platform));
+ self::assertInternalType('float', $this->type->convertToPHPValue('5.5', $this->platform));
}
public function testFloatNullConvertsToPHPValue()
{
- self::assertNull($this->_type->convertToPHPValue(null, $this->_platform));
+ self::assertNull($this->type->convertToPHPValue(null, $this->platform));
}
public function testFloatConvertToDatabaseValue()
{
- self::assertInternalType('float', $this->_type->convertToDatabaseValue(5.5, $this->_platform));
+ self::assertInternalType('float', $this->type->convertToDatabaseValue(5.5, $this->platform));
}
public function testFloatNullConvertToDatabaseValue()
{
- self::assertNull($this->_type->convertToDatabaseValue(null, $this->_platform));
+ self::assertNull($this->type->convertToDatabaseValue(null, $this->platform));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php
index cfc40999ef1..978cfd50fb7 100644
--- a/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php
@@ -9,42 +9,38 @@
class GuidTypeTest extends DbalTestCase
{
- /**
- * @var MockPlatform
- */
- protected $_platform;
+ /** @var MockPlatform */
+ private $platform;
- /**
- * @var Type
- */
- protected $_type;
+ /** @var Type */
+ private $type;
protected function setUp()
{
- $this->_platform = new MockPlatform();
- $this->_type = Type::getType('guid');
+ $this->platform = new MockPlatform();
+ $this->type = Type::getType('guid');
}
public function testConvertToPHPValue()
{
- self::assertInternalType("string", $this->_type->convertToPHPValue("foo", $this->_platform));
- self::assertInternalType("string", $this->_type->convertToPHPValue("", $this->_platform));
+ self::assertInternalType('string', $this->type->convertToPHPValue('foo', $this->platform));
+ self::assertInternalType('string', $this->type->convertToPHPValue('', $this->platform));
}
public function testNullConversion()
{
- self::assertNull($this->_type->convertToPHPValue(null, $this->_platform));
+ self::assertNull($this->type->convertToPHPValue(null, $this->platform));
}
public function testNativeGuidSupport()
{
- self::assertTrue($this->_type->requiresSQLCommentHint($this->_platform));
+ self::assertTrue($this->type->requiresSQLCommentHint($this->platform));
- $mock = $this->createMock(get_class($this->_platform));
+ $mock = $this->createMock(get_class($this->platform));
$mock->expects($this->any())
->method('hasNativeGuidType')
->will($this->returnValue(true));
- self::assertFalse($this->_type->requiresSQLCommentHint($mock));
+ self::assertFalse($this->type->requiresSQLCommentHint($mock));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php b/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php
index 51d57d5c98e..848ff05dfc8 100644
--- a/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php
@@ -4,33 +4,30 @@
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use Doctrine\Tests\DbalTestCase;
-class IntegerTest extends \Doctrine\Tests\DbalTestCase
+class IntegerTest extends DbalTestCase
{
- /**
- * @var MockPlatform
- */
- protected $_platform;
+ /** @var MockPlatform */
+ private $platform;
- /**
- * @var Type
- */
- protected $_type;
+ /** @var Type */
+ private $type;
protected function setUp()
{
- $this->_platform = new MockPlatform();
- $this->_type = Type::getType('integer');
+ $this->platform = new MockPlatform();
+ $this->type = Type::getType('integer');
}
public function testIntegerConvertsToPHPValue()
{
- self::assertInternalType('integer', $this->_type->convertToPHPValue('1', $this->_platform));
- self::assertInternalType('integer', $this->_type->convertToPHPValue('0', $this->_platform));
+ self::assertInternalType('integer', $this->type->convertToPHPValue('1', $this->platform));
+ self::assertInternalType('integer', $this->type->convertToPHPValue('0', $this->platform));
}
public function testIntegerNullConvertsToPHPValue()
{
- self::assertNull($this->_type->convertToPHPValue(null, $this->_platform));
+ self::assertNull($this->type->convertToPHPValue(null, $this->platform));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php
index 3972002caf8..564371a30b3 100644
--- a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php
@@ -3,22 +3,20 @@
namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\ParameterType;
+use Doctrine\DBAL\Types\JsonArrayType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use Doctrine\Tests\DbalTestCase;
use function base64_encode;
use function fopen;
use function json_encode;
-class JsonArrayTest extends \Doctrine\Tests\DbalTestCase
+class JsonArrayTest extends DbalTestCase
{
- /**
- * @var \Doctrine\Tests\DBAL\Mocks\MockPlatform
- */
+ /** @var MockPlatform */
protected $platform;
- /**
- * @var \Doctrine\DBAL\Types\JsonArrayType
- */
+ /** @var JsonArrayType */
protected $type;
/**
@@ -42,22 +40,22 @@ public function testReturnsName()
public function testReturnsSQLDeclaration()
{
- self::assertSame('DUMMYJSON', $this->type->getSQLDeclaration(array(), $this->platform));
+ self::assertSame('DUMMYJSON', $this->type->getSQLDeclaration([], $this->platform));
}
public function testJsonNullConvertsToPHPValue()
{
- self::assertSame(array(), $this->type->convertToPHPValue(null, $this->platform));
+ self::assertSame([], $this->type->convertToPHPValue(null, $this->platform));
}
public function testJsonEmptyStringConvertsToPHPValue()
{
- self::assertSame(array(), $this->type->convertToPHPValue('', $this->platform));
+ self::assertSame([], $this->type->convertToPHPValue('', $this->platform));
}
public function testJsonStringConvertsToPHPValue()
{
- $value = array('foo' => 'bar', 'bar' => 'foo');
+ $value = ['foo' => 'bar', 'bar' => 'foo'];
$databaseValue = json_encode($value);
$phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform);
@@ -66,7 +64,7 @@ public function testJsonStringConvertsToPHPValue()
public function testJsonResourceConvertsToPHPValue()
{
- $value = array('foo' => 'bar', 'bar' => 'foo');
+ $value = ['foo' => 'bar', 'bar' => 'foo'];
$databaseValue = fopen('data://text/plain;base64,' . base64_encode(json_encode($value)), 'r');
$phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform);
diff --git a/tests/Doctrine/Tests/DBAL/Types/JsonTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php
index ddf72b22d79..4f204a8baec 100644
--- a/tests/Doctrine/Tests/DBAL/Types/JsonTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php
@@ -3,22 +3,21 @@
namespace Doctrine\Tests\DBAL\Types;
use Doctrine\DBAL\ParameterType;
+use Doctrine\DBAL\Types\ConversionException;
+use Doctrine\DBAL\Types\JsonType;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use Doctrine\Tests\DbalTestCase;
use function base64_encode;
use function fopen;
use function json_encode;
-class JsonTest extends \Doctrine\Tests\DbalTestCase
+class JsonTest extends DbalTestCase
{
- /**
- * @var \Doctrine\Tests\DBAL\Mocks\MockPlatform
- */
+ /** @var MockPlatform */
protected $platform;
- /**
- * @var \Doctrine\DBAL\Types\JsonType
- */
+ /** @var JsonType */
protected $type;
/**
@@ -42,7 +41,7 @@ public function testReturnsName()
public function testReturnsSQLDeclaration()
{
- self::assertSame('DUMMYJSON', $this->type->getSQLDeclaration(array(), $this->platform));
+ self::assertSame('DUMMYJSON', $this->type->getSQLDeclaration([], $this->platform));
}
public function testJsonNullConvertsToPHPValue()
@@ -57,7 +56,7 @@ public function testJsonEmptyStringConvertsToPHPValue()
public function testJsonStringConvertsToPHPValue()
{
- $value = array('foo' => 'bar', 'bar' => 'foo');
+ $value = ['foo' => 'bar', 'bar' => 'foo'];
$databaseValue = json_encode($value);
$phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform);
@@ -67,18 +66,18 @@ public function testJsonStringConvertsToPHPValue()
/** @dataProvider providerFailure */
public function testConversionFailure($data)
{
- $this->expectException('Doctrine\DBAL\Types\ConversionException');
+ $this->expectException(ConversionException::class);
$this->type->convertToPHPValue($data, $this->platform);
}
public function providerFailure()
{
- return array(array('a'), array('{'));
+ return [['a'], ['{']];
}
public function testJsonResourceConvertsToPHPValue()
{
- $value = array('foo' => 'bar', 'bar' => 'foo');
+ $value = ['foo' => 'bar', 'bar' => 'foo'];
$databaseValue = fopen('data://text/plain;base64,' . base64_encode(json_encode($value)), 'r');
$phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform);
diff --git a/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php b/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php
index bd4fcd8057d..858004b73f4 100644
--- a/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php
@@ -2,48 +2,47 @@
namespace Doctrine\Tests\DBAL\Types;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use Doctrine\Tests\DbalTestCase;
+use stdClass;
use function serialize;
-class ObjectTest extends \Doctrine\Tests\DbalTestCase
+class ObjectTest extends DbalTestCase
{
- /**
- * @var MockPlatform
- */
- protected $_platform;
+ /** @var MockPlatform */
+ private $platform;
- /**
- * @var Type
- */
- protected $_type;
+ /** @var Type */
+ private $type;
protected function setUp()
{
- $this->_platform = new MockPlatform();
- $this->_type = Type::getType('object');
+ $this->platform = new MockPlatform();
+ $this->type = Type::getType('object');
}
public function testObjectConvertsToDatabaseValue()
{
- self::assertInternalType('string', $this->_type->convertToDatabaseValue(new \stdClass(), $this->_platform));
+ self::assertInternalType('string', $this->type->convertToDatabaseValue(new stdClass(), $this->platform));
}
public function testObjectConvertsToPHPValue()
{
- self::assertInternalType('object', $this->_type->convertToPHPValue(serialize(new \stdClass), $this->_platform));
+ self::assertInternalType('object', $this->type->convertToPHPValue(serialize(new stdClass()), $this->platform));
}
public function testConversionFailure()
{
- $this->expectException('Doctrine\DBAL\Types\ConversionException');
+ $this->expectException(ConversionException::class);
$this->expectExceptionMessage("Could not convert database value to 'object' as an error was triggered by the unserialization: 'unserialize(): Error at offset 0 of 7 bytes'");
- $this->_type->convertToPHPValue('abcdefg', $this->_platform);
+ $this->type->convertToPHPValue('abcdefg', $this->platform);
}
public function testNullConversion()
{
- self::assertNull($this->_type->convertToPHPValue(null, $this->_platform));
+ self::assertNull($this->type->convertToPHPValue(null, $this->platform));
}
/**
@@ -51,6 +50,6 @@ public function testNullConversion()
*/
public function testFalseConversion()
{
- self::assertFalse($this->_type->convertToPHPValue(serialize(false), $this->_platform));
+ self::assertFalse($this->type->convertToPHPValue(serialize(false), $this->platform));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php b/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php
index 89a50117e15..4a453421b36 100644
--- a/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php
@@ -4,33 +4,30 @@
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use Doctrine\Tests\DbalTestCase;
-class SmallIntTest extends \Doctrine\Tests\DbalTestCase
+class SmallIntTest extends DbalTestCase
{
- /**
- * @var MockPlatform
- */
- protected $_platform;
+ /** @var MockPlatform */
+ private $platform;
- /**
- * @var Type
- */
- protected $_type;
+ /** @var Type */
+ private $type;
protected function setUp()
{
- $this->_platform = new MockPlatform();
- $this->_type = Type::getType('smallint');
+ $this->platform = new MockPlatform();
+ $this->type = Type::getType('smallint');
}
public function testSmallIntConvertsToPHPValue()
{
- self::assertInternalType('integer', $this->_type->convertToPHPValue('1', $this->_platform));
- self::assertInternalType('integer', $this->_type->convertToPHPValue('0', $this->_platform));
+ self::assertInternalType('integer', $this->type->convertToPHPValue('1', $this->platform));
+ self::assertInternalType('integer', $this->type->convertToPHPValue('0', $this->platform));
}
public function testSmallIntNullConvertsToPHPValue()
{
- self::assertNull($this->_type->convertToPHPValue(null, $this->_platform));
+ self::assertNull($this->type->convertToPHPValue(null, $this->platform));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/StringTest.php b/tests/Doctrine/Tests/DBAL/Types/StringTest.php
index e968b9f0d99..74716e4f23c 100644
--- a/tests/Doctrine/Tests/DBAL/Types/StringTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/StringTest.php
@@ -4,50 +4,47 @@
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use Doctrine\Tests\DbalTestCase;
-class StringTest extends \Doctrine\Tests\DbalTestCase
+class StringTest extends DbalTestCase
{
- /**
- * @var MockPlatform
- */
- protected $_platform;
+ /** @var MockPlatform */
+ private $platform;
- /**
- * @var Type
- */
- protected $_type;
+ /** @var Type */
+ private $type;
protected function setUp()
{
- $this->_platform = new MockPlatform();
- $this->_type = Type::getType('string');
+ $this->platform = new MockPlatform();
+ $this->type = Type::getType('string');
}
public function testReturnsSqlDeclarationFromPlatformVarchar()
{
- self::assertEquals("DUMMYVARCHAR()", $this->_type->getSqlDeclaration(array(), $this->_platform));
+ self::assertEquals('DUMMYVARCHAR()', $this->type->getSqlDeclaration([], $this->platform));
}
public function testReturnsDefaultLengthFromPlatformVarchar()
{
- self::assertEquals(255, $this->_type->getDefaultLength($this->_platform));
+ self::assertEquals(255, $this->type->getDefaultLength($this->platform));
}
public function testConvertToPHPValue()
{
- self::assertInternalType("string", $this->_type->convertToPHPValue("foo", $this->_platform));
- self::assertInternalType("string", $this->_type->convertToPHPValue("", $this->_platform));
+ self::assertInternalType('string', $this->type->convertToPHPValue('foo', $this->platform));
+ self::assertInternalType('string', $this->type->convertToPHPValue('', $this->platform));
}
public function testNullConversion()
{
- self::assertNull($this->_type->convertToPHPValue(null, $this->_platform));
+ self::assertNull($this->type->convertToPHPValue(null, $this->platform));
}
public function testSQLConversion()
{
- self::assertFalse($this->_type->canRequireSQLConversion(), "String type can never require SQL conversion to work.");
- self::assertEquals('t.foo', $this->_type->convertToDatabaseValueSQL('t.foo', $this->_platform));
- self::assertEquals('t.foo', $this->_type->convertToPHPValueSQL('t.foo', $this->_platform));
+ self::assertFalse($this->type->canRequireSQLConversion(), 'String type can never require SQL conversion to work.');
+ self::assertEquals('t.foo', $this->type->convertToDatabaseValueSQL('t.foo', $this->platform));
+ self::assertEquals('t.foo', $this->type->convertToPHPValueSQL('t.foo', $this->platform));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php
index 78ae5917f77..0f7427df3ed 100644
--- a/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php
@@ -2,28 +2,28 @@
namespace Doctrine\Tests\DBAL\Types;
+use DateTime;
+use DateTimeImmutable;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\TimeImmutableType;
use Doctrine\DBAL\Types\Type;
+use PHPUnit\Framework\TestCase;
+use Prophecy\Prophecy\ObjectProphecy;
use function get_class;
-class TimeImmutableTypeTest extends \PHPUnit\Framework\TestCase
+class TimeImmutableTypeTest extends TestCase
{
- /**
- * @var \Doctrine\DBAL\Platforms\AbstractPlatform|\Prophecy\Prophecy\ObjectProphecy
- */
+ /** @var AbstractPlatform|ObjectProphecy */
private $platform;
- /**
- * @var TimeImmutableType
- */
+ /** @var TimeImmutableType */
private $type;
protected function setUp()
{
- $this->type = Type::getType('time_immutable');
+ $this->type = Type::getType('time_immutable');
$this->platform = $this->prophesize(AbstractPlatform::class);
}
@@ -44,7 +44,7 @@ public function testReturnsBindingType()
public function testConvertsDateTimeImmutableInstanceToDatabaseValue()
{
- $date = $this->prophesize(\DateTimeImmutable::class);
+ $date = $this->prophesize(DateTimeImmutable::class);
$this->platform->getTimeFormatString()->willReturn('H:i:s')->shouldBeCalled();
$date->format('H:i:s')->willReturn('15:58:59')->shouldBeCalled();
@@ -64,12 +64,12 @@ public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion()
{
$this->expectException(ConversionException::class);
- $this->type->convertToDatabaseValue(new \DateTime(), $this->platform->reveal());
+ $this->type->convertToDatabaseValue(new DateTime(), $this->platform->reveal());
}
public function testConvertsDateTimeImmutableInstanceToPHPValue()
{
- $date = new \DateTimeImmutable();
+ $date = new DateTimeImmutable();
self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform->reveal()));
}
@@ -85,7 +85,7 @@ public function testConvertsTimeStringToPHPValue()
$date = $this->type->convertToPHPValue('15:58:59', $this->platform->reveal());
- self::assertInstanceOf(\DateTimeImmutable::class, $date);
+ self::assertInstanceOf(DateTimeImmutable::class, $date);
self::assertSame('15:58:59', $date->format('H:i:s'));
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/TimeTest.php b/tests/Doctrine/Tests/DBAL/Types/TimeTest.php
index f55d50e7ad7..c2cd766b1c3 100644
--- a/tests/Doctrine/Tests/DBAL/Types/TimeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/TimeTest.php
@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Types;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
class TimeTest extends BaseDateTypeTestCase
@@ -31,7 +32,7 @@ public function testDateFieldResetInPHPValue()
public function testInvalidTimeFormatConversion()
{
- $this->expectException('Doctrine\DBAL\Types\ConversionException');
+ $this->expectException(ConversionException::class);
$this->type->convertToPHPValue('abcdefg', $this->platform);
}
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php
index ebf21284651..870bb23cc98 100644
--- a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php
@@ -2,22 +2,22 @@
namespace Doctrine\Tests\DBAL\Types;
+use DateTime;
+use DateTimeImmutable;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
-use Doctrine\DBAL\Types\VarDateTimeImmutableType;
use Doctrine\DBAL\Types\Type;
+use Doctrine\DBAL\Types\VarDateTimeImmutableType;
+use PHPUnit\Framework\TestCase;
+use Prophecy\Prophecy\ObjectProphecy;
-class VarDateTimeImmutableTypeTest extends \PHPUnit\Framework\TestCase
+class VarDateTimeImmutableTypeTest extends TestCase
{
- /**
- * @var \Doctrine\DBAL\Platforms\AbstractPlatform|\Prophecy\Prophecy\ObjectProphecy
- */
+ /** @var AbstractPlatform|ObjectProphecy */
private $platform;
- /**
- * @var VarDateTimeImmutableType
- */
+ /** @var VarDateTimeImmutableType */
private $type;
protected function setUp()
@@ -26,7 +26,7 @@ protected function setUp()
Type::addType('vardatetime_immutable', VarDateTimeImmutableType::class);
}
- $this->type = Type::getType('vardatetime_immutable');
+ $this->type = Type::getType('vardatetime_immutable');
$this->platform = $this->prophesize(AbstractPlatform::class);
}
@@ -42,7 +42,7 @@ public function testReturnsBindingType()
public function testConvertsDateTimeImmutableInstanceToDatabaseValue()
{
- $date = $this->prophesize(\DateTimeImmutable::class);
+ $date = $this->prophesize(DateTimeImmutable::class);
$this->platform->getDateTimeFormatString()->willReturn('Y-m-d H:i:s')->shouldBeCalled();
$date->format('Y-m-d H:i:s')->willReturn('2016-01-01 15:58:59')->shouldBeCalled();
@@ -62,12 +62,12 @@ public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion()
{
$this->expectException(ConversionException::class);
- $this->type->convertToDatabaseValue(new \DateTime(), $this->platform->reveal());
+ $this->type->convertToDatabaseValue(new DateTime(), $this->platform->reveal());
}
public function testConvertsDateTimeImmutableInstanceToPHPValue()
{
- $date = new \DateTimeImmutable();
+ $date = new DateTimeImmutable();
self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform->reveal()));
}
@@ -83,7 +83,7 @@ public function testConvertsDateishStringToPHPValue()
$date = $this->type->convertToPHPValue('2016-01-01 15:58:59.123456 UTC', $this->platform->reveal());
- self::assertInstanceOf(\DateTimeImmutable::class, $date);
+ self::assertInstanceOf(DateTimeImmutable::class, $date);
self::assertSame('2016-01-01 15:58:59.123456 UTC', $date->format('Y-m-d H:i:s.u T'));
}
diff --git a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php
index 4af76968cf1..2322aa474fe 100644
--- a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php
+++ b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php
@@ -2,36 +2,36 @@
namespace Doctrine\Tests\DBAL\Types;
+use DateTime;
+use Doctrine\DBAL\Types\ConversionException;
use Doctrine\DBAL\Types\Type;
+use Doctrine\DBAL\Types\VarDateTimeType;
use Doctrine\Tests\DBAL\Mocks\MockPlatform;
+use Doctrine\Tests\DbalTestCase;
-class VarDateTimeTest extends \Doctrine\Tests\DbalTestCase
+class VarDateTimeTest extends DbalTestCase
{
- /**
- * @var MockPlatform
- */
- protected $_platform;
+ /** @var MockPlatform */
+ private $platform;
- /**
- * @var Type
- */
- protected $_type;
+ /** @var Type */
+ private $type;
protected function setUp()
{
- $this->_platform = new MockPlatform();
- if (!Type::hasType('vardatetime')) {
- Type::addType('vardatetime', 'Doctrine\DBAL\Types\VarDateTimeType');
+ $this->platform = new MockPlatform();
+ if (! Type::hasType('vardatetime')) {
+ Type::addType('vardatetime', VarDateTimeType::class);
}
- $this->_type = Type::getType('vardatetime');
+ $this->type = Type::getType('vardatetime');
}
public function testDateTimeConvertsToDatabaseValue()
{
- $date = new \DateTime('1985-09-01 10:10:10');
+ $date = new DateTime('1985-09-01 10:10:10');
- $expected = $date->format($this->_platform->getDateTimeTzFormatString());
- $actual = $this->_type->convertToDatabaseValue($date, $this->_platform);
+ $expected = $date->format($this->platform->getDateTimeTzFormatString());
+ $actual = $this->type->convertToDatabaseValue($date, $this->platform);
self::assertEquals($expected, $actual);
}
@@ -39,7 +39,7 @@ public function testDateTimeConvertsToDatabaseValue()
public function testDateTimeConvertsToPHPValue()
{
// Birthday of jwage and also birthday of Doctrine. Send him a present ;)
- $date = $this->_type->convertToPHPValue('1985-09-01 00:00:00', $this->_platform);
+ $date = $this->type->convertToPHPValue('1985-09-01 00:00:00', $this->platform);
self::assertInstanceOf('DateTime', $date);
self::assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s'));
self::assertEquals('000000', $date->format('u'));
@@ -47,13 +47,13 @@ public function testDateTimeConvertsToPHPValue()
public function testInvalidDateTimeFormatConversion()
{
- $this->expectException('Doctrine\DBAL\Types\ConversionException');
- $this->_type->convertToPHPValue('abcdefg', $this->_platform);
+ $this->expectException(ConversionException::class);
+ $this->type->convertToPHPValue('abcdefg', $this->platform);
}
public function testConversionWithMicroseconds()
{
- $date = $this->_type->convertToPHPValue('1985-09-01 00:00:00.123456', $this->_platform);
+ $date = $this->type->convertToPHPValue('1985-09-01 00:00:00.123456', $this->platform);
self::assertInstanceOf('DateTime', $date);
self::assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s'));
self::assertEquals('123456', $date->format('u'));
@@ -61,12 +61,12 @@ public function testConversionWithMicroseconds()
public function testNullConversion()
{
- self::assertNull($this->_type->convertToPHPValue(null, $this->_platform));
+ self::assertNull($this->type->convertToPHPValue(null, $this->platform));
}
public function testConvertDateTimeToPHPValue()
{
- $date = new \DateTime("now");
- self::assertSame($date, $this->_type->convertToPHPValue($date, $this->_platform));
+ $date = new DateTime('now');
+ self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform));
}
}
diff --git a/tests/Doctrine/Tests/DBAL/UtilTest.php b/tests/Doctrine/Tests/DBAL/UtilTest.php
index ac26d8aa1dd..e7800fceba3 100644
--- a/tests/Doctrine/Tests/DBAL/UtilTest.php
+++ b/tests/Doctrine/Tests/DBAL/UtilTest.php
@@ -2,73 +2,77 @@
namespace Doctrine\Tests\DBAL;
-class UtilTest extends \Doctrine\Tests\DbalTestCase
+use Doctrine\DBAL\Driver\OCI8\OCI8Statement;
+use Doctrine\Tests\DbalTestCase;
+
+class UtilTest extends DbalTestCase
{
public static function dataConvertPositionalToNamedParameters()
{
- return array(
- array(
+ return [
+ [
'SELECT name FROM users WHERE id = ?',
'SELECT name FROM users WHERE id = :param1',
- array(1 => ':param1')
- ),
- array(
+ [1 => ':param1'],
+ ],
+ [
'SELECT name FROM users WHERE id = ? AND status = ?',
'SELECT name FROM users WHERE id = :param1 AND status = :param2',
- array(1 => ':param1', 2 => ':param2'),
- ),
- array(
+ [1 => ':param1', 2 => ':param2'],
+ ],
+ [
"UPDATE users SET name = '???', status = ?",
"UPDATE users SET name = '???', status = :param1",
- array(1 => ':param1'),
- ),
- array(
+ [1 => ':param1'],
+ ],
+ [
"UPDATE users SET status = ?, name = '???'",
"UPDATE users SET status = :param1, name = '???'",
- array(1 => ':param1'),
- ),
- array(
+ [1 => ':param1'],
+ ],
+ [
"UPDATE users SET foo = ?, name = '???', status = ?",
"UPDATE users SET foo = :param1, name = '???', status = :param2",
- array(1 => ':param1', 2 => ':param2'),
- ),
- array(
+ [1 => ':param1', 2 => ':param2'],
+ ],
+ [
'UPDATE users SET name = "???", status = ?',
'UPDATE users SET name = "???", status = :param1',
- array(1 => ':param1'),
- ),
- array(
+ [1 => ':param1'],
+ ],
+ [
'UPDATE users SET status = ?, name = "???"',
'UPDATE users SET status = :param1, name = "???"',
- array(1 => ':param1'),
- ),
- array(
+ [1 => ':param1'],
+ ],
+ [
'UPDATE users SET foo = ?, name = "???", status = ?',
'UPDATE users SET foo = :param1, name = "???", status = :param2',
- array(1 => ':param1', 2 => ':param2'),
- ),
- array(
+ [1 => ':param1', 2 => ':param2'],
+ ],
+ [
'SELECT * FROM users WHERE id = ? AND name = "" AND status = ?',
'SELECT * FROM users WHERE id = :param1 AND name = "" AND status = :param2',
- array(1 => ':param1', 2 => ':param2'),
- ),
- array(
+ [1 => ':param1', 2 => ':param2'],
+ ],
+ [
"SELECT * FROM users WHERE id = ? AND name = '' AND status = ?",
"SELECT * FROM users WHERE id = :param1 AND name = '' AND status = :param2",
- array(1 => ':param1', 2 => ':param2'),
- )
- );
+ [1 => ':param1', 2 => ':param2'],
+ ],
+ ];
}
/**
+ * @param string $inputSQL
+ * @param string $expectedOutputSQL
+ * @param mixed[] $expectedOutputParamsMap
+ *
* @dataProvider dataConvertPositionalToNamedParameters
- * @param string $inputSQL
- * @param string $expectedOutputSQL
- * @param array $expectedOutputParamsMap
*/
public function testConvertPositionalToNamedParameters($inputSQL, $expectedOutputSQL, $expectedOutputParamsMap)
{
- list($statement, $params) = \Doctrine\DBAL\Driver\OCI8\OCI8Statement::convertPositionalToNamedPlaceholders($inputSQL);
+ [$statement, $params] = OCI8Statement::convertPositionalToNamedPlaceholders($inputSQL);
self::assertEquals($expectedOutputSQL, $statement);
self::assertEquals($expectedOutputParamsMap, $params);
diff --git a/tests/Doctrine/Tests/DbalFunctionalTestCase.php b/tests/Doctrine/Tests/DbalFunctionalTestCase.php
index 17154eac9f6..77cfd8d6900 100644
--- a/tests/Doctrine/Tests/DbalFunctionalTestCase.php
+++ b/tests/Doctrine/Tests/DbalFunctionalTestCase.php
@@ -1,6 +1,12 @@
close();
- self::$_sharedConn = null;
+ if (! self::$sharedConnection) {
+ return;
}
+
+ self::$sharedConnection->close();
+ self::$sharedConnection = null;
}
protected function setUp()
{
- if ( ! isset(self::$_sharedConn)) {
- self::$_sharedConn = TestUtil::getConnection();
+ if (! isset(self::$sharedConnection)) {
+ self::$sharedConnection = TestUtil::getConnection();
}
- $this->_conn = self::$_sharedConn;
+ $this->connection = self::$sharedConnection;
- $this->_sqlLoggerStack = new \Doctrine\DBAL\Logging\DebugStack();
- $this->_conn->getConfiguration()->setSQLLogger($this->_sqlLoggerStack);
+ $this->sqlLoggerStack = new DebugStack();
+ $this->connection->getConfiguration()->setSQLLogger($this->sqlLoggerStack);
}
protected function tearDown()
{
- while ($this->_conn->isTransactionActive()) {
- $this->_conn->rollBack();
+ while ($this->connection->isTransactionActive()) {
+ $this->connection->rollBack();
}
}
- protected function onNotSuccessfulTest(\Throwable $t)
+ protected function onNotSuccessfulTest(Throwable $t)
{
- if ($t instanceof \PHPUnit\Framework\AssertionFailedError) {
+ if ($t instanceof AssertionFailedError) {
throw $t;
}
- if(isset($this->_sqlLoggerStack->queries) && count($this->_sqlLoggerStack->queries)) {
- $queries = "";
- $i = count($this->_sqlLoggerStack->queries);
- foreach (array_reverse($this->_sqlLoggerStack->queries) as $query) {
- $params = array_map(function($p) {
+ if (isset($this->sqlLoggerStack->queries) && count($this->sqlLoggerStack->queries)) {
+ $queries = '';
+ $i = count($this->sqlLoggerStack->queries);
+ foreach (array_reverse($this->sqlLoggerStack->queries) as $query) {
+ $params = array_map(static function ($p) {
if (is_object($p)) {
return get_class($p);
} elseif (is_scalar($p)) {
- return "'".$p."'";
+ return "'" . $p . "'";
}
return var_export($p, true);
- }, $query['params'] ?: array());
- $queries .= $i.". SQL: '".$query['sql']."' Params: ".implode(", ", $params).PHP_EOL;
+ }, $query['params'] ?: []);
+ $queries .= $i . ". SQL: '" . $query['sql'] . "' Params: " . implode(', ', $params) . PHP_EOL;
$i--;
}
- $trace = $t->getTrace();
- $traceMsg = "";
- foreach($trace as $part) {
- if(isset($part['file'])) {
- if(strpos($part['file'], "PHPUnit/") !== false) {
- // Beginning with PHPUnit files we don't print the trace anymore.
- break;
- }
+ $trace = $t->getTrace();
+ $traceMsg = '';
+ foreach ($trace as $part) {
+ if (! isset($part['file'])) {
+ continue;
+ }
- $traceMsg .= $part['file'].":".$part['line'].PHP_EOL;
+ if (strpos($part['file'], 'PHPUnit/') !== false) {
+ // Beginning with PHPUnit files we don't print the trace anymore.
+ break;
}
+
+ $traceMsg .= $part['file'] . ':' . $part['line'] . PHP_EOL;
}
- $message = "[".get_class($t)."] ".$t->getMessage().PHP_EOL.PHP_EOL."With queries:".PHP_EOL.$queries.PHP_EOL."Trace:".PHP_EOL.$traceMsg;
+ $message = '[' . get_class($t) . '] ' . $t->getMessage() . PHP_EOL . PHP_EOL . 'With queries:' . PHP_EOL . $queries . PHP_EOL . 'Trace:' . PHP_EOL . $traceMsg;
- throw new \Exception($message, (int) $t->getCode(), $t);
+ throw new Exception($message, (int) $t->getCode(), $t);
}
throw $t;
}
diff --git a/tests/Doctrine/Tests/DbalPerformanceTestCase.php b/tests/Doctrine/Tests/DbalPerformanceTestCase.php
index 0422e5aa987..bfc60201bef 100644
--- a/tests/Doctrine/Tests/DbalPerformanceTestCase.php
+++ b/tests/Doctrine/Tests/DbalPerformanceTestCase.php
@@ -1,17 +1,15 @@
startTime, "Test timing was started");
- self::assertNotNull($this->runTime, "Test timing was stopped");
+ self::assertNotNull($this->startTime, 'Test timing was started');
+ self::assertNotNull($this->runTime, 'Test timing was stopped');
}
/**
diff --git a/tests/Doctrine/Tests/DbalPerformanceTestListener.php b/tests/Doctrine/Tests/DbalPerformanceTestListener.php
index 46085829434..e9265c0f35f 100644
--- a/tests/Doctrine/Tests/DbalPerformanceTestListener.php
+++ b/tests/Doctrine/Tests/DbalPerformanceTestListener.php
@@ -11,15 +11,12 @@
/**
* Listener for collecting and reporting results of performance tests
- *
- * @author Bill Schaller
*/
class DbalPerformanceTestListener implements TestListener
{
use TestListenerDefaultImplementation;
- /**
- * @var string[][]
- */
+
+ /** @var string[][] */
private $timings = [];
/**
@@ -28,18 +25,19 @@ class DbalPerformanceTestListener implements TestListener
public function endTest(Test $test, float $time) : void
{
// This listener only applies to performance tests.
- if ($test instanceof \Doctrine\Tests\DbalPerformanceTestCase)
- {
- // we identify perf tests by class, method, and dataset
- $class = str_replace('Doctrine\Tests\DBAL\Performance\\', '', get_class($test));
+ if (! ($test instanceof DbalPerformanceTestCase)) {
+ return;
+ }
- if (!isset($this->timings[$class])) {
- $this->timings[$class] = [];
- }
+ // we identify perf tests by class, method, and dataset
+ $class = str_replace('\\Doctrine\\Tests\\DBAL\\Performance\\', '', get_class($test));
- // Store timing data for each test in the order they were run.
- $this->timings[$class][$test->getName(true)] = $test->getTime();
+ if (! isset($this->timings[$class])) {
+ $this->timings[$class] = [];
}
+
+ // Store timing data for each test in the order they were run.
+ $this->timings[$class][$test->getName(true)] = $test->getTime();
}
/**
@@ -50,15 +48,17 @@ public function endTest(Test $test, float $time) : void
*/
public function __destruct()
{
- if (!empty($this->timings)) {
- // Report timings.
- print("\nPerformance test results:\n\n");
+ if (empty($this->timings)) {
+ return;
+ }
+
+ // Report timings.
+ print "\nPerformance test results:\n\n";
- foreach($this->timings as $class => $tests) {
- printf("%s:\n", $class);
- foreach($tests as $test => $time) {
- printf("\t%s: %.3f seconds\n", $test, $time);
- }
+ foreach ($this->timings as $class => $tests) {
+ printf("%s:\n", $class);
+ foreach ($tests as $test => $time) {
+ printf("\t%s: %.3f seconds\n", $test, $time);
}
}
}
diff --git a/tests/Doctrine/Tests/DbalTestCase.php b/tests/Doctrine/Tests/DbalTestCase.php
index b577893e6f1..8664141c03e 100644
--- a/tests/Doctrine/Tests/DbalTestCase.php
+++ b/tests/Doctrine/Tests/DbalTestCase.php
@@ -2,9 +2,11 @@
namespace Doctrine\Tests;
+use PHPUnit\Framework\TestCase;
+
/**
* Base testcase class for all dbal testcases.
*/
-abstract class DbalTestCase extends \PHPUnit\Framework\TestCase
+abstract class DbalTestCase extends TestCase
{
}
diff --git a/tests/Doctrine/Tests/Mocks/ConnectionMock.php b/tests/Doctrine/Tests/Mocks/ConnectionMock.php
index fb5dcc47b4d..157584f09f7 100644
--- a/tests/Doctrine/Tests/Mocks/ConnectionMock.php
+++ b/tests/Doctrine/Tests/Mocks/ConnectionMock.php
@@ -1,59 +1,49 @@
_platformMock = new DatabasePlatformMock();
+ $this->platformMock = new DatabasePlatformMock();
parent::__construct($params, $driver, $config, $eventManager);
}
- /**
- * @override
- */
public function getDatabasePlatform()
{
- return $this->_platformMock;
+ return $this->platformMock;
}
/**
- * @override
+ * {@inheritDoc}
*/
- public function insert($tableName, array $data, array $types = array())
+ public function insert($tableName, array $data, array $types = [])
{
- $this->_inserts[$tableName][] = $data;
+ $this->inserts[$tableName][] = $data;
}
- /**
- * @override
- */
public function lastInsertId($seqName = null)
{
- return $this->_lastInsertId;
+ return $this->lastInsertId;
}
- /**
- * @override
- */
public function quote($input, $type = null)
{
if (is_string($input)) {
@@ -64,17 +54,17 @@ public function quote($input, $type = null)
public function setLastInsertId($id)
{
- $this->_lastInsertId = $id;
+ $this->lastInsertId = $id;
}
public function getInserts()
{
- return $this->_inserts;
+ return $this->inserts;
}
public function reset()
{
- $this->_inserts = array();
- $this->_lastInsertId = 0;
+ $this->inserts = [];
+ $this->lastInsertId = 0;
}
}
diff --git a/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php b/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php
index 021746831af..690809e308a 100644
--- a/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php
+++ b/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php
@@ -3,96 +3,116 @@
namespace Doctrine\Tests\Mocks;
use Doctrine\DBAL\DBALException;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
-class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
+class DatabasePlatformMock extends AbstractPlatform
{
+ /** @var string */
+ private $sequenceNextValSql = '';
+
+ /** @var bool */
+ private $prefersIdentityColumns = true;
+
+ /** @var bool */
+ private $prefersSequences = false;
+
+ public function prefersIdentityColumns()
+ {
+ return $this->prefersIdentityColumns;
+ }
+
+ public function prefersSequences()
+ {
+ return $this->prefersSequences;
+ }
+
+ public function getSequenceNextValSQL($sequenceName)
+ {
+ return $this->sequenceNextValSql;
+ }
+
/**
- * @var string
+ * {@inheritDoc}
*/
- private $_sequenceNextValSql = "";
+ public function getBooleanTypeDeclarationSQL(array $field)
+ {
+ }
/**
- * @var bool
+ * {@inheritDoc}
*/
- private $_prefersIdentityColumns = true;
+ public function getIntegerTypeDeclarationSQL(array $field)
+ {
+ }
/**
- * @var bool
+ * {@inheritDoc}
*/
- private $_prefersSequences = false;
+ public function getBigIntTypeDeclarationSQL(array $field)
+ {
+ }
/**
- * @override
+ * {@inheritDoc}
*/
- public function prefersIdentityColumns()
+ public function getSmallIntTypeDeclarationSQL(array $field)
{
- return $this->_prefersIdentityColumns;
}
/**
- * @override
+ * {@inheritDoc}
*/
- public function prefersSequences()
+ protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
{
- return $this->_prefersSequences;
}
- /** @override */
- public function getSequenceNextValSQL($sequenceName)
+ /**
+ * {@inheritDoc}
+ */
+ public function getVarcharTypeDeclarationSQL(array $field)
{
- return $this->_sequenceNextValSql;
}
- /** @override */
- public function getBooleanTypeDeclarationSQL(array $field) {}
-
- /** @override */
- public function getIntegerTypeDeclarationSQL(array $field) {}
-
- /** @override */
- public function getBigIntTypeDeclarationSQL(array $field) {}
-
- /** @override */
- public function getSmallIntTypeDeclarationSQL(array $field) {}
-
- /** @override */
- protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef) {}
-
- /** @override */
- public function getVarcharTypeDeclarationSQL(array $field) {}
-
- /** @override */
- public function getClobTypeDeclarationSQL(array $field) {}
+ /**
+ * {@inheritDoc}
+ */
+ public function getClobTypeDeclarationSQL(array $field)
+ {
+ }
/* MOCK API */
- public function setPrefersIdentityColumns($bool)
+ /**
+ * @param bool $prefersIdentityColumns
+ */
+ public function setPrefersIdentityColumns($prefersIdentityColumns)
{
- $this->_prefersIdentityColumns = $bool;
+ $this->prefersIdentityColumns = $prefersIdentityColumns;
}
public function setPrefersSequences($bool)
{
- $this->_prefersSequences = $bool;
+ $this->prefersSequences = $bool;
}
public function setSequenceNextValSql($sql)
{
- $this->_sequenceNextValSql = $sql;
+ $this->sequenceNextValSql = $sql;
}
public function getName()
{
return 'mock';
}
- protected function initializeDoctrineTypeMappings() {
+ protected function initializeDoctrineTypeMappings()
+ {
}
protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed)
{
-
}
+
/**
- * Gets the SQL Snippet used to declare a BLOB column type.
+ * {@inheritDoc}
*/
public function getBlobTypeDeclarationSQL(array $field)
{
diff --git a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php b/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php
index 760dbff40cf..7b8872f2ea8 100644
--- a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php
+++ b/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php
@@ -2,22 +2,41 @@
namespace Doctrine\Tests\Mocks;
+use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\ParameterType;
-class DriverConnectionMock implements \Doctrine\DBAL\Driver\Connection
+class DriverConnectionMock implements Connection
{
- public function prepare($prepareString) {}
- public function query() {}
+ public function prepare($prepareString)
+ {
+ }
+ public function query()
+ {
+ }
public function quote($input, $type = ParameterType::STRING)
{
}
- public function exec($statement) {}
- public function lastInsertId($name = null) {}
- public function beginTransaction() {}
- public function commit() {}
- public function rollBack() {}
- public function errorCode() {}
- public function errorInfo() {}
+ public function exec($statement)
+ {
+ }
+ public function lastInsertId($name = null)
+ {
+ }
+ public function beginTransaction()
+ {
+ }
+ public function commit()
+ {
+ }
+ public function rollBack()
+ {
+ }
+ public function errorCode()
+ {
+ }
+ public function errorInfo()
+ {
+ }
}
diff --git a/tests/Doctrine/Tests/Mocks/DriverMock.php b/tests/Doctrine/Tests/Mocks/DriverMock.php
index 61b2d992aff..9b5f4245472 100644
--- a/tests/Doctrine/Tests/Mocks/DriverMock.php
+++ b/tests/Doctrine/Tests/Mocks/DriverMock.php
@@ -2,69 +2,53 @@
namespace Doctrine\Tests\Mocks;
+use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Driver;
+use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
+use Throwable;
-class DriverMock implements \Doctrine\DBAL\Driver
+class DriverMock implements Driver
{
- /**
- * @var DatabasePlatformMock
- */
- private $_platformMock;
+ /** @var DatabasePlatformMock */
+ private $platformMock;
- /**
- * @var AbstractSchemaManager
- */
- private $_schemaManagerMock;
-
- public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
- {
- return new DriverConnectionMock();
- }
+ /** @var AbstractSchemaManager */
+ private $schemaManagerMock;
/**
- * Constructs the Sqlite PDO DSN.
- *
- * @return string The DSN.
- * @override
+ * {@inheritDoc}
*/
- protected function _constructPdoDsn(array $params)
+ public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
{
- return "";
+ return new DriverConnectionMock();
}
- /**
- * @override
- */
public function getDatabasePlatform()
{
- if ( ! $this->_platformMock) {
- $this->_platformMock = new DatabasePlatformMock;
+ if (! $this->platformMock) {
+ $this->platformMock = new DatabasePlatformMock();
}
- return $this->_platformMock;
+ return $this->platformMock;
}
- /**
- * @override
- */
- public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
+ public function getSchemaManager(Connection $conn)
{
- if($this->_schemaManagerMock == null) {
+ if ($this->schemaManagerMock === null) {
return new SchemaManagerMock($conn);
}
- return $this->_schemaManagerMock;
+ return $this->schemaManagerMock;
}
- /* MOCK API */
-
- public function setDatabasePlatform(\Doctrine\DBAL\Platforms\AbstractPlatform $platform)
+ public function setDatabasePlatform(AbstractPlatform $platform)
{
- $this->_platformMock = $platform;
+ $this->platformMock = $platform;
}
public function setSchemaManager(AbstractSchemaManager $sm)
{
- $this->_schemaManagerMock = $sm;
+ $this->schemaManagerMock = $sm;
}
public function getName()
@@ -72,12 +56,12 @@ public function getName()
return 'mock';
}
- public function getDatabase(\Doctrine\DBAL\Connection $conn)
+ public function getDatabase(Connection $conn)
{
return;
}
- public function convertExceptionCode(\Exception $exception)
+ public function convertExceptionCode(Throwable $exception)
{
return 0;
}
diff --git a/tests/Doctrine/Tests/Mocks/DriverResultStatementMock.php b/tests/Doctrine/Tests/Mocks/DriverResultStatementMock.php
index 04c085c7459..46573c39494 100644
--- a/tests/Doctrine/Tests/Mocks/DriverResultStatementMock.php
+++ b/tests/Doctrine/Tests/Mocks/DriverResultStatementMock.php
@@ -3,7 +3,8 @@
namespace Doctrine\Tests\Mocks;
use Doctrine\DBAL\Driver\ResultStatement;
+use IteratorAggregate;
-interface DriverResultStatementMock extends ResultStatement, \IteratorAggregate
+interface DriverResultStatementMock extends ResultStatement, IteratorAggregate
{
}
diff --git a/tests/Doctrine/Tests/Mocks/DriverStatementMock.php b/tests/Doctrine/Tests/Mocks/DriverStatementMock.php
index 62f09464c0f..5c14d6962e2 100644
--- a/tests/Doctrine/Tests/Mocks/DriverStatementMock.php
+++ b/tests/Doctrine/Tests/Mocks/DriverStatementMock.php
@@ -3,7 +3,8 @@
namespace Doctrine\Tests\Mocks;
use Doctrine\DBAL\Driver\Statement;
+use IteratorAggregate;
-interface DriverStatementMock extends Statement, \IteratorAggregate
+interface DriverStatementMock extends Statement, IteratorAggregate
{
}
diff --git a/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php b/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php
index d4c3c28c004..6eccd68609e 100644
--- a/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php
+++ b/tests/Doctrine/Tests/Mocks/SchemaManagerMock.php
@@ -2,12 +2,17 @@
namespace Doctrine\Tests\Mocks;
-class SchemaManagerMock extends \Doctrine\DBAL\Schema\AbstractSchemaManager
+use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\Schema\AbstractSchemaManager;
+
+class SchemaManagerMock extends AbstractSchemaManager
{
- public function __construct(\Doctrine\DBAL\Connection $conn)
+ public function __construct(Connection $conn)
{
parent::__construct($conn);
}
- protected function _getPortableTableColumnDefinition($tableColumn) {}
-}
\ No newline at end of file
+ protected function _getPortableTableColumnDefinition($tableColumn)
+ {
+ }
+}
diff --git a/tests/Doctrine/Tests/Mocks/TaskMock.php b/tests/Doctrine/Tests/Mocks/TaskMock.php
deleted file mode 100644
index 4502703d9ac..00000000000
--- a/tests/Doctrine/Tests/Mocks/TaskMock.php
+++ /dev/null
@@ -1,84 +0,0 @@
-.
- */
-
-namespace Doctrine\Tests\Mocks;
-
-use Doctrine\Common\Cli\AbstractNamespace;
-
-/**
- * TaskMock used for testing the CLI interface.
- * @author Nils Adermann
- */
-class TaskMock extends \Doctrine\Common\Cli\Tasks\AbstractTask
-{
- /**
- * Since instances of this class can be created elsewhere all instances
- * register themselves in this array for later inspection.
- *
- * @var array(TaskMock)
- */
- static public $instances = array();
-
- /**
- * @var int
- */
- private $runCounter = 0;
-
- /**
- * Constructor of Task Mock Object.
- * Makes sure the object can be inspected later.
- *
- * @param AbstractNamespace CLI Namespace, passed to parent constructor
- */
- function __construct(AbstractNamespace $namespace)
- {
- self::$instances[] = $this;
-
- parent::__construct($namespace);
- }
-
- /**
- * Returns the number of times run() was called on this object.
- *
- * @return int
- */
- public function getRunCounter()
- {
- return $this->runCounter;
- }
-
- /* Mock API */
-
- /**
- * Method invoked by CLI to run task.
- */
- public function run()
- {
- $this->runCounter++;
- }
-
- /**
- * Method supposed to generate the CLI Task Documentation
- */
- public function buildDocumentation()
- {
- }
-}
diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Doctrine/Tests/TestUtil.php
index be90e6c8ae8..37553595490 100644
--- a/tests/Doctrine/Tests/TestUtil.php
+++ b/tests/Doctrine/Tests/TestUtil.php
@@ -11,14 +11,10 @@
/**
* TestUtil is a class with static utility methods used during tests.
- *
- * @author robo
*/
class TestUtil
{
- /**
- * @var bool Whether the database schema is initialized.
- */
+ /** @var bool Whether the database schema is initialized. */
private static $initialized = false;
/**
@@ -51,7 +47,8 @@ public static function getConnection()
return $conn;
}
- private static function getConnectionParams() {
+ private static function getConnectionParams()
+ {
if (self::hasRequiredConnectionParams()) {
return self::getSpecifiedConnectionParams();
}
@@ -78,16 +75,17 @@ private static function hasRequiredConnectionParams()
);
}
- private static function getSpecifiedConnectionParams() {
+ private static function getSpecifiedConnectionParams()
+ {
$realDbParams = self::getParamsForMainConnection();
- $tmpDbParams = self::getParamsForTemporaryConnection();
+ $tmpDbParams = self::getParamsForTemporaryConnection();
$realConn = DriverManager::getConnection($realDbParams);
// Connect to tmpdb in order to drop and create the real test db.
$tmpConn = DriverManager::getConnection($tmpDbParams);
- $platform = $tmpConn->getDatabasePlatform();
+ $platform = $tmpConn->getDatabasePlatform();
if (! self::$initialized) {
if ($platform->supportsCreateDropDatabase()) {
@@ -101,7 +99,7 @@ private static function getSpecifiedConnectionParams() {
$sm = $realConn->getSchemaManager();
$schema = $sm->createSchema();
- $stmts = $schema->toDropSql($realConn->getDatabasePlatform());
+ $stmts = $schema->toDropSql($realConn->getDatabasePlatform());
foreach ($stmts as $stmt) {
$realConn->exec($stmt);
@@ -120,10 +118,10 @@ private static function getFallbackConnectionParams()
Assert::markTestSkipped('PDO SQLite extension is not loaded');
}
- $params = array(
+ $params = [
'driver' => 'pdo_sqlite',
- 'memory' => true
- );
+ 'memory' => true,
+ ];
if (isset($GLOBALS['db_path'])) {
$params['path'] = $GLOBALS['db_path'];
@@ -133,26 +131,29 @@ private static function getFallbackConnectionParams()
return $params;
}
- private static function addDbEventSubscribers(Connection $conn) {
- if (isset($GLOBALS['db_event_subscribers'])) {
- $evm = $conn->getEventManager();
- foreach (explode(",", $GLOBALS['db_event_subscribers']) as $subscriberClass) {
- $subscriberInstance = new $subscriberClass();
- $evm->addEventSubscriber($subscriberInstance);
- }
+ private static function addDbEventSubscribers(Connection $conn)
+ {
+ if (! isset($GLOBALS['db_event_subscribers'])) {
+ return;
+ }
+
+ $evm = $conn->getEventManager();
+ foreach (explode(',', $GLOBALS['db_event_subscribers']) as $subscriberClass) {
+ $subscriberInstance = new $subscriberClass();
+ $evm->addEventSubscriber($subscriberInstance);
}
}
private static function getParamsForTemporaryConnection()
{
- $connectionParams = array(
+ $connectionParams = [
'driver' => $GLOBALS['tmpdb_type'],
'user' => $GLOBALS['tmpdb_username'],
'password' => $GLOBALS['tmpdb_password'],
'host' => $GLOBALS['tmpdb_host'],
'dbname' => null,
- 'port' => $GLOBALS['tmpdb_port']
- );
+ 'port' => $GLOBALS['tmpdb_port'],
+ ];
if (isset($GLOBALS['tmpdb_name'])) {
$connectionParams['dbname'] = $GLOBALS['tmpdb_name'];
@@ -171,14 +172,14 @@ private static function getParamsForTemporaryConnection()
private static function getParamsForMainConnection()
{
- $connectionParams = array(
+ $connectionParams = [
'driver' => $GLOBALS['db_type'],
'user' => $GLOBALS['db_username'],
'password' => $GLOBALS['db_password'],
'host' => $GLOBALS['db_host'],
'dbname' => $GLOBALS['db_name'],
- 'port' => $GLOBALS['db_port']
- );
+ 'port' => $GLOBALS['db_port'],
+ ];
if (isset($GLOBALS['db_server'])) {
$connectionParams['server'] = $GLOBALS['db_server'];
diff --git a/tests/Doctrine/Tests/Types/CommentedType.php b/tests/Doctrine/Tests/Types/CommentedType.php
index f5c1fdb1b27..cbe98b2324b 100644
--- a/tests/Doctrine/Tests/Types/CommentedType.php
+++ b/tests/Doctrine/Tests/Types/CommentedType.php
@@ -8,16 +8,25 @@
class CommentedType extends Type
{
+ /**
+ * {@inheritDoc}
+ */
public function getName()
{
return 'my_commented';
}
+ /**
+ * {@inheritDoc}
+ */
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return strtoupper($this->getName());
}
+ /**
+ * {@inheritDoc}
+ */
public function requiresSQLCommentHint(AbstractPlatform $platform)
{
return true;
diff --git a/tests/Doctrine/Tests/Types/MySqlPointType.php b/tests/Doctrine/Tests/Types/MySqlPointType.php
index d325cb272d6..f4740769b8b 100644
--- a/tests/Doctrine/Tests/Types/MySqlPointType.php
+++ b/tests/Doctrine/Tests/Types/MySqlPointType.php
@@ -8,18 +8,27 @@
class MySqlPointType extends Type
{
+ /**
+ * {@inheritDoc}
+ */
public function getName()
{
return 'point';
}
+ /**
+ * {@inheritDoc}
+ */
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return strtoupper($this->getName());
}
+ /**
+ * {@inheritDoc}
+ */
public function getMappedDatabaseTypes(AbstractPlatform $platform)
{
- return array('point');
+ return ['point'];
}
}
diff --git a/tests/continuousphp/bootstrap.php b/tests/continuousphp/bootstrap.php
index feaa1887e6a..cfdfb40eb1a 100644
--- a/tests/continuousphp/bootstrap.php
+++ b/tests/continuousphp/bootstrap.php
@@ -2,7 +2,7 @@
declare(strict_types=1);
-(function () : void {
+(static function () : void {
$pos = array_search('--coverage-clover', $_SERVER['argv'], true);
if ($pos === false) {
@@ -11,7 +11,7 @@
$file = $_SERVER['argv'][$pos + 1];
- register_shutdown_function(function () use ($file) : void {
+ register_shutdown_function(static function () use ($file) : void {
$cmd = 'wget https://github.com/scrutinizer-ci/ocular/releases/download/1.5.2/ocular.phar'
. ' && php ocular.phar code-coverage:upload --format=php-clover ' . escapeshellarg($file);
diff --git a/tests/phpstan-polyfill.php b/tests/phpstan-polyfill.php
index 13b5aa1e185..f27e09de3a0 100644
--- a/tests/phpstan-polyfill.php
+++ b/tests/phpstan-polyfill.php
@@ -2,7 +2,7 @@
declare(strict_types=1);
-(function () : void {
+(static function () : void {
foreach (['ibm_db2', 'mysqli', 'oci8', 'sqlsrv', 'pgsql'] as $extension) {
if (extension_loaded($extension)) {
continue;