diff --git a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php index 851f973e66e..8310ea15c66 100644 --- a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php +++ b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\DBAL; diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php index dfb908f40f4..52e95cfc528 100644 --- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php @@ -12,6 +12,8 @@ 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; @@ -21,6 +23,7 @@ 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; @@ -35,7 +38,7 @@ class ConnectionTest extends DbalTestCase { /** @var Connection */ - protected $_conn = null; + private $connection; /** @var string[] */ protected $params = [ @@ -48,7 +51,7 @@ class ConnectionTest extends DbalTestCase protected function setUp() { - $this->_conn = \Doctrine\DBAL\DriverManager::getConnection($this->params); + $this->connection = DriverManager::getConnection($this->params); } public function getExecuteUpdateMockConnection() @@ -69,73 +72,73 @@ public function getExecuteUpdateMockConnection() 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() @@ -148,7 +151,7 @@ public function testConnectDispatchEvent() $eventManager = new EventManager(); $eventManager->addEventListener([Events::postConnect], $listenerMock); - $driverMock = $this->createMock('Doctrine\DBAL\Driver'); + $driverMock = $this->createMock(Driver::class); $driverMock->expects($this->at(0)) ->method('connect'); $platform = new Mocks\MockPlatform(); @@ -161,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()); } @@ -175,12 +178,12 @@ 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() @@ -202,8 +205,8 @@ public function getQueryMethods() public function testEchoSQLLogger() { $logger = new EchoSQLLogger(); - $this->_conn->getConfiguration()->setSQLLogger($logger); - self::assertSame($logger, $this->_conn->getConfiguration()->getSQLLogger()); + $this->connection->getConfiguration()->setSQLLogger($logger); + self::assertSame($logger, $this->connection->getConfiguration()->getSQLLogger()); } /** @@ -214,8 +217,8 @@ public function testEchoSQLLogger() public function testDebugSQLStack() { $logger = new DebugStack(); - $this->_conn->getConfiguration()->setSQLLogger($logger); - self::assertSame($logger, $this->_conn->getConfiguration()->getSQLLogger()); + $this->connection->getConfiguration()->setSQLLogger($logger); + self::assertSame($logger, $this->connection->getConfiguration()->getSQLLogger()); } /** @@ -223,7 +226,7 @@ public function testDebugSQLStack() */ public function testIsAutoCommit() { - self::assertTrue($this->_conn->isAutoCommit()); + self::assertTrue($this->connection->isAutoCommit()); } /** @@ -231,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()); } /** @@ -242,7 +245,7 @@ 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( @@ -264,7 +267,7 @@ 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( @@ -284,7 +287,7 @@ 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( @@ -304,7 +307,7 @@ 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( @@ -501,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') @@ -509,7 +512,7 @@ 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') @@ -517,7 +520,7 @@ public function testFetchAssoc() ->will($this->returnValue($result)); /** @var PHPUnit_Framework_MockObject_MockObject|Connection $conn */ - $conn = $this->getMockBuilder('Doctrine\DBAL\Connection') + $conn = $this->getMockBuilder(Connection::class) ->setMethods(['executeQuery']) ->setConstructorArgs([['platform' => new Mocks\MockPlatform()], $driverMock]) ->getMock(); @@ -537,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') @@ -545,7 +548,7 @@ 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') @@ -553,7 +556,7 @@ public function testFetchArray() ->will($this->returnValue($result)); /** @var PHPUnit_Framework_MockObject_MockObject|Connection $conn */ - $conn = $this->getMockBuilder('Doctrine\DBAL\Connection') + $conn = $this->getMockBuilder(Connection::class) ->setMethods(['executeQuery']) ->setConstructorArgs([['platform' => new Mocks\MockPlatform()], $driverMock]) ->getMock(); @@ -574,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') @@ -582,7 +585,7 @@ 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') @@ -590,7 +593,7 @@ public function testFetchColumn() ->will($this->returnValue($result)); /** @var PHPUnit_Framework_MockObject_MockObject|Connection $conn */ - $conn = $this->getMockBuilder('Doctrine\DBAL\Connection') + $conn = $this->getMockBuilder(Connection::class) ->setMethods(['executeQuery']) ->setConstructorArgs([['platform' => new Mocks\MockPlatform()], $driverMock]) ->getMock(); @@ -606,7 +609,7 @@ 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(['connect']) ->getMock(); @@ -633,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') @@ -641,14 +644,14 @@ 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|Connection $conn */ - $conn = $this->getMockBuilder('Doctrine\DBAL\Connection') + $conn = $this->getMockBuilder(Connection::class) ->setMethods(['executeQuery']) ->setConstructorArgs([['platform' => new Mocks\MockPlatform()], $driverMock]) ->getMock(); @@ -665,7 +668,7 @@ public function testConnectionDoesNotMaintainTwoReferencesToExternalPDO() { $params['pdo'] = new stdClass(); - $driverMock = $this->createMock('Doctrine\DBAL\Driver'); + $driverMock = $this->createMock(Driver::class); $conn = new Connection($params, $driverMock); @@ -676,7 +679,7 @@ public function testPassingExternalPDOMeansConnectionIsConnected() { $params['pdo'] = new stdClass(); - $driverMock = $this->createMock('Doctrine\DBAL\Driver'); + $driverMock = $this->createMock(Driver::class); $conn = new Connection($params, $driverMock); @@ -686,8 +689,8 @@ public function testPassingExternalPDOMeansConnectionIsConnected() public function testCallingDeleteWithNoDeletionCriteriaResultsInInvalidArgumentException() { /** @var Driver $driver */ - $driver = $this->createMock('Doctrine\DBAL\Driver'); - $pdoMock = $this->createMock('Doctrine\DBAL\Driver\Connection'); + $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'); @@ -715,16 +718,16 @@ 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') + $conn = $this->getMockBuilder(Connection::class) ->setConstructorArgs([['pdo' => $pdoMock, 'platform' => $platformMock], $driverMock]) ->setMethods(['connect']) ->getMock(); @@ -740,13 +743,13 @@ public function testCallConnectOnce($method, $params) public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform() { /** @var VersionAwarePlatformDriverMock|PHPUnit_Framework_MockObject_MockObject $driverMock */ - $driverMock = $this->createMock('Doctrine\Tests\Mocks\VersionAwarePlatformDriverMock'); + $driverMock = $this->createMock(VersionAwarePlatformDriverMock::class); /** @var ServerInfoAwareConnectionMock|PHPUnit_Framework_MockObject_MockObject $driverConnectionMock */ - $driverConnectionMock = $this->createMock('Doctrine\Tests\Mocks\ServerInfoAwareConnectionMock'); + $driverConnectionMock = $this->createMock(ServerInfoAwareConnectionMock::class); /** @var AbstractPlatform|PHPUnit_Framework_MockObject_MockObject $platformMock */ - $platformMock = $this->getMockForAbstractClass('Doctrine\DBAL\Platforms\AbstractPlatform'); + $platformMock = $this->getMockForAbstractClass(AbstractPlatform::class); $connection = new Connection([], $driverMock); 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 9eda7f8de77..0475ea11b89 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php @@ -4,8 +4,25 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; -use Doctrine\DBAL\Driver\DriverException; +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; @@ -16,23 +33,23 @@ abstract class AbstractDriverTest extends DbalTestCase { - public const EXCEPTION_CONNECTION = 'Doctrine\DBAL\Exception\ConnectionException'; - public const EXCEPTION_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\ConstraintViolationException'; - public const EXCEPTION_DATABASE_OBJECT_EXISTS = 'Doctrine\DBAL\Exception\DatabaseObjectExistsException'; - public const EXCEPTION_DATABASE_OBJECT_NOT_FOUND = 'Doctrine\DBAL\Exception\DatabaseObjectNotFoundException'; - public const EXCEPTION_DRIVER = 'Doctrine\DBAL\Exception\DriverException'; - public const EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException'; - public const EXCEPTION_INVALID_FIELD_NAME = 'Doctrine\DBAL\Exception\InvalidFieldNameException'; - public const EXCEPTION_NON_UNIQUE_FIELD_NAME = 'Doctrine\DBAL\Exception\NonUniqueFieldNameException'; - public const EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\NotNullConstraintViolationException'; - public const EXCEPTION_READ_ONLY = 'Doctrine\DBAL\Exception\ReadOnlyException'; - public const EXCEPTION_SERVER = 'Doctrine\DBAL\Exception\ServerException'; - public const EXCEPTION_SYNTAX_ERROR = 'Doctrine\DBAL\Exception\SyntaxErrorException'; - public const EXCEPTION_TABLE_EXISTS = 'Doctrine\DBAL\Exception\TableExistsException'; - public const EXCEPTION_TABLE_NOT_FOUND = 'Doctrine\DBAL\Exception\TableNotFoundException'; - public const EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\UniqueConstraintViolationException'; - public const EXCEPTION_DEADLOCK = 'Doctrine\DBAL\Exception\DeadlockException'; - public 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. @@ -66,7 +83,7 @@ public function testConvertsException() ); } - $driverException = new class extends Exception implements DriverException + $driverException = new class extends Exception implements DriverExceptionInterface { public function __construct() { @@ -215,7 +232,7 @@ abstract protected function createSchemaManager(Connection $connection); protected function getConnectionMock() { - return $this->getMockBuilder('Doctrine\DBAL\Connection') + return $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() ->getMock(); } @@ -238,7 +255,7 @@ private function getExceptionConversions() foreach ($errors as $error) { $driverException = new class ($error[0], $error[1], $error[2]) extends Exception - implements DriverException + implements DriverExceptionInterface { /** @var mixed */ private $errorCode; diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php index ebeb81d160f..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 { @@ -21,7 +23,7 @@ public function testReturnsDatabaseName() '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 [ diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php index a427f12c945..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; @@ -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() diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php index 9c9bcd5c354..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 { @@ -19,7 +24,7 @@ public function testReturnsDatabaseName() '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() @@ -56,18 +61,18 @@ protected function createSchemaManager(Connection $connection) protected function getDatabasePlatformsForVersions() { return [ - ['9.0.9', 'Doctrine\DBAL\Platforms\PostgreSqlPlatform'], - ['9.1', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'], - ['9.1.0', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'], - ['9.1.1', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'], - ['9.1.9', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'], - ['9.2', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'], - ['9.2.0', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'], - ['9.2.1', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'], - ['9.3.6', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'], - ['9.4', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'], - ['9.4.0', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'], - ['9.4.1', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'], + ['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], ]; } diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php index 53480e7d82a..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() @@ -26,35 +30,35 @@ protected function createSchemaManager(Connection $connection) protected function getDatabasePlatformsForVersions() { return [ - ['10', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'], - ['10.0', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'], - ['10.0.0', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'], - ['10.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'], - ['10.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'], - ['10.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'], - ['11', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'], - ['11.0', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'], - ['11.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'], - ['11.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'], - ['11.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'], - ['11.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'], - ['12', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'], - ['12.0', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'], - ['12.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'], - ['12.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'], - ['12.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'], - ['12.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'], - ['13', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'], - ['14', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'], - ['15', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'], - ['15.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'], - ['16', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'], - ['16.0', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'], - ['16.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'], - ['16.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'], - ['16.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'], - ['16.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'], - ['17', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'], + ['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], ]; } diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php index 31e72a661af..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() @@ -26,32 +30,32 @@ protected function createSchemaManager(Connection $connection) protected function getDatabasePlatformsForVersions() { return [ - ['9', 'Doctrine\DBAL\Platforms\SQLServerPlatform'], - ['9.00', 'Doctrine\DBAL\Platforms\SQLServerPlatform'], - ['9.00.0', 'Doctrine\DBAL\Platforms\SQLServerPlatform'], - ['9.00.1398', 'Doctrine\DBAL\Platforms\SQLServerPlatform'], - ['9.00.1398.99', 'Doctrine\DBAL\Platforms\SQLServerPlatform'], - ['9.00.1399', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'], - ['9.00.1399.0', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'], - ['9.00.1399.99', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'], - ['9.00.1400', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'], - ['9.10', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'], - ['9.10.9999', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'], - ['10.00.1599', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'], - ['10.00.1599.99', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'], - ['10.00.1600', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'], - ['10.00.1600.0', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'], - ['10.00.1600.99', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'], - ['10.00.1601', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'], - ['10.10', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'], - ['10.10.9999', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'], - ['11.00.2099', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'], - ['11.00.2099.99', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'], - ['11.00.2100', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'], - ['11.00.2100.0', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'], - ['11.00.2100.99', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'], - ['11.00.2101', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'], - ['12', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'], + ['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 96f3b6b9d64..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; @@ -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() 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 eaebefb728c..a60772295a6 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php @@ -24,7 +24,7 @@ protected function setUp() 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 b0b34309f28..9bd3172dd1d 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php @@ -28,7 +28,7 @@ protected function setUp() parent::setUp(); - if (! $this->_conn->getDatabasePlatform() instanceof MySqlPlatform) { + if (! $this->connection->getDatabasePlatform() instanceof MySqlPlatform) { $this->markTestSkipped('MySQL only test.'); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php index b8141a84f2a..0628738400e 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php @@ -24,7 +24,7 @@ protected function setUp() 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 103b7ab57d7..b51f3bf2f5b 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php @@ -2,6 +2,7 @@ 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; @@ -28,12 +29,14 @@ 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') + $statement = $this->getMockBuilder(OCI8Statement::class) ->setMethods(['bindValue', 'errorInfo']) ->disableOriginalConstructor() ->getMock(); @@ -59,7 +62,7 @@ public function testExecute(array $params) // 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') + $conn = $this->getMockBuilder(OCI8Connection::class) ->setMethods(['getExecuteMode']) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php index 3f1c3efa1f8..a6ac2456b64 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php @@ -2,6 +2,7 @@ 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; @@ -32,7 +33,7 @@ public function testConnectionDisablesPreparesOnPhp56() $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)); @@ -59,7 +60,7 @@ public function testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined( [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)); @@ -86,7 +87,7 @@ public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplici [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)); diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php index 49bc5d05a16..d70d36396ba 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php @@ -24,7 +24,7 @@ protected function setUp() 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 9e467cca01f..b0e32708428 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php @@ -24,7 +24,7 @@ protected function setUp() 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/Events/MysqlSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php index 981851a6b9e..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,7 +12,7 @@ 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')); diff --git a/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php index b86af27fc3f..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,7 +13,7 @@ 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')); @@ -29,7 +30,7 @@ public function testPostConnect() */ public function testPostConnectQuotesSessionParameterValues($name, $value) { - $connectionMock = $this->getMockBuilder('Doctrine\DBAL\Connection') + $connectionMock = $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() ->getMock(); $connectionMock->expects($this->once()) diff --git a/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php index bf74e5180ae..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'")); diff --git a/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php b/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php index c2e7c7ec29a..54cfea89596 100644 --- a/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\DBAL\Exception; @@ -33,7 +16,7 @@ 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 66332ed20ba..779f33254b5 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php @@ -23,7 +23,7 @@ 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'); } @@ -34,13 +34,13 @@ protected function setUp() $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', @@ -55,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'), @@ -77,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', @@ -92,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', @@ -102,7 +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 c6cca6d8e68..b9d03d5e66c 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php @@ -4,6 +4,7 @@ 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; @@ -31,204 +32,204 @@ 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()); + $this->connection->beginTransaction(); + self::assertEquals(2, $this->connection->getTransactionNestingLevel()); throw new Exception(); - $this->_conn->commit(); // never reached + $this->connection->commit(); // never reached } catch (Throwable $e) { - $this->_conn->rollBack(); - self::assertEquals(1, $this->_conn->getTransactionNestingLevel()); + $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()); + $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->_conn->commit(); // never reached + $this->connection->commit(); // never reached } catch (Throwable $e) { - $this->_conn->rollBack(); - self::assertEquals(1, $this->_conn->getTransactionNestingLevel()); + $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->_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->_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->_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->_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(); - $this->_conn->commit(); // never reached + $this->connection->commit(); // never reached } catch (Throwable $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 testTransactionBehaviour() { try { - $this->_conn->beginTransaction(); - self::assertEquals(1, $this->_conn->getTransactionNestingLevel()); - $this->_conn->commit(); + $this->connection->beginTransaction(); + self::assertEquals(1, $this->connection->getTransactionNestingLevel()); + $this->connection->commit(); } catch (Throwable $e) { - $this->_conn->rollBack(); - self::assertEquals(0, $this->_conn->getTransactionNestingLevel()); + $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(static function($conn) { + $this->connection->transactional(static function ($conn) { /** @var Connection $conn */ $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); throw new RuntimeException('Ooops!'); }); $this->fail('Expected exception'); } catch (RuntimeException $expected) { - self::assertEquals(0, $this->_conn->getTransactionNestingLevel()); + self::assertEquals(0, $this->connection->getTransactionNestingLevel()); } } public function testTransactionalWithThrowable() { try { - $this->_conn->transactional(static function($conn) { + $this->connection->transactional(static function ($conn) { /** @var Connection $conn */ $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); throw new Error('Ooops!'); }); $this->fail('Expected exception'); } catch (Error $expected) { - self::assertEquals(0, $this->_conn->getTransactionNestingLevel()); + self::assertEquals(0, $this->connection->getTransactionNestingLevel()); } } public function testTransactional() { - $res = $this->_conn->transactional(static function($conn) { + $res = $this->connection->transactional(static function ($conn) { /** @var Connection $conn */ $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); }); @@ -238,7 +239,7 @@ public function testTransactional() public function testTransactionalReturnValue() { - $res = $this->_conn->transactional(static function() { + $res = $this->connection->transactional(static function () { return 42; }); @@ -251,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()); } /** @@ -267,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()); @@ -290,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 e688a5f0604..9f6fcbfd75b 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php @@ -4,12 +4,15 @@ 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; @@ -23,6 +26,7 @@ use function is_numeric; use function json_encode; use function property_exists; +use function sprintf; use function strtotime; class DataAccessTest extends DbalFunctionalTestCase @@ -45,18 +49,18 @@ protected function setUp() $table->addColumn('test_datetime', 'datetime', ['notnull' => false]); $table->setPrimaryKey(['test_int']); - $sm = $this->_conn->getSchemaManager(); + $sm = $this->connection->getSchemaManager(); $sm->createTable($table); - $this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo', 'test_datetime' => '2010-01-01 10:10:10')); + $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); + $stmt = $this->connection->prepare($sql); + self::assertInstanceOf(Statement::class, $stmt); $stmt->bindValue(1, 1); $stmt->bindValue(2, 'foo'); @@ -73,8 +77,8 @@ public function testPrepareWithBindParam() $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 = $this->connection->prepare($sql); + self::assertInstanceOf(Statement::class, $stmt); $stmt->bindParam(1, $paramInt); $stmt->bindParam(2, $paramStr); @@ -91,8 +95,8 @@ public function testPrepareWithFetchAll() $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 = $this->connection->prepare($sql); + self::assertInstanceOf(Statement::class, $stmt); $stmt->bindParam(1, $paramInt); $stmt->bindParam(2, $paramStr); @@ -112,8 +116,8 @@ public function testPrepareWithFetchAllBoth() $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 = $this->connection->prepare($sql); + self::assertInstanceOf(Statement::class, $stmt); $stmt->bindParam(1, $paramInt); $stmt->bindParam(2, $paramStr); @@ -130,8 +134,8 @@ public function testPrepareWithFetchColumn() $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); + $stmt = $this->connection->prepare($sql); + self::assertInstanceOf(Statement::class, $stmt); $stmt->bindParam(1, $paramInt); $stmt->bindParam(2, $paramStr); @@ -147,8 +151,8 @@ public function testPrepareWithIterator() $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 = $this->connection->prepare($sql); + self::assertInstanceOf(Statement::class, $stmt); $stmt->bindParam(1, $paramInt); $stmt->bindParam(2, $paramStr); @@ -169,10 +173,13 @@ public function testPrepareWithQuoted() $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() @@ -181,8 +188,8 @@ public function testPrepareWithExecuteParams() $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 = $this->connection->prepare($sql); + self::assertInstanceOf(Statement::class, $stmt); $stmt->execute([$paramInt, $paramStr]); $row = $stmt->fetch(FetchMode::ASSOCIATIVE); @@ -194,7 +201,7 @@ public function testPrepareWithExecuteParams() 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')); + $data = $this->connection->fetchAll($sql, [1, 'foo']); self::assertCount(1, $data); @@ -215,7 +222,7 @@ public function testFetchAllWithTypes() $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); @@ -233,21 +240,21 @@ 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, [1, $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); @@ -262,14 +269,14 @@ 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')); + $row = $this->connection->fetchAssoc($sql, [1, 'foo']); self::assertNotFalse($row); @@ -285,7 +292,7 @@ public function testFetchAssocWithTypes() $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); @@ -300,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)); + $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')); + $row = $this->connection->fetchArray($sql, [1, 'foo']); self::assertEquals(1, $row[0]); self::assertEquals('foo', $row[1]); @@ -326,7 +333,7 @@ public function testFetchArrayWithTypes() $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); @@ -341,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, [1, $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, [1, 'foo'], 0); + $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, [1, 'foo'], 1); + $testString = $this->connection->fetchColumn($sql, [1, 'foo'], 1); self::assertEquals('foo', $testString); } @@ -371,7 +378,7 @@ public function testFetchColumnWithTypes() $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); @@ -383,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, [1, $datetime], 1); + $column = $this->connection->fetchColumn($sql, [1, $datetime], 1); } /** @@ -400,7 +407,7 @@ public function testFetchColumnWithMissingTypes() public function testExecuteQueryBindDateTimeType() { $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?'; - $stmt = $this->_conn->executeQuery( + $stmt = $this->connection->executeQuery( $sql, [1 => new DateTime('2010-01-01 10:10:10')], [1 => Type::DATETIME] @@ -417,7 +424,7 @@ public function testExecuteUpdateBindDateTimeType() $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, [ + $affectedRows = $this->connection->executeUpdate($sql, [ 1 => 50, 2 => 'foo', 3 => $datetime, @@ -428,7 +435,7 @@ 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 = ?', [1 => $datetime], [1 => Type::DATETIME] @@ -441,7 +448,7 @@ public function testExecuteUpdateBindDateTimeType() public function testPrepareQueryBindValueDateTimeType() { $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?'; - $stmt = $this->_conn->prepare($sql); + $stmt = $this->connection->prepare($sql); $stmt->bindValue(1, new DateTime('2010-01-01 10:10:10'), Type::DATETIME); $stmt->execute(); @@ -454,10 +461,10 @@ public function testPrepareQueryBindValueDateTimeType() public function testNativeArrayListSupport() { for ($i = 100; $i < 110; $i++) { - $this->_conn->insert('fetch_table', ['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( + $stmt = $this->connection->executeQuery( 'SELECT test_int FROM fetch_table WHERE test_int IN (?)', [[100, 101, 102, 103, 104]], [Connection::PARAM_INT_ARRAY] @@ -467,7 +474,7 @@ public function testNativeArrayListSupport() self::assertCount(5, $data); self::assertEquals([[100], [101], [102], [103], [104]], $data); - $stmt = $this->_conn->executeQuery( + $stmt = $this->connection->executeQuery( 'SELECT test_int FROM fetch_table WHERE test_string IN (?)', [['foo100', 'foo101', 'foo102', 'foo103', 'foo104']], [Connection::PARAM_STR_ARRAY] @@ -484,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']); @@ -540,7 +547,7 @@ public function getTrimExpressionData() */ public function testDateArithmetics() { - $p = $this->_conn->getDatabasePlatform(); + $p = $this->connection->getDatabasePlatform(); $sql = 'SELECT '; $sql .= $p->getDateAddSecondsExpression('test_datetime', 1) . ' AS add_seconds, '; $sql .= $p->getDateSubSecondsExpression('test_datetime', 1) . ' AS sub_seconds, '; @@ -560,7 +567,7 @@ public function testDateArithmetics() $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'); @@ -583,7 +590,7 @@ public function testDateArithmetics() public function testSqliteDateArithmeticWithDynamicInterval() { - $platform = $this->_conn->getDatabasePlatform(); + $platform = $this->connection->getDatabasePlatform(); if (! $platform instanceof SqlitePlatform) { $this->markTestSkipped('test is for sqlite only'); @@ -595,23 +602,23 @@ public function testSqliteDateArithmeticWithDynamicInterval() $table->setPrimaryKey(['test_date']); /** @var AbstractSchemaManager $sm */ - $sm = $this->_conn->getSchemaManager(); + $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(); + $platform = $this->connection->getDatabasePlatform(); $sql = 'SELECT '; $sql .= $platform->getLocateExpression('test_string', "'oo'") . ' AS locate1, '; @@ -625,7 +632,7 @@ public function testLocateExpression() $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']); @@ -641,8 +648,8 @@ 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'); } @@ -652,8 +659,8 @@ public function testQuoteSQLInjection() */ public function testBitComparisonExpressionSupport() { - $this->_conn->exec('DELETE FROM fetch_table'); - $platform = $this->_conn->getDatabasePlatform(); + $this->connection->exec('DELETE FROM fetch_table'); + $platform = $this->connection->getDatabasePlatform(); $bitmap = []; for ($i = 2; $i < 9; $i += 2) { @@ -661,7 +668,7 @@ public function testBitComparisonExpressionSupport() 'bit_or' => ($i | 2), 'bit_and' => ($i & 2), ]; - $this->_conn->insert('fetch_table', [ + $this->connection->insert('fetch_table', [ 'test_int' => $i, 'test_string' => json_encode($bitmap[$i]), 'test_datetime' => '2010-01-01 10:10:10', @@ -675,7 +682,7 @@ public function testBitComparisonExpressionSupport() $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); @@ -700,7 +707,7 @@ 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()); @@ -717,7 +724,7 @@ public function testFetchAllStyleObject() $this->setupFixture(); $sql = 'SELECT test_int, test_string, test_datetime FROM fetch_table'; - $stmt = $this->_conn->prepare($sql); + $stmt = $this->connection->prepare($sql); $stmt->execute(); @@ -749,16 +756,16 @@ public function testFetchAllSupportFetchClass() $this->setupFixture(); $sql = 'SELECT test_int, test_string, test_datetime FROM fetch_table'; - $stmt = $this->_conn->prepare($sql); + $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); @@ -771,13 +778,13 @@ public function testFetchAllSupportFetchClass() public function testFetchAllStyleColumn() { $sql = 'DELETE FROM fetch_table'; - $this->_conn->executeUpdate($sql); + $this->connection->executeUpdate($sql); - $this->_conn->insert('fetch_table', ['test_int' => 1, 'test_string' => 'foo']); - $this->_conn->insert('fetch_table', ['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); + $rows = $this->connection->query($sql)->fetchAll(FetchMode::COLUMN); self::assertEquals([1, 10], $rows); } @@ -791,13 +798,13 @@ public function testSetFetchModeClassFetchAll() $this->setupFixture(); $sql = 'SELECT * FROM fetch_table'; - $stmt = $this->_conn->query($sql); - $stmt->setFetchMode(FetchMode::CUSTOM_OBJECT, __NAMESPACE__ . '\\MyFetchClass'); + $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); @@ -813,8 +820,8 @@ public function testSetFetchModeClassFetch() $this->setupFixture(); $sql = 'SELECT * FROM fetch_table'; - $stmt = $this->_conn->query($sql); - $stmt->setFetchMode(FetchMode::CUSTOM_OBJECT, __NAMESPACE__ . '\\MyFetchClass'); + $stmt = $this->connection->query($sql); + $stmt->setFetchMode(FetchMode::CUSTOM_OBJECT, MyFetchClass::class); $results = []; while ($row = $stmt->fetch()) { @@ -822,7 +829,7 @@ public function testSetFetchModeClassFetch() } 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); @@ -834,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(); } /** @@ -847,7 +854,7 @@ 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, [1, 'foo']); + $stmt = $this->connection->executeQuery($sql, [1, 'foo']); $stmt->setFetchMode(FetchMode::NUMERIC); $row = $stmt->fetch(); @@ -863,7 +870,7 @@ public function testSetFetchModeOnDbalStatement() public function testEmptyParameters() { $sql = 'SELECT * FROM fetch_table WHERE test_int IN (?)'; - $stmt = $this->_conn->executeQuery($sql, [[]], [Connection::PARAM_INT_ARRAY]); + $stmt = $this->connection->executeQuery($sql, [[]], [Connection::PARAM_INT_ARRAY]); $rows = $stmt->fetchAll(); self::assertEquals([], $rows); @@ -874,13 +881,13 @@ public function testEmptyParameters() */ public function testFetchColumnNullValue() { - $this->_conn->executeUpdate( + $this->connection->executeUpdate( 'INSERT INTO fetch_table (test_int, test_string) VALUES (?, ?)', [2, 'foo'] ); self::assertNull( - $this->_conn->fetchColumn('SELECT test_datetime FROM fetch_table WHERE test_int = ?', [2]) + $this->connection->fetchColumn('SELECT test_datetime FROM fetch_table WHERE test_int = ?', [2]) ); } @@ -889,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 = ?', [1], 1) + $this->connection->fetchColumn('SELECT test_int FROM fetch_table WHERE test_int = ?', [1], 1) ); } @@ -906,14 +913,14 @@ public function testFetchColumnNonExistingIndex() public function testFetchColumnNoResult() { self::assertFalse( - $this->_conn->fetchColumn('SELECT test_int FROM fetch_table WHERE test_int = ?', [-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', [ + $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', @@ -925,7 +932,7 @@ private function skipOci8AndMysqli() if (isset($GLOBALS['db_type']) && $GLOBALS['db_type'] === 'oci8') { $this->markTestSkipped('Not supported by OCI8'); } - if ($this->_conn->getDriver()->getName() !== 'mysqli') { + if ($this->connection->getDriver()->getName() !== 'mysqli') { return; } @@ -935,5 +942,12 @@ private function skipOci8AndMysqli() 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 a013a7706a8..738c259d5c0 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\Tests\DbalFunctionalTestCase; abstract class AbstractDriverTest extends DbalFunctionalTestCase @@ -27,7 +28,7 @@ protected function setUp() */ public function testConnectsWithoutDatabaseNameParameter() { - $params = $this->_conn->getParams(); + $params = $this->connection->getParams(); unset($params['dbname']); $user = $params['user'] ?? null; @@ -35,7 +36,7 @@ public function testConnectsWithoutDatabaseNameParameter() $connection = $this->driver->connect($params, $user, $password); - self::assertInstanceOf('Doctrine\DBAL\Driver\Connection', $connection); + self::assertInstanceOf(DriverConnection::class, $connection); } /** @@ -43,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( diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php index cb39d81135c..82da6090b7e 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php @@ -16,7 +16,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDriver() instanceof DB2Driver) { + if ($this->connection->getDriver() instanceof DB2Driver) { return; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php index 13226c32613..6c2ec6a9ca6 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php @@ -19,7 +19,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDriver() instanceof DB2Driver) { + if ($this->connection->getDriver() instanceof DB2Driver) { return; } @@ -28,7 +28,7 @@ protected function setUp() 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 591fff5a13e..8c274e1cbb2 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php @@ -18,7 +18,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDriver() instanceof Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } @@ -35,7 +35,7 @@ public function testDriverOptions() $driverOptions = [MYSQLI_OPT_CONNECT_TIMEOUT => 1]; $connection = $this->getConnection($driverOptions); - self::assertInstanceOf('\Doctrine\DBAL\Driver\Mysqli\MysqliConnection', $connection); + self::assertInstanceOf(MysqliConnection::class, $connection); } /** @@ -52,6 +52,9 @@ public function testPing() self::assertTrue($conn->ping()); } + /** + * @param mixed[] $driverOptions + */ private function getConnection(array $driverOptions) { return new MysqliConnection( diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php index da9ee0b5e5b..d7f02a40306 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php @@ -16,7 +16,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDriver() instanceof Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php index a5776b75c68..a781b31007d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php @@ -16,7 +16,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDriver() instanceof Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php index cba1041129e..1c3226852d6 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php @@ -21,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(); } /** @@ -33,8 +33,8 @@ 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', ['autoincrement' => true]); @@ -42,9 +42,9 @@ public function testLastInsertIdAcceptsFqn() $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 f9ddce6f11c..db6a4d552ca 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php @@ -16,7 +16,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDriver() instanceof Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } @@ -24,13 +24,16 @@ protected function setUp() } /** + * @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() ); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php index b5eebb92da3..214f90700c1 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php @@ -25,7 +25,7 @@ protected function setUp() parent::setUp(); - $this->driverConnection = $this->_conn->getWrappedConnection(); + $this->driverConnection = $this->connection->getWrappedConnection(); if ($this->driverConnection instanceof PDOConnection) { return; @@ -68,7 +68,7 @@ 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.'); } @@ -86,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 462f5941fa2..cb0f9633201 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php @@ -16,7 +16,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDriver() instanceof Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php index 0fcba6d6431..604fbc8b123 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php @@ -16,7 +16,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDriver() instanceof Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php index 7c595c9c7df..289621c5eba 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php @@ -21,7 +21,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDriver() instanceof Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } @@ -33,15 +33,15 @@ protected function setUp() */ public function testDatabaseParameters($databaseName, $defaultDatabaseName, $expectedDatabaseName) { - $params = $this->_conn->getParams(); + $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( @@ -70,7 +70,7 @@ public function getDatabaseParameter() */ public function testConnectsWithApplicationNameParameter() { - $parameters = $this->_conn->getParams(); + $parameters = $this->connection->getParams(); $parameters['application_name'] = 'doctrine'; $user = $parameters['user'] ?? null; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php index 16021c3ea24..0893bed2e70 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php @@ -18,7 +18,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDatabasePlatform() instanceof PostgreSqlPlatform) { + if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) { return; } @@ -34,13 +34,13 @@ protected function setUp() */ 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( @@ -51,7 +51,7 @@ public function testConnectsWithValidCharsetOption($charset) } /** - * @return array + * @return mixed[][] */ public function getValidCharsets() { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php index e6ad8639552..36978d4b4fd 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php @@ -16,7 +16,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDriver() instanceof Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php index e9d224f8e0f..f125eab3515 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php @@ -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 d94fb91df7d..63253a84408 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php @@ -17,7 +17,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDriver() instanceof Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } @@ -26,7 +26,7 @@ protected function setUp() public function testNonPersistentConnection() { - $params = $this->_conn->getParams(); + $params = $this->connection->getParams(); $params['persistent'] = false; $conn = DriverManager::getConnection($params); @@ -38,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 1dbe8eebee7..07d0189a88d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php @@ -17,7 +17,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDriver() instanceof Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } @@ -26,14 +26,14 @@ protected function setUp() 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 1e2debe949f..3cf5c282ea0 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php @@ -17,7 +17,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDriver() instanceof Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } @@ -26,7 +26,7 @@ protected function setUp() public function testNonPersistentStatement() { - $params = $this->_conn->getParams(); + $params = $this->connection->getParams(); $params['persistent'] = false; $conn = DriverManager::getConnection($params); @@ -41,7 +41,7 @@ public function testNonPersistentStatement() public function testPersistentStatement() { - $params = $this->_conn->getParams(); + $params = $this->connection->getParams(); $params['persistent'] = true; $conn = DriverManager::getConnection($params); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php index 4ea3c9bc143..b09d7339fc9 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php @@ -16,7 +16,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDriver() instanceof Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php index b6b325f23b4..38df9cb5181 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php @@ -17,7 +17,7 @@ protected function setUp() parent::setUp(); - if ($this->_conn->getDriver() instanceof Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } @@ -27,7 +27,7 @@ protected function setUp() 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 a2e1ca901e3..e420000ba58 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php @@ -24,7 +24,7 @@ protected function setUp() { parent::setUp(); - if ($this->_conn->getDriver() instanceof ExceptionConverterDriver) { + if ($this->connection->getDriver() instanceof ExceptionConverterDriver) { return; } @@ -37,12 +37,12 @@ public function testPrimaryConstraintViolationException() $table->addColumn('id', 'integer', []); $table->setPrimaryKey(['id']); - $this->_conn->getSchemaManager()->createTable($table); + $this->connection->getSchemaManager()->createTable($table); - $this->_conn->insert('duplicatekey_table', ['id' => 1]); + $this->connection->insert('duplicatekey_table', ['id' => 1]); $this->expectException(Exception\UniqueConstraintViolationException::class); - $this->_conn->insert('duplicatekey_table', ['id' => 1]); + $this->connection->insert('duplicatekey_table', ['id' => 1]); } public function testTableNotFoundException() @@ -50,12 +50,12 @@ public function testTableNotFoundException() $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(); + $schemaManager = $this->connection->getSchemaManager(); $table = new Table('alreadyexist_table'); $table->addColumn('id', 'integer', []); $table->setPrimaryKey(['id']); @@ -67,15 +67,15 @@ public function testTableExistsException() public function testForeignKeyConstraintViolationExceptionOnInsert() { - if (! $this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) { + if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Only fails on platforms with foreign key constraints.'); } $this->setUpForeignKeyConstraintViolationExceptionTest(); try { - $this->_conn->insert('constraint_error_table', ['id' => 1]); - $this->_conn->insert('owning_table', ['id' => 1, 'constraint_id' => 1]); + $this->connection->insert('constraint_error_table', ['id' => 1]); + $this->connection->insert('owning_table', ['id' => 1, 'constraint_id' => 1]); } catch (Throwable $exception) { $this->tearDownForeignKeyConstraintViolationExceptionTest(); @@ -85,7 +85,7 @@ public function testForeignKeyConstraintViolationExceptionOnInsert() $this->expectException(Exception\ForeignKeyConstraintViolationException::class); try { - $this->_conn->insert('owning_table', ['id' => 2, 'constraint_id' => 2]); + $this->connection->insert('owning_table', ['id' => 2, 'constraint_id' => 2]); } catch (Exception\ForeignKeyConstraintViolationException $exception) { $this->tearDownForeignKeyConstraintViolationExceptionTest(); @@ -101,15 +101,15 @@ public function testForeignKeyConstraintViolationExceptionOnInsert() public function testForeignKeyConstraintViolationExceptionOnUpdate() { - if (! $this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) { + if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Only fails on platforms with foreign key constraints.'); } $this->setUpForeignKeyConstraintViolationExceptionTest(); try { - $this->_conn->insert('constraint_error_table', ['id' => 1]); - $this->_conn->insert('owning_table', ['id' => 1, 'constraint_id' => 1]); + $this->connection->insert('constraint_error_table', ['id' => 1]); + $this->connection->insert('owning_table', ['id' => 1, 'constraint_id' => 1]); } catch (Throwable $exception) { $this->tearDownForeignKeyConstraintViolationExceptionTest(); @@ -119,7 +119,7 @@ public function testForeignKeyConstraintViolationExceptionOnUpdate() $this->expectException(Exception\ForeignKeyConstraintViolationException::class); try { - $this->_conn->update('constraint_error_table', ['id' => 2], ['id' => 1]); + $this->connection->update('constraint_error_table', ['id' => 2], ['id' => 1]); } catch (Exception\ForeignKeyConstraintViolationException $exception) { $this->tearDownForeignKeyConstraintViolationExceptionTest(); @@ -135,15 +135,15 @@ public function testForeignKeyConstraintViolationExceptionOnUpdate() public function testForeignKeyConstraintViolationExceptionOnDelete() { - if (! $this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) { + if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Only fails on platforms with foreign key constraints.'); } $this->setUpForeignKeyConstraintViolationExceptionTest(); try { - $this->_conn->insert('constraint_error_table', ['id' => 1]); - $this->_conn->insert('owning_table', ['id' => 1, 'constraint_id' => 1]); + $this->connection->insert('constraint_error_table', ['id' => 1]); + $this->connection->insert('owning_table', ['id' => 1, 'constraint_id' => 1]); } catch (Throwable $exception) { $this->tearDownForeignKeyConstraintViolationExceptionTest(); @@ -153,7 +153,7 @@ public function testForeignKeyConstraintViolationExceptionOnDelete() $this->expectException(Exception\ForeignKeyConstraintViolationException::class); try { - $this->_conn->delete('constraint_error_table', ['id' => 1]); + $this->connection->delete('constraint_error_table', ['id' => 1]); } catch (Exception\ForeignKeyConstraintViolationException $exception) { $this->tearDownForeignKeyConstraintViolationExceptionTest(); @@ -169,7 +169,7 @@ 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.'); @@ -178,8 +178,8 @@ public function testForeignKeyConstraintViolationExceptionOnTruncate() $this->setUpForeignKeyConstraintViolationExceptionTest(); try { - $this->_conn->insert('constraint_error_table', ['id' => 1]); - $this->_conn->insert('owning_table', ['id' => 1, 'constraint_id' => 1]); + $this->connection->insert('constraint_error_table', ['id' => 1]); + $this->connection->insert('owning_table', ['id' => 1, 'constraint_id' => 1]); } catch (Throwable $exception) { $this->tearDownForeignKeyConstraintViolationExceptionTest(); @@ -189,7 +189,7 @@ 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(); @@ -212,12 +212,12 @@ public function testNotNullConstraintViolationException() $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', ['id' => 1, 'value' => null]); + $this->connection->insert('notnull_table', ['id' => 1, 'value' => null]); } public function testInvalidFieldNameException() @@ -227,12 +227,12 @@ public function testInvalidFieldNameException() $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', ['name' => 5]); + $this->connection->insert('bad_fieldname_table', ['name' => 5]); } public function testNonUniqueFieldNameException() @@ -245,13 +245,13 @@ public function testNonUniqueFieldNameException() $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() @@ -262,13 +262,13 @@ public function testUniqueConstraintViolationException() $table->addColumn('id', 'integer'); $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', ['id' => 5]); + $this->connection->insert('unique_field_table', ['id' => 5]); $this->expectException(Exception\UniqueConstraintViolationException::class); - $this->_conn->insert('unique_field_table', ['id' => 5]); + $this->connection->insert('unique_field_table', ['id' => 5]); } public function testSyntaxErrorException() @@ -277,11 +277,11 @@ public function testSyntaxErrorException() $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); } /** @@ -289,7 +289,7 @@ public function testSyntaxErrorException() */ public function testConnectionExceptionSqLite($mode, $exceptionClass) { - if ($this->_conn->getDatabasePlatform()->getName() !== 'sqlite') { + if ($this->connection->getDatabasePlatform()->getName() !== 'sqlite') { $this->markTestSkipped('Only fails this way on sqlite'); } @@ -333,19 +333,19 @@ public function getSqLiteOpenConnection() */ public function testConnectionException($params) { - if ($this->_conn->getDatabasePlatform()->getName() === 'sqlite') { + if ($this->connection->getDatabasePlatform()->getName() === 'sqlite') { $this->markTestSkipped('Only skipped if platform is not sqlite'); } - if ($this->_conn->getDatabasePlatform()->getName() === 'drizzle') { + if ($this->connection->getDatabasePlatform()->getName() === 'drizzle') { $this->markTestSkipped('Drizzle does not always support authentication'); } - if ($this->_conn->getDatabasePlatform()->getName() === 'postgresql' && isset($params['password'])) { + if ($this->connection->getDatabasePlatform()->getName() === 'postgresql' && isset($params['password'])) { $this->markTestSkipped('Does not work on Travis'); } - $defaultParams = $this->_conn->getParams(); + $defaultParams = $this->connection->getParams(); $params = array_merge($defaultParams, $params); $conn = DriverManager::getConnection($params); @@ -372,7 +372,7 @@ public function getConnectionParams() private function setUpForeignKeyConstraintViolationExceptionTest() { - $schemaManager = $this->_conn->getSchemaManager(); + $schemaManager = $this->connection->getSchemaManager(); $table = new Table('constraint_error_table'); $table->addColumn('id', 'integer', []); @@ -390,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 59306f153fd..e172816f2af 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php @@ -11,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 8ba5daa0669..99ca533e742 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/LoggingTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/LoggingTest.php @@ -2,53 +2,54 @@ namespace Doctrine\Tests\DBAL\Functional; +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([]), $this->equalTo([])); $logMock->expects($this->at(1)) ->method('stopQuery'); - $this->_conn->getConfiguration()->setSQLLogger($logMock); - $this->_conn->executeQuery($sql, []); + $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([]), $this->equalTo([])); $logMock->expects($this->at(1)) ->method('stopQuery'); - $this->_conn->getConfiguration()->setSQLLogger($logMock); - $this->_conn->executeUpdate($sql, []); + $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([])); $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 af894cf147c..81747c3a996 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php @@ -24,7 +24,7 @@ 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') { @@ -37,13 +37,13 @@ protected function setUp() $table->addColumn('test_int', 'integer'); $table->setPrimaryKey(['test_int']); - $sm = $this->_conn->getSchemaManager(); + $sm = $this->connection->getSchemaManager(); $sm->createTable($table); } catch (Throwable $e) { } - $this->_conn->executeUpdate('DELETE FROM master_slave_table'); - $this->_conn->insert('master_slave_table', ['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 @@ -51,9 +51,12 @@ 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'] = [$params, $params]; $params['keepSlave'] = $keepSlave; diff --git a/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php b/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php index b68aeaef8b3..87f326abdca 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php @@ -29,21 +29,21 @@ protected function setUp() $table2->addColumn('test_int', 'integer'); $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', ['test_int' => 1]); - $this->_conn->insert('modify_limit_table', ['test_int' => 2]); - $this->_conn->insert('modify_limit_table', ['test_int' => 3]); - $this->_conn->insert('modify_limit_table', ['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'; @@ -55,14 +55,14 @@ public function testModifyLimitQuerySimpleQuery() public function testModifyLimitQueryJoinQuery() { - $this->_conn->insert('modify_limit_table', ['test_int' => 1]); - $this->_conn->insert('modify_limit_table', ['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', ['test_int' => 1]); - $this->_conn->insert('modify_limit_table2', ['test_int' => 1]); - $this->_conn->insert('modify_limit_table2', ['test_int' => 1]); - $this->_conn->insert('modify_limit_table2', ['test_int' => 2]); - $this->_conn->insert('modify_limit_table2', ['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'; @@ -73,10 +73,10 @@ public function testModifyLimitQueryJoinQuery() public function testModifyLimitQueryNonDeterministic() { - $this->_conn->insert('modify_limit_table', ['test_int' => 1]); - $this->_conn->insert('modify_limit_table', ['test_int' => 2]); - $this->_conn->insert('modify_limit_table', ['test_int' => 3]); - $this->_conn->insert('modify_limit_table', ['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'; @@ -87,14 +87,14 @@ public function testModifyLimitQueryNonDeterministic() public function testModifyLimitQueryGroupBy() { - $this->_conn->insert('modify_limit_table', ['test_int' => 1]); - $this->_conn->insert('modify_limit_table', ['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', ['test_int' => 1]); - $this->_conn->insert('modify_limit_table2', ['test_int' => 1]); - $this->_conn->insert('modify_limit_table2', ['test_int' => 1]); - $this->_conn->insert('modify_limit_table2', ['test_int' => 2]); - $this->_conn->insert('modify_limit_table2', ['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 ' . @@ -107,10 +107,10 @@ public function testModifyLimitQueryGroupBy() public function testModifyLimitQuerySubSelect() { - $this->_conn->insert('modify_limit_table', ['test_int' => 1]); - $this->_conn->insert('modify_limit_table', ['test_int' => 2]); - $this->_conn->insert('modify_limit_table', ['test_int' => 3]); - $this->_conn->insert('modify_limit_table', ['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'; @@ -121,10 +121,10 @@ public function testModifyLimitQuerySubSelect() public function testModifyLimitQueryFromSubSelect() { - $this->_conn->insert('modify_limit_table', ['test_int' => 1]); - $this->_conn->insert('modify_limit_table', ['test_int' => 2]); - $this->_conn->insert('modify_limit_table', ['test_int' => 3]); - $this->_conn->insert('modify_limit_table', ['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'; @@ -135,9 +135,9 @@ public function testModifyLimitQueryFromSubSelect() public function testModifyLimitQueryLineBreaks() { - $this->_conn->insert('modify_limit_table', ['test_int' => 1]); - $this->_conn->insert('modify_limit_table', ['test_int' => 2]); - $this->_conn->insert('modify_limit_table', ['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 = <<_conn->insert('modify_limit_table', ['test_int' => 1]); - $this->_conn->insert('modify_limit_table', ['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'; @@ -165,9 +165,9 @@ public function testModifyLimitQueryZeroOffsetNoLimit() public function assertLimitResult($expectedResults, $sql, $limit, $offset, $deterministic = true) { - $p = $this->_conn->getDatabasePlatform(); + $p = $this->connection->getDatabasePlatform(); $data = []; - foreach ($this->_conn->fetchAll($p->modifyLimitQuery($sql, $limit, $offset)) as $row) { + 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 cbe56ef9bfc..fec2e5944d6 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php @@ -151,7 +151,7 @@ protected function setUp() { parent::setUp(); - if ($this->_conn->getSchemaManager()->tablesExist('ddc1372_foobar')) { + if ($this->connection->getSchemaManager()->tablesExist('ddc1372_foobar')) { return; } @@ -162,35 +162,35 @@ protected function setUp() $table->addColumn('bar', 'string'); $table->setPrimaryKey(['id']); - $sm = $this->_conn->getSchemaManager(); + $sm = $this->connection->getSchemaManager(); $sm->createTable($table); - $this->_conn->insert('ddc1372_foobar', [ + $this->connection->insert('ddc1372_foobar', [ 'id' => 1, 'foo' => 1, 'bar' => 1, ]); - $this->_conn->insert('ddc1372_foobar', [ + $this->connection->insert('ddc1372_foobar', [ 'id' => 2, 'foo' => 1, 'bar' => 2, ]); - $this->_conn->insert('ddc1372_foobar', [ + $this->connection->insert('ddc1372_foobar', [ 'id' => 3, 'foo' => 1, 'bar' => 3, ]); - $this->_conn->insert('ddc1372_foobar', [ + $this->connection->insert('ddc1372_foobar', [ 'id' => 4, 'foo' => 1, 'bar' => 4, ]); - $this->_conn->insert('ddc1372_foobar', [ + $this->connection->insert('ddc1372_foobar', [ 'id' => 5, 'foo' => 2, 'bar' => 1, ]); - $this->_conn->insert('ddc1372_foobar', [ + $this->connection->insert('ddc1372_foobar', [ 'id' => 6, 'foo' => 2, 'bar' => 2, @@ -201,16 +201,16 @@ protected function setUp() } /** - * @param string $query - * @param array $params - * @param array $types - * @param array $expected + * @param string $query + * @param mixed[] $params + * @param int[] $types + * @param int[] $expected * * @dataProvider ticketProvider */ 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 32a43664d6e..b120823eefb 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php @@ -4,6 +4,7 @@ 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; @@ -41,13 +42,13 @@ private function getPortableConnection( $case = ColumnCase::LOWER ) { if (! $this->portableConnection) { - $params = $this->_conn->getParams(); + $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 AbstractSchemaManager $sm */ @@ -145,7 +146,7 @@ public function testPortabilityPdoSqlServer() $portability = ConnectionPortability::PORTABILITY_SQLSRV; $params = ['portability' => $portability]; - $driverMock = $this->getMockBuilder('Doctrine\\DBAL\\Driver\\PDOSqlsrv\\Driver') + $driverMock = $this->getMockBuilder(Driver::class) ->setMethods(['connect']) ->getMock(); @@ -161,6 +162,9 @@ public function testPortabilityPdoSqlServer() } /** + * @param string $field + * @param mixed[] $expected + * * @dataProvider fetchAllColumnProvider */ public function testFetchAllColumn($field, array $expected) diff --git a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php index cb32a94252c..ae4259da91f 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php @@ -35,14 +35,14 @@ protected function setUp() $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 = $this->connection->getConfiguration(); $config->setSQLLogger($this->sqlLogger = new DebugStack()); $cache = new ArrayCache(); @@ -51,7 +51,7 @@ protected function setUp() protected function tearDown() { - $this->_conn->getSchemaManager()->dropTable('caching'); + $this->connection->getSchemaManager()->dropTable('caching'); parent::tearDown(); } @@ -100,13 +100,13 @@ public function testMixingFetch() foreach ($this->expectedResult as $v) { $numExpectedResult[] = array_values($v); } - $stmt = $this->_conn->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], 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', [], [], 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); @@ -122,10 +122,10 @@ public function testIteratorFetch() public function assertStandardAndIteratorFetchAreEqual($fetchMode) { - $stmt = $this->_conn->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], 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', [], [], 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); @@ -133,7 +133,7 @@ public function assertStandardAndIteratorFetchAreEqual($fetchMode) public function testDontCloseNoCache() { - $stmt = $this->_conn->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); + $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); $data = []; @@ -141,7 +141,7 @@ public function testDontCloseNoCache() $data[] = $row; } - $stmt = $this->_conn->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); + $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); $data = []; @@ -154,12 +154,12 @@ public function testDontCloseNoCache() public function testDontFinishNoCache() { - $stmt = $this->_conn->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], 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', [], [], 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); @@ -168,13 +168,13 @@ public function testDontFinishNoCache() public function assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, $fetchMode) { - $stmt = $this->_conn->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], 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', [], [], 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); @@ -184,10 +184,10 @@ public function assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, public function testEmptyResultCache() { - $stmt = $this->_conn->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], 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', [], [], 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'); @@ -195,11 +195,11 @@ public function testEmptyResultCache() public function testChangeCacheImpl() { - $stmt = $this->_conn->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], 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 ArrayCache(); - $stmt = $this->_conn->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'emptycachekey', $secondCache)); + $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'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php index bb1f46d2787..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 { @@ -15,12 +16,12 @@ public function testGetBooleanColumn() $table->addColumn('bool', 'boolean'); $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 bbc1b5a5fdd..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 { @@ -16,14 +17,14 @@ public function testListTableWithBinary() $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()); } @@ -35,9 +36,9 @@ public function testColumnCollation() $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 80a89e29541..7dd9409b30c 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\Tests\Types\MySqlPointType; use function implode; +use function sprintf; class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase { @@ -31,15 +32,15 @@ public function testSwitchPrimaryKeyColumns() $tableOld->addColumn('foo_id', 'integer'); $tableOld->addColumn('bar_id', 'integer'); - $this->_sm->createTable($tableOld); - $tableFetched = $this->_sm->listTableDetails('switch_primary_key_columns'); + $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)); + $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); @@ -61,8 +62,8 @@ public function testDiffTableBug() $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); @@ -80,9 +81,9 @@ public function testFulltextIndex() $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')); } @@ -97,9 +98,9 @@ public function testSpatialIndex() $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')); } @@ -114,7 +115,7 @@ public function testAlterTableAddPrimaryKey() $table->addColumn('foo', 'integer'); $table->addIndex(['id'], 'idx_id'); - $this->_sm->createTable($table); + $this->schemaManager->createTable($table); $comparator = new Comparator(); $diffTable = clone $table; @@ -122,9 +123,9 @@ public function testAlterTableAddPrimaryKey() $diffTable->dropIndex('idx_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()); @@ -140,7 +141,7 @@ public function testDropPrimaryKeyWithAutoincrementColumn() $table->addColumn('foo', 'integer'); $table->setPrimaryKey(['id', 'foo']); - $this->_sm->dropAndCreateTable($table); + $this->schemaManager->dropAndCreateTable($table); $diffTable = clone $table; @@ -148,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()); @@ -161,7 +162,7 @@ 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' ); @@ -173,9 +174,9 @@ public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() $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()); @@ -186,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()); @@ -207,9 +208,9 @@ public function testColumnCollation() $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')); @@ -235,11 +236,11 @@ public function testListLobTypeColumns() $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()), @@ -284,9 +285,9 @@ 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(); @@ -307,9 +308,9 @@ public function testListDecimalTypeColumns() $table->addColumn('col', 'decimal'); $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); @@ -328,9 +329,9 @@ public function testListFloatTypeColumns() $table->addColumn('col', 'float'); $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); @@ -342,16 +343,16 @@ 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'); @@ -360,9 +361,9 @@ public function testColumnDefaultCurrentTimestamp() : void $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()); @@ -376,7 +377,7 @@ public function testColumnDefaultsAreValid() { $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]); @@ -385,13 +386,13 @@ 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( + $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' ); @@ -417,11 +418,11 @@ 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'); @@ -433,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()); @@ -456,8 +457,8 @@ public function testColumnDefaultValuesCurrentTimeAndDate() : void */ 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 @@ -477,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 bc9327677f2..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; @@ -28,13 +29,13 @@ protected function setUp() 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'); } @@ -49,14 +50,14 @@ public function testListTableWithBinary() $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()); } @@ -75,9 +76,9 @@ public function testAlterTableColumnNotNull() $table->addColumn('bar', 'string'); $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()); @@ -87,9 +88,9 @@ public function testAlterTableColumnNotNull() $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); @@ -145,16 +146,16 @@ public function testListTableDetailsWithDifferentIdentifierQuotingRequirements() ); $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)); @@ -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,16 +240,16 @@ public function testListTableColumnsSameTableNamesInDifferentSchemas() public function testListTableIndexesPrimaryKeyConstraintNameDiffersFromIndexName() { $table = new Table('list_table_indexes_pk_id_test'); - $table->setSchemaConfig($this->_sm->createSchemaConfig()); + $table->setSchemaConfig($this->schemaManager->createSchemaConfig()); $table->addColumn('id', 'integer', ['notnull' => true]); $table->addUniqueIndex(['id'], 'id_unique_index'); - $this->_sm->dropAndCreateTable($table); + $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', ['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(['id'], array_map('strtolower', $tableIndexes['primary']->getColumns())); @@ -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 4dc76ba1da0..e007eabda2a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php @@ -9,6 +9,8 @@ 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; @@ -21,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); } /** @@ -33,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); } @@ -44,7 +46,7 @@ public function testGetSearchPath() */ public function testGetSchemaNames() { - $names = $this->_sm->getSchemaNames(); + $names = $this->schemaManager->getSchemaNames(); self::assertInternalType('array', $names); self::assertNotEmpty($names); @@ -57,19 +59,19 @@ public function testGetSchemaNames() public function testSupportDomainTypeFallback() { $createDomainTypeSQL = 'CREATE DOMAIN MyMoney AS DECIMAL(18,2)'; - $this->_conn->exec($createDomainTypeSQL); + $this->connection->exec($createDomainTypeSQL); $createTableSQL = 'CREATE TABLE domain_type_test (id INT PRIMARY KEY, value MyMoney)'; - $this->_conn->exec($createTableSQL); + $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()); } /** @@ -80,8 +82,8 @@ public function testDetectsAutoIncrement() $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()); } @@ -93,8 +95,8 @@ public function testAlterTableAutoIncrementAdd() { $tableFrom = new Table('autoinc_table_add'); $column = $tableFrom->addColumn('id', 'integer'); - $this->_sm->createTable($tableFrom); - $tableFrom = $this->_sm->listTableDetails('autoinc_table_add'); + $this->schemaManager->createTable($tableFrom); + $tableFrom = $this->schemaManager->listTableDetails('autoinc_table_add'); self::assertFalse($tableFrom->getColumn('id')->getAutoincrement()); $tableTo = new Table('autoinc_table_add'); @@ -103,15 +105,15 @@ public function testAlterTableAutoIncrementAdd() $c = new Comparator(); $diff = $c->diffTable($tableFrom, $tableTo); - $sql = $this->_conn->getDatabasePlatform()->getAlterTableSQL($diff); + $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); - $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()); } @@ -123,8 +125,8 @@ public function testAlterTableAutoIncrementDrop() $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 Table('autoinc_table_drop'); @@ -132,11 +134,11 @@ public function testAlterTableAutoIncrementDrop() $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(['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()); } @@ -145,7 +147,7 @@ public function testAlterTableAutoIncrementDrop() */ public function testTableWithSchema() { - $this->_conn->exec('CREATE SCHEMA nested'); + $this->connection->exec('CREATE SCHEMA nested'); $nestedRelatedTable = new Table('nested.schemarelated'); $column = $nestedRelatedTable->addColumn('id', 'integer'); @@ -158,13 +160,13 @@ public function testTableWithSchema() $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(); + $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(['id'], $nestedSchemaTable->getPrimaryKey()->getColumns()); @@ -181,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( [ '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) + $this->connection->getDatabasePlatform()->getCreateTableSQL($table) ); } @@ -204,23 +206,23 @@ public function testFilterSchemaExpression() { $testTable = new Table('dbal204_test_prefix'); $column = $testTable->addColumn('id', 'integer'); - $this->_sm->createTable($testTable); + $this->schemaManager->createTable($testTable); $testTable = new Table('dbal204_without_prefix'); $column = $testTable->addColumn('id', 'integer'); - $this->_sm->createTable($testTable); + $this->schemaManager->createTable($testTable); - $this->_conn->getConfiguration()->setFilterSchemaAssetsExpression('#^dbal204_#'); - $names = $this->_sm->listTableNames(); + $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.'); } @@ -228,25 +230,25 @@ public function testListForeignKeys() $foreignKeys = []; $fkTable = $this->getTestTable('test_create_fk1'); for ($i = 0; $i < count($fkOptions); $i++) { - $fkTable->addColumn("foreign_key_test$i", 'integer'); + $fkTable->addColumn('foreign_key_test' . $i, 'integer'); $foreignKeys[] = new ForeignKeyConstraint( - ["foreign_key_test$i"], + ['foreign_key_test' . $i], 'test_create_fk2', ['id'], - "foreign_key_test_$i" . '_fk', + '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'); + $this->schemaManager->createForeignKey($foreignKey, 'test_create_fk1'); } - $fkeys = $this->_sm->listTableForeignKeys('test_create_fk1'); + $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(["foreign_key_test$i"], array_map('strtolower', $fkeys[$i]->getLocalColumns())); + 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') { @@ -267,9 +269,9 @@ public function testDefaultValueCharacterVarying() $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()); } @@ -283,9 +285,9 @@ public function testBooleanDefault() $table->addColumn('id', 'integer'); $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 Comparator(); $diff = $c->diffTable($table, $databaseTable); @@ -303,14 +305,14 @@ public function testListTableWithBinary() $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()); } @@ -323,9 +325,9 @@ public function testListQuotedTable() $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(); @@ -341,13 +343,13 @@ public function testListTablesExcludesViews() $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.'); + self::assertInstanceOf(Table::class, $table, 'No Table instance was found in tables array.'); if (strtolower($table->getName()) !== 'list_tables_excludes_views_test_view') { continue; } @@ -369,9 +371,9 @@ public function testPartialIndexes() $offlineTable->addColumn('email', 'string'); $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(); @@ -386,22 +388,25 @@ public function testPartialIndexes() */ public function testJsonbColumn(string $type) : void { - if (! $this->_sm->getDatabasePlatform() instanceof PostgreSQL94Platform) { + 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')); } + /** + * @return mixed[][] + */ public function jsonbColumnTypeProvider() : array { return [ @@ -423,9 +428,9 @@ public function testListNegativeColumnDefaultValue() $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()); @@ -435,6 +440,9 @@ public function testListNegativeColumnDefaultValue() self::assertEquals('(-1)', $columns['col_string']->getDefault()); } + /** + * @return mixed[][] + */ public static function serialTypes() : array { return [ @@ -449,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()); } @@ -467,14 +475,14 @@ 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()); } @@ -488,8 +496,8 @@ public function testAlterTableAutoIncrementIntToBigInt(string $from, string $to, $tableFrom = new Table('autoinc_type_modification'); $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'); @@ -499,13 +507,16 @@ public function testAlterTableAutoIncrementIntToBigInt(string $from, string $to, $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::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 [ @@ -522,6 +533,9 @@ public function getName() 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 5c68a19bcfd..f48c5157256 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php @@ -17,12 +17,12 @@ public function testCreateAndListViews() $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::assertInstanceOf(View::class, $views[$name]); self::assertEquals($name, $views[$name]->getName()); self::assertEquals($sql, $views[$name]->getSql()); } @@ -30,13 +30,13 @@ public function testCreateAndListViews() public function testDropAndCreateAdvancedIndex() { $table = $this->getTestTable('test_create_advanced_index'); - $this->_sm->dropAndCreateTable($table); - $this->_sm->dropAndCreateIndex( + $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(['test'], $tableIndexes['test']->getColumns()); @@ -54,9 +54,9 @@ public function testListTableColumnsWithFixedStringTypeColumn() $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 218c11292be..cb7f37f15d5 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php @@ -25,12 +25,12 @@ public function testDropColumnConstraints() $table->addColumn('id', 'integer'); $table->addColumn('todrop', 'decimal', ['default' => 10.2]); - $this->_sm->createTable($table); + $this->schemaManager->createTable($table); $diff = new TableDiff('sqlsrv_drop_column', [], [], [new Column('todrop', Type::getType('decimal'))]); - $this->_sm->alterTable($diff); + $this->schemaManager->alterTable($diff); - $columns = $this->_sm->listTableColumns('sqlsrv_drop_column'); + $columns = $this->schemaManager->listTableColumns('sqlsrv_drop_column'); self::assertCount(1, $columns); } @@ -39,22 +39,22 @@ public function testColumnCollation() $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(); + $platform = $this->schemaManager->getDatabasePlatform(); $table = new Table('sqlsrv_default_constraints'); $table->addColumn('no_default', 'string'); $table->addColumn('df_integer', 'integer', ['default' => 666]); @@ -66,8 +66,8 @@ public function testDefaultConstraints() $table->addColumn('df_current_date', 'date', ['default' => $platform->getCurrentDateSQL()]); $table->addColumn('df_current_time', 'time', ['default' => $platform->getCurrentTimeSQL()]); - $this->_sm->createTable($table); - $columns = $this->_sm->listTableColumns('sqlsrv_default_constraints'); + $this->schemaManager->createTable($table); + $columns = $this->schemaManager->listTableColumns('sqlsrv_default_constraints'); self::assertNull($columns['no_default']->getDefault()); self::assertEquals(666, $columns['df_integer']->getDefault()); @@ -122,8 +122,8 @@ public function testDefaultConstraints() ['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()); @@ -160,8 +160,8 @@ public function testDefaultConstraints() $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()); @@ -187,9 +187,9 @@ public function testColumnComments() $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()); @@ -303,9 +303,9 @@ public function testColumnComments() $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()); @@ -345,9 +345,9 @@ public function testPkOrdering() $table->addColumn('colA', 'integer', ['notnull' => true]); $table->addColumn('colB', 'integer', ['notnull' => true]); $table->setPrimaryKey(['colB', 'colA']); - $this->_sm->createTable($table); + $this->schemaManager->createTable($table); - $indexes = $this->_sm->listTableIndexes('sqlsrv_pk_ordering'); + $indexes = $this->schemaManager->listTableIndexes('sqlsrv_pk_ordering'); self::assertCount(1, $indexes); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php index 0a20f5ca4d9..425039fa023 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -4,6 +4,7 @@ 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; @@ -18,6 +19,15 @@ 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; @@ -39,7 +49,7 @@ class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase { /** @var AbstractSchemaManager */ - protected $_sm; + protected $schemaManager; protected function getPlatformName() { @@ -55,11 +65,11 @@ protected function setUp() $dbms = $this->getPlatformName(); - if ($this->_conn->getDatabasePlatform()->getName() !== $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(); } @@ -67,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; } @@ -84,21 +94,21 @@ 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'; @@ -107,13 +117,13 @@ public function testDropsDatabaseWithActiveConnections() $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()); } /** @@ -121,17 +131,20 @@ 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( @@ -146,14 +159,14 @@ static function (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.'); @@ -174,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); @@ -191,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')); + $this->connection->executeUpdate($this->schemaManager->getDatabasePlatform()->getCreateSchemaSQL('test_create_schema')); - $namespaces = $this->_sm->listNamespaceNames(); + $namespaces = $this->schemaManager->listNamespaceNames(); $namespaces = array_map('strtolower', $namespaces); } @@ -212,14 +225,14 @@ 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); + self::assertInstanceOf(Table::class, $table); if (strtolower($table->getName()) !== 'list_tables_test') { continue; } @@ -253,15 +266,15 @@ 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::assertInstanceOf(IntegerType::class, $columns['id']->gettype()); self::assertEquals(false, $columns['id']->getunsigned()); self::assertEquals(true, $columns['id']->getnotnull()); self::assertEquals(null, $columns['id']->getdefault()); @@ -270,7 +283,7 @@ public function testListTableColumns() 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::assertInstanceOf(StringType::class, $columns['test']->gettype()); self::assertEquals(255, $columns['test']->getlength()); self::assertEquals(false, $columns['test']->getfixed()); self::assertEquals(false, $columns['test']->getnotnull()); @@ -279,7 +292,7 @@ public function testListTableColumns() self::assertEquals('foo', strtolower($columns['foo']->getname())); self::assertEquals(2, array_search('foo', $columnsKeys)); - self::assertInstanceOf('Doctrine\DBAL\Types\TextType', $columns['foo']->gettype()); + 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()); @@ -288,7 +301,7 @@ public function testListTableColumns() self::assertEquals('bar', strtolower($columns['bar']->getname())); self::assertEquals(3, array_search('bar', $columnsKeys)); - self::assertInstanceOf('Doctrine\DBAL\Types\DecimalType', $columns['bar']->gettype()); + 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()); @@ -300,7 +313,7 @@ public function testListTableColumns() self::assertEquals('baz1', strtolower($columns['baz1']->getname())); self::assertEquals(4, array_search('baz1', $columnsKeys)); - self::assertInstanceOf('Doctrine\DBAL\Types\DateTimeType', $columns['baz1']->gettype()); + 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()); @@ -330,12 +343,12 @@ public function testListTableColumnsWithFixedStringColumn() $table = new Table($tableName); $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()); } @@ -344,7 +357,7 @@ public function testListTableColumnsDispatchEvent() { $table = $this->createListTableColumns(); - $this->_sm->dropAndCreateTable($table); + $this->schemaManager->dropAndCreateTable($table); $listenerMock = $this ->getMockBuilder('ListTableColumnsDispatchEventListener') @@ -354,16 +367,16 @@ public function testListTableColumnsDispatchEvent() ->expects($this->exactly(7)) ->method('onSchemaColumnDefinition'); - $oldEventManager = $this->_sm->getDatabasePlatform()->getEventManager(); + $oldEventManager = $this->schemaManager->getDatabasePlatform()->getEventManager(); $eventManager = new EventManager(); $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() @@ -372,7 +385,7 @@ public function testListTableIndexesDispatchEvent() $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') @@ -382,27 +395,27 @@ public function testListTableIndexesDispatchEvent() ->expects($this->exactly(3)) ->method('onSchemaIndexDefinition'); - $oldEventManager = $this->_sm->getDatabasePlatform()->getEventManager(); + $oldEventManager = $this->schemaManager->getDatabasePlatform()->getEventManager(); $eventManager = new EventManager(); $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 Comparator(); $diff = $comparator->diffTable($offlineTable, $onlineTable); @@ -416,9 +429,9 @@ public function testListTableIndexes() $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)); @@ -442,10 +455,10 @@ public function testDropAndCreateIndex() { $table = $this->getTestTable('test_create_index'); $table->addUniqueIndex(['test'], 'test'); - $this->_sm->dropAndCreateTable($table); + $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())); @@ -456,25 +469,25 @@ public function testDropAndCreateIndex() 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', ['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::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())); @@ -484,7 +497,7 @@ public function testCreateTableWithForeignKeys() public function testListForeignKeys() { - if (! $this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) { + if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Does not support foreign key constraints.'); } @@ -499,13 +512,13 @@ public function testListForeignKeys() ['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::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())); @@ -526,20 +539,20 @@ 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')); @@ -551,9 +564,9 @@ public function testAlterTableScenario() $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')); @@ -561,9 +574,9 @@ public function testAlterTableScenario() $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(['foo'], array_map('strtolower', $table->getIndex('foo_idx')->getColumns())); @@ -574,9 +587,9 @@ public function testAlterTableScenario() $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(['foo', 'foreign_key_test'], array_map('strtolower', $table->getIndex('foo_idx')->getColumns())); @@ -585,9 +598,9 @@ public function testAlterTableScenario() $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')); @@ -601,13 +614,13 @@ public function testAlterTableScenario() $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()) { + if (! $this->schemaManager->getDatabasePlatform()->supportsForeignKeyConstraints()) { return; } @@ -622,7 +635,7 @@ public function testAlterTableScenario() public function testTableInNamespace() { - if (! $this->_sm->getDatabasePlatform()->supportsSchemas()) { + if (! $this->schemaManager->getDatabasePlatform()->supportsSchemas()) { $this->markTestSkipped('Schema definition is not supported by this platform.'); } @@ -630,23 +643,23 @@ 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.'); } @@ -657,25 +670,25 @@ public function testCreateAndListViews() $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->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()); } @@ -685,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(['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()); } @@ -707,7 +720,7 @@ 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.'); } @@ -716,18 +729,18 @@ public function testUpdateSchemaWithForeignKeyRenaming() $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(['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(['id']); @@ -737,9 +750,9 @@ public function testUpdateSchemaWithForeignKeyRenaming() $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')); @@ -752,7 +765,7 @@ 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.'); } @@ -771,17 +784,17 @@ public function testRenameIndexUsedInForeignKeyConstraint() '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')); @@ -793,9 +806,9 @@ 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.'); } @@ -803,9 +816,9 @@ public function testGetColumnComment() $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()); @@ -825,9 +838,9 @@ public function testGetColumnComment() ) ); - $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()); } @@ -837,9 +850,9 @@ 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.'); } @@ -849,15 +862,15 @@ public function testAutomaticallyAppendCommentOnMarkedColumns() $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::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('Doctrine\DBAL\Types\ArrayType', $columns['arr']->getType(), 'The Doctrine2 should be detected from comment hint.'); + self::assertInstanceOf(ArrayType::class, $columns['arr']->getType(), 'The Doctrine2 should be detected from comment hint.'); } /** @@ -865,9 +878,9 @@ 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.'); } @@ -876,13 +889,13 @@ public function testCommentHintOnDateIntervalTypeColumn() $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::assertInstanceOf(DateIntervalType::class, $columns['date_interval']->getType(), 'The Doctrine2 should be detected from comment hint.'); } /** @@ -896,7 +909,7 @@ public function testChangeColumnsTypeWithDefaultValue() $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; @@ -914,14 +927,14 @@ public function testChangeColumnsTypeWithDefaultValue() 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()); } @@ -935,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')); @@ -945,18 +958,18 @@ public function testListTableWithBlob() } /** - * @param string $name - * @param array $data + * @param string $name + * @param mixed[] $data * * @return Table */ - protected function createTestTable($name = 'test_table', $data = []) + 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; } @@ -964,7 +977,7 @@ protected function createTestTable($name = 'test_table', $data = []) protected function getTestTable($name, $options = []) { $table = new Table($name, [], [], [], false, $options); - $table->setSchemaConfig($this->_sm->createSchemaConfig()); + $table->setSchemaConfig($this->schemaManager->createSchemaConfig()); $table->addColumn('id', 'integer', ['notnull' => true]); $table->setPrimaryKey(['id']); $table->addColumn('test', 'string', ['length' => 255]); @@ -975,7 +988,7 @@ protected function getTestTable($name, $options = []) protected function getTestCompositeTable($name) { $table = new Table($name, [], [], [], false, []); - $table->setSchemaConfig($this->_sm->createSchemaConfig()); + $table->setSchemaConfig($this->schemaManager->createSchemaConfig()); $table->addColumn('id', 'integer', ['notnull' => true]); $table->addColumn('other_id', 'integer', ['notnull' => true]); $table->setPrimaryKey(['id', 'other_id']); @@ -987,7 +1000,7 @@ 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.'); + self::assertInstanceOf(Table::class, $table, 'No Table instance was found in tables array.'); if (strtolower($table->getName()) !== 'list_tables_test_new_name') { continue; } @@ -999,12 +1012,12 @@ protected function assertHasTable($tables, $tableName) 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 ForeignKeyConstraint( ['id', 'foreign_key_test'], @@ -1013,13 +1026,13 @@ public function testListForeignKeysComposite() '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::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())); } @@ -1040,9 +1053,9 @@ public function testColumnDefaultLifecycle() $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()); @@ -1065,9 +1078,9 @@ public function testColumnDefaultLifecycle() $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()); @@ -1088,24 +1101,24 @@ public function testListTableWithBinary() $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'; @@ -1113,7 +1126,7 @@ public function testListTableDetailsWithFullQualifiedTableName() $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', ['autoincrement' => true]); @@ -1123,27 +1136,27 @@ public function testListTableDetailsWithFullQualifiedTableName() $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.'); } @@ -1151,15 +1164,15 @@ public function testCommentStringsAreQuoted() $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.'); } @@ -1169,11 +1182,11 @@ public function testCommentNotDuplicated() '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', ['columnDefinition' => $columnDefinition, 'comment' => 'unexpected_column_comment']); - $sql = $this->_conn->getDatabasePlatform()->getCreateTableSQL($table); + $sql = $this->connection->getDatabasePlatform()->getCreateTableSQL($table); self::assertContains('expected+column+comment', $sql[0]); self::assertNotContains('unexpected_column_comment', $sql[0]); @@ -1185,9 +1198,9 @@ public function testCommentNotDuplicated() */ 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.'); } @@ -1196,9 +1209,9 @@ public function testAlterColumnComment($comment1, $expectedComment1, $comment2, $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()); @@ -1214,11 +1227,11 @@ public function testAlterColumnComment($comment1, $expectedComment1, $comment2, $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()); @@ -1249,7 +1262,7 @@ 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.'); } @@ -1264,10 +1277,10 @@ public function testDoesNotListIndexesImplicitlyCreatedByForeignKeys() $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); @@ -1279,11 +1292,11 @@ public function testDoesNotListIndexesImplicitlyCreatedByForeignKeys() */ public function removeJsonArrayTable() : void { - if (! $this->_sm->tablesExist(['json_array_test'])) { + if (! $this->schemaManager->tablesExist(['json_array_test'])) { return; } - $this->_sm->dropTable('json_array_test'); + $this->schemaManager->dropTable('json_array_test'); } /** @@ -1295,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); } @@ -1309,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); @@ -1337,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); @@ -1359,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); @@ -1381,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); @@ -1403,17 +1416,17 @@ 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); } @@ -1424,11 +1437,14 @@ public function testComparatorShouldNotAddCommentToJsonTypeSinceItIsTheDefaultNo */ 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'; @@ -1445,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.'); } @@ -1458,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; } @@ -1484,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.'); } @@ -1493,11 +1509,11 @@ 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(), + $this->schemaManager->listSequences(), static function (Sequence $sequence) use ($sequenceName) : bool { return strcasecmp($sequence->getName(), $sequenceName) === 0; } @@ -1521,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 ca42061b695..659e6d8dff2 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php @@ -2,8 +2,10 @@ 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; @@ -20,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'; - $this->_sm->createDatabase($path); + $this->schemaManager->createDatabase($path); self::assertFileExists($path); - $this->_sm->dropDatabase($path); + $this->schemaManager->dropDatabase($path); self::assertFileNotExists($path); } @@ -38,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; $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'); @@ -62,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); } @@ -79,7 +81,7 @@ public function createListTableColumns() public function testListForeignKeysFromExistingDatabase() { - $this->_conn->exec(<<connection->exec(<<_sm->listTableForeignKeys('user')); + self::assertEquals($expected, $this->schemaManager->listTableForeignKeys('user')); } public function testColumnCollation() @@ -124,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')); @@ -144,14 +146,14 @@ public function testListTableWithBinary() $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()); } @@ -165,7 +167,7 @@ public function testNonDefaultPKOrder() 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); @@ -194,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); @@ -222,21 +224,21 @@ public function testDiffListIntegerAutoincrementTableColumns($integerType, $unsi $offlineTable->addColumn('id', $integerType, ['autoincrement' => true, 'unsigned' => $unsigned]); $offlineTable->setPrimaryKey(['id']); - $this->_sm->dropAndCreateTable($offlineTable); + $this->schemaManager->dropAndCreateTable($offlineTable); - $onlineTable = $this->_sm->listTableDetails($tableName); + $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() { @@ -259,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 7c8585c3f77..7aa374b461b 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php @@ -20,15 +20,15 @@ protected function setUp() $table = new Table('stmt_test'); $table->addColumn('id', 'integer'); $table->addColumn('name', 'text', ['notnull' => false]); - $this->_conn->getSchemaManager()->dropAndCreateTable($table); + $this->connection->getSchemaManager()->dropAndCreateTable($table); } public function testStatementIsReusableAfterClosingCursor() { - $this->_conn->insert('stmt_test', ['id' => 1]); - $this->_conn->insert('stmt_test', ['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(); @@ -46,7 +46,7 @@ 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'); @@ -56,9 +56,9 @@ public function testReuseStatementWithLongerResults() '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([ ['param1', 'X'], @@ -68,7 +68,7 @@ public function testReuseStatementWithLongerResults() '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([ @@ -83,7 +83,7 @@ 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', ['length' => 0xFFFFFFFF]); $sm->createTable($table); @@ -105,15 +105,15 @@ public function testFetchLongBlob() EOF ); - $this->_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)); @@ -121,27 +121,27 @@ public function testFetchLongBlob() public function testIncompletelyFetchedStatementDoesNotBlockConnection() { - $this->_conn->insert('stmt_test', ['id' => 1]); - $this->_conn->insert('stmt_test', ['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 = $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', ['id' => 1]); - $this->_conn->insert('stmt_test', ['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([1]); $id = $stmt->fetchColumn(); @@ -156,10 +156,10 @@ public function testReuseStatementAfterClosingCursor() public function testReuseStatementWithParameterBoundByReference() { - $this->_conn->insert('stmt_test', ['id' => 1]); - $this->_conn->insert('stmt_test', ['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; @@ -173,10 +173,10 @@ public function testReuseStatementWithParameterBoundByReference() public function testReuseStatementWithReboundValue() { - $this->_conn->insert('stmt_test', ['id' => 1]); - $this->_conn->insert('stmt_test', ['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(); @@ -189,10 +189,10 @@ public function testReuseStatementWithReboundValue() public function testReuseStatementWithReboundParam() { - $this->_conn->insert('stmt_test', ['id' => 1]); - $this->_conn->insert('stmt_test', ['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); @@ -210,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()); } @@ -227,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(); @@ -240,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)); @@ -251,9 +251,9 @@ public function testFetchFromNonExecutedStatementWithClosedCursor(callable $fetc */ public function testFetchFromExecutedStatementWithClosedCursor(callable $fetch, $expected) { - $this->_conn->insert('stmt_test', ['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(); @@ -286,9 +286,9 @@ static function (Statement $stmt) { 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 182a337f295..f62b992015c 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php @@ -20,7 +20,7 @@ protected function setUp() { parent::setUp(); - $platform = $this->_conn->getDatabasePlatform(); + $platform = $this->connection->getDatabasePlatform(); if ($platform->getName() === 'sqlite') { $this->markTestSkipped('TableGenerator does not work with SQLite'); } @@ -31,11 +31,11 @@ protected function setUp() $schema->visit($visitor); foreach ($schema->toSql($platform) as $sql) { - $this->_conn->exec($sql); + $this->connection->exec($sql); } } catch (Throwable $e) { } - $this->generator = new TableGenerator($this->_conn); + $this->generator = new TableGenerator($this->connection); } public function testNextVal() @@ -51,9 +51,9 @@ public function testNextVal() public function testNextValNotAffectedByOuterTransactions() { - $this->_conn->beginTransaction(); + $this->connection->beginTransaction(); $id1 = $this->generator->nextValue('tbl1'); - $this->_conn->rollBack(); + $this->connection->rollBack(); $id2 = $this->generator->nextValue('tbl1'); self::assertGreaterThan(0, $id1, 'First id has to be larger than 0'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php b/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php index 5ef755ee4da..87a776c7e06 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php @@ -13,17 +13,17 @@ protected function setUp() { parent::setUp(); try { - $this->_conn->exec($this->_conn->getDatabasePlatform()->getDropTableSQL('nontemporary')); + $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)); + $tempTable = $this->connection->getDatabasePlatform()->getTemporaryTableName('my_temporary'); + $this->connection->exec($this->connection->getDatabasePlatform()->getDropTemporaryTableSQL($tempTable)); } catch (Throwable $e) { } } @@ -38,33 +38,33 @@ protected function tearDown() */ public function testDropTemporaryTableNotAutoCommitTransaction() { - if ($this->_conn->getDatabasePlatform()->getName() === 'sqlanywhere' || - $this->_conn->getDatabasePlatform()->getName() === 'oracle') { + 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(); + $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(['id']); - $this->_conn->getSchemaManager()->createTable($table); + $this->connection->getSchemaManager()->createTable($table); - $this->_conn->beginTransaction(); - $this->_conn->insert('nontemporary', ['id' => 1]); - $this->_conn->exec($platform->getDropTemporaryTableSQL($tempTable)); - $this->_conn->insert('nontemporary', ['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'); + $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.'); } @@ -75,12 +75,12 @@ public function testDropTemporaryTableNotAutoCommitTransaction() */ public function testCreateTemporaryTableNotAutoCommitTransaction() { - if ($this->_conn->getDatabasePlatform()->getName() === 'sqlanywhere' || - $this->_conn->getDatabasePlatform()->getName() === 'oracle') { + 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(); + $platform = $this->connection->getDatabasePlatform(); $columnDefinitions = ['id' => ['type' => Type::getType('integer'), 'notnull' => true]]; $tempTable = $platform->getTemporaryTableName('my_temporary'); @@ -91,22 +91,22 @@ public function testCreateTemporaryTableNotAutoCommitTransaction() $table->addColumn('id', 'integer'); $table->setPrimaryKey(['id']); - $this->_conn->getSchemaManager()->createTable($table); + $this->connection->getSchemaManager()->createTable($table); - $this->_conn->beginTransaction(); - $this->_conn->insert('nontemporary', ['id' => 1]); + $this->connection->beginTransaction(); + $this->connection->insert('nontemporary', ['id' => 1]); - $this->_conn->exec($createTempTableSQL); - $this->_conn->insert('nontemporary', ['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)); + $this->connection->exec($platform->getDropTemporaryTableSQL($tempTable)); } catch (Throwable $e) { } - $rows = $this->_conn->fetchAll('SELECT * FROM nontemporary'); + $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 b43da19b52d..b18b6cbdaf5 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php @@ -12,7 +12,7 @@ class DBAL168Test extends DbalFunctionalTestCase { public function testDomainsTable() { - if ($this->_conn->getDatabasePlatform()->getName() !== 'postgresql') { + if ($this->connection->getDatabasePlatform()->getName() !== 'postgresql') { $this->markTestSkipped('PostgreSQL only test'); } @@ -22,8 +22,8 @@ public function testDomainsTable() $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 63d93ffafa7..1adf993250f 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php @@ -14,38 +14,38 @@ 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 Table('DBAL202'); $table->addColumn('id', 'integer'); $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 b44e7542489..af41670690a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php @@ -15,7 +15,7 @@ protected function setUp() { parent::setUp(); - $platform = $this->_conn->getDatabasePlatform()->getName(); + $platform = $this->connection->getDatabasePlatform()->getName(); if (in_array($platform, ['mysql', 'sqlite'])) { return; } @@ -25,7 +25,7 @@ protected function setUp() 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'); } @@ -36,7 +36,7 @@ public function testGuidShouldMatchPattern() */ public function testGuidShouldBeRandom() { - $statement = $this->_conn->prepare($this->getSelectGuidSql()); + $statement = $this->connection->prepare($this->getSelectGuidSql()); $guids = []; for ($i = 0; $i < 99; $i++) { @@ -51,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 2298898d74d..a9dbdb1e109 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL461Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL461Test.php @@ -2,6 +2,8 @@ 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; @@ -14,8 +16,8 @@ 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); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php index 208db06d19b..fa98ecb3eca 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php @@ -15,7 +15,7 @@ protected function setUp() { parent::setUp(); - if ($this->_conn->getDatabasePlatform()->getName() === 'postgresql') { + if ($this->connection->getDatabasePlatform()->getName() === 'postgresql') { return; } @@ -28,9 +28,9 @@ public function testSearchPathSchemaChanges() $table->addColumn('id', 'integer'); $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 --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php index 0709ffd5632..827a9124277 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php @@ -20,15 +20,15 @@ protected function setUp() { parent::setUp(); - $platform = $this->_conn->getDatabasePlatform()->getName(); + $platform = $this->connection->getDatabasePlatform()->getName(); 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; @@ -37,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(); @@ -45,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 = ?', [$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 = ?', [$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 = ?', [$id]); + $row = $this->connection->fetchAssoc('SELECT bool_col FROM dbal630 WHERE id = ?', [$id]); self::assertFalse($row['bool_col']); } @@ -95,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 = ?', [$id]); + $row = $this->connection->fetchAssoc('SELECT bool_col FROM dbal630_allow_nulls WHERE id = ?', [$id]); self::assertSame($databaseConvertedValue, $row['bool_col']); } @@ -119,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), @@ -131,11 +131,11 @@ 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 = ?', [$id]); + $row = $this->connection->fetchAssoc('SELECT bool_col FROM dbal630_allow_nulls WHERE id = ?', [$id]); self::assertSame($databaseConvertedValue, $row['bool_col']); } @@ -143,7 +143,7 @@ public function testBooleanConversionNullParamEmulatedPreparesWithBooleanTypeInB /** * Boolean conversion mapping provider * - * @return array + * @return mixed[][] */ public function booleanTypeConversionUsingBooleanTypeProvider() { @@ -158,7 +158,7 @@ public function booleanTypeConversionUsingBooleanTypeProvider() /** * Boolean conversion mapping provider * - * @return array + * @return mixed[][] */ public function booleanTypeConversionWithoutPdoTypeProvider() { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php index 393e3457eed..ee0bce44e08 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php @@ -14,7 +14,7 @@ protected function setUp() { parent::setUp(); - $platform = $this->_conn->getDatabasePlatform()->getName(); + $platform = $this->connection->getDatabasePlatform()->getName(); if (in_array($platform, ['sqlite'])) { return; @@ -25,7 +25,7 @@ protected function setUp() 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 289d5c7fd9a..333e7364088 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php @@ -21,7 +21,7 @@ protected function setUp() parent::setUp(); /** @var AbstractSchemaManager $sm */ - $sm = $this->_conn->getSchemaManager(); + $sm = $this->connection->getSchemaManager(); $table = new Table('type_conversion'); $table->addColumn('id', 'integer', ['notnull' => false]); @@ -42,7 +42,7 @@ protected function setUp() $table->setPrimaryKey(['id']); try { - $this->_conn->getSchemaManager()->createTable($table); + $this->connection->getSchemaManager()->createTable($table); } catch (Throwable $e) { } } @@ -83,12 +83,12 @@ public function testIdempotentDataConversion($type, $originalValue, $expectedPhp { $columnName = 'test_' . $type; $typeInstance = Type::getType($type); - $insertionValue = $typeInstance->convertToDatabaseValue($originalValue, $this->_conn->getDatabasePlatform()); + $insertionValue = $typeInstance->convertToDatabaseValue($originalValue, $this->connection->getDatabasePlatform()); - $this->_conn->insert('type_conversion', ['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()); + $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); 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 60c32fe9615..039fed14f8e 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php @@ -27,10 +27,10 @@ protected function setUp() $table->addColumn('test_string', 'string', ['notnull' => false]); $table->setPrimaryKey(['id']); - $this->_conn->getSchemaManager()->createTable($table); + $this->connection->getSchemaManager()->createTable($table); } catch (Throwable $e) { } - $this->_conn->executeUpdate('DELETE FROM write_table'); + $this->connection->executeUpdate('DELETE FROM write_table'); } /** @@ -39,16 +39,16 @@ 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]); + $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])); + 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!'); } @@ -56,7 +56,7 @@ public function testExecuteUpdate() public function testExecuteUpdateWithTypes() { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; - $affected = $this->_conn->executeUpdate( + $affected = $this->connection->executeUpdate( $sql, [1, 'foo'], [ParameterType::INTEGER, ParameterType::STRING] @@ -68,7 +68,7 @@ public function testExecuteUpdateWithTypes() public function testPrepareRowCountReturnsAffectedRows() { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; - $stmt = $this->_conn->prepare($sql); + $stmt = $this->connection->prepare($sql); $stmt->bindValue(1, 1); $stmt->bindValue(2, 'foo'); @@ -80,7 +80,7 @@ public function testPrepareRowCountReturnsAffectedRows() public function testPrepareWithPdoTypes() { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; - $stmt = $this->_conn->prepare($sql); + $stmt = $this->connection->prepare($sql); $stmt->bindValue(1, 1, ParameterType::INTEGER); $stmt->bindValue(2, 'foo', ParameterType::STRING); @@ -92,7 +92,7 @@ public function testPrepareWithPdoTypes() public function testPrepareWithDbalTypes() { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; - $stmt = $this->_conn->prepare($sql); + $stmt = $this->connection->prepare($sql); $stmt->bindValue(1, 1, Type::getType('integer')); $stmt->bindValue(2, 'foo', Type::getType('string')); @@ -104,7 +104,7 @@ public function testPrepareWithDbalTypes() public function testPrepareWithDbalTypeNames() { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; - $stmt = $this->_conn->prepare($sql); + $stmt = $this->connection->prepare($sql); $stmt->bindValue(1, 1, 'integer'); $stmt->bindValue(2, 'foo', 'string'); @@ -115,8 +115,8 @@ public function testPrepareWithDbalTypeNames() public function insertRows() { - self::assertEquals(1, $this->_conn->insert('write_table', ['test_int' => 1, 'test_string' => 'foo'])); - self::assertEquals(1, $this->_conn->insert('write_table', ['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() @@ -128,30 +128,30 @@ public function testDelete() { $this->insertRows(); - self::assertEquals(1, $this->_conn->delete('write_table', ['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', ['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', ['test_string' => 'bar'], ['test_string' => 'foo'])); - self::assertEquals(2, $this->_conn->update('write_table', ['test_string' => 'baz'], ['test_string' => 'bar'])); - self::assertEquals(0, $this->_conn->update('write_table', ['test_string' => 'baz'], ['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', ['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.'); @@ -159,25 +159,25 @@ public function testLastInsertId() public function testLastInsertIdSequence() { - if (! $this->_conn->getDatabasePlatform()->supportsSequences()) { + if (! $this->connection->getDatabasePlatform()->supportsSequences()) { $this->markTestSkipped('Test only works on platforms with sequences.'); } $sequence = new Sequence('write_table_id_seq'); try { - $this->_conn->getSchemaManager()->createSequence($sequence); + $this->connection->getSchemaManager()->createSequence($sequence); } catch (Throwable $e) { } - $sequences = $this->_conn->getSchemaManager()->listSequences(); + $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); @@ -185,11 +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)); } /** @@ -199,15 +199,15 @@ public function testInsertWithKeyValueTypes() { $testString = new DateTime('2013-04-14 10:10:10'); - $this->_conn->insert( + $this->connection->insert( 'write_table', ['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); } /** @@ -217,7 +217,7 @@ public function testUpdateWithKeyValueTypes() { $testString = new DateTime('2013-04-14 10:10:10'); - $this->_conn->insert( + $this->connection->insert( 'write_table', ['test_int' => '30', 'test_string' => $testString], ['test_string' => 'datetime', 'test_int' => 'integer'] @@ -225,16 +225,16 @@ public function testUpdateWithKeyValueTypes() $testString = new DateTime('2013-04-15 10:10:10'); - $this->_conn->update( + $this->connection->update( 'write_table', ['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); } /** @@ -243,22 +243,22 @@ public function testUpdateWithKeyValueTypes() public function testDeleteWithKeyValueTypes() { $val = new DateTime('2013-04-14 10:10:10'); - $this->_conn->insert( + $this->connection->insert( 'write_table', ['test_int' => '30', 'test_string' => $val], ['test_string' => 'datetime', 'test_int' => 'integer'] ); - $this->_conn->delete('write_table', ['test_int' => 30, 'test_string' => $val], ['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())) { $this->markTestSkipped( @@ -271,12 +271,12 @@ public function testEmptyIdentityInsert() $table->setPrimaryKey(['id']); try { - $this->_conn->getSchemaManager()->dropTable($table->getQuotedName($platform)); + $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() @@ -285,13 +285,13 @@ 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); } @@ -301,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/Mocks/MockPlatform.php b/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php index cb6ec18df32..6a3f3d8e376 100644 --- a/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php +++ b/tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php @@ -8,34 +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__); } + /** + * {@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()'; } + /** + * {@inheritDoc} + */ public function getClobTypeDeclarationSQL(array $field) { return 'DUMMYCLOB'; diff --git a/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php b/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php index e60bace5dca..c4efa1b8377 100644 --- a/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php +++ b/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php @@ -23,7 +23,7 @@ public function testDateTimeTypeConversionPerformance($count) { $value = new DateTime(); $type = Type::getType('datetime'); - $platform = $this->_conn->getDatabasePlatform(); + $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 3b81ef680c6..63148215f22 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php @@ -15,7 +15,7 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase { public function testModifyLimitQueryWitoutLimit() { - $sql = $this->_platform->modifyLimitQuery('SELECT n FROM Foo', null, 10); + $sql = $this->platform->modifyLimitQuery('SELECT n FROM Foo', null, 10); self::assertEquals('SELECT n FROM Foo LIMIT 18446744073709551615 OFFSET 10', $sql); } @@ -24,7 +24,7 @@ public function testGenerateMixedCaseTableCreate() $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)); } @@ -45,54 +45,54 @@ public function getGenerateAlterTableSql() 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([]) + $this->platform->getIntegerTypeDeclarationSQL([]) ); self::assertEquals( 'INT AUTO_INCREMENT', - $this->_platform->getIntegerTypeDeclarationSQL(['autoincrement' => true]) + $this->platform->getIntegerTypeDeclarationSQL(['autoincrement' => true]) ); self::assertEquals( 'INT AUTO_INCREMENT', - $this->_platform->getIntegerTypeDeclarationSQL( + $this->platform->getIntegerTypeDeclarationSQL( ['autoincrement' => true, 'primary' => true] ) ); @@ -102,35 +102,35 @@ public function testGeneratesTypeDeclarationForStrings() { self::assertEquals( 'CHAR(10)', - $this->_platform->getVarcharTypeDeclarationSQL( + $this->platform->getVarcharTypeDeclarationSQL( ['length' => 10, 'fixed' => true] ) ); self::assertEquals( 'VARCHAR(50)', - $this->_platform->getVarcharTypeDeclarationSQL(['length' => 50]), + $this->platform->getVarcharTypeDeclarationSQL(['length' => 50]), 'Variable string declaration is not correct' ); self::assertEquals( 'VARCHAR(255)', - $this->_platform->getVarcharTypeDeclarationSQL([]), + $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() @@ -166,7 +166,7 @@ public function testUniquePrimaryKey() $c = new Comparator(); $diff = $c->diffTable($oldTable, $keyTable); - $sql = $this->_platform->getAlterTableSQL($diff); + $sql = $this->platform->getAlterTableSQL($diff); self::assertEquals([ 'ALTER TABLE foo ADD PRIMARY KEY (bar)', @@ -176,13 +176,13 @@ public function testUniquePrimaryKey() 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); } @@ -191,9 +191,9 @@ public function testModifyLimitQueryWithEmptyOffset() */ public function testGetDateTimeTypeDeclarationSql() { - self::assertEquals('DATETIME', $this->_platform->getDateTimeTypeDeclarationSQL(['version' => false])); - self::assertEquals('TIMESTAMP', $this->_platform->getDateTimeTypeDeclarationSQL(['version' => true])); - self::assertEquals('DATETIME', $this->_platform->getDateTimeTypeDeclarationSQL([])); + 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() @@ -220,11 +220,11 @@ public function testChangeIndexWithForeignKeys() $unique = new Index('uniq', ['col'], true); $diff = new TableDiff('test', [], [], [], [$unique], [], [$index]); - $sql = $this->_platform->getAlterTableSQL($diff); + $sql = $this->platform->getAlterTableSQL($diff); self::assertEquals(['ALTER TABLE test DROP INDEX idx, ADD UNIQUE INDEX uniq (col)'], $sql); $diff = new TableDiff('test', [], [], [], [$index], [], [$unique]); - $sql = $this->_platform->getAlterTableSQL($diff); + $sql = $this->platform->getAlterTableSQL($diff); self::assertEquals(['ALTER TABLE test DROP INDEX uniq, ADD INDEX idx (col)'], $sql); } @@ -263,7 +263,7 @@ public function testCreateTableWithFulltextIndex() $index = $table->getIndex('fulltext_text'); $index->addFlag('fulltext'); - $sql = $this->_platform->getCreateTableSQL($table); + $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); } @@ -277,32 +277,32 @@ public function testCreateTableWithSpatialIndex() $index = $table->getIndex('spatial_text'); $index->addFlag('spatial'); - $sql = $this->_platform->getCreateTableSQL($table); + $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(['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([])); + 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(['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([])); + 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([])); } /** @@ -323,7 +323,7 @@ public function testAlterTableAddPrimaryKey() self::assertEquals( ['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)) + $this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable)) ); } @@ -349,7 +349,7 @@ public function testAlterPrimaryKeyWithAutoincrementColumn() 'ALTER TABLE alter_primary_key DROP PRIMARY KEY', 'ALTER TABLE alter_primary_key ADD PRIMARY KEY (foo)', ], - $this->_platform->getAlterTableSQL($comparator->diffTable($table, $diffTable)) + $this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable)) ); } @@ -374,7 +374,7 @@ public function testDropPrimaryKeyWithAutoincrementColumn() '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)) + $this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable)) ); } @@ -401,7 +401,7 @@ public function testDropNonAutoincrementColumnFromCompositePrimaryKeyWithAutoinc '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)) ); } @@ -428,7 +428,7 @@ public function testAddNonAutoincrementColumnToPrimaryKeyWithAutoincrementColumn '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)) ); } @@ -448,7 +448,7 @@ public function testAddAutoIncrementPrimaryKey() $c = new Comparator(); $diff = $c->diffTable($oldTable, $keyTable); - $sql = $this->_platform->getAlterTableSQL($diff); + $sql = $this->platform->getAlterTableSQL($diff); self::assertEquals(['ALTER TABLE foo ADD id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)'], $sql); } @@ -458,7 +458,7 @@ public function testNamedPrimaryKey() $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([ 'ALTER TABLE mytable DROP PRIMARY KEY', @@ -486,17 +486,17 @@ public function testAlterPrimaryKeyWithNewColumn() '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() @@ -506,13 +506,13 @@ protected function getBinaryMaxLength() public function testReturnsBinaryTypeDeclarationSQL() { - 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('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(['fixed' => true])); - self::assertSame('BINARY(255)', $this->_platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 0])); - self::assertSame('BINARY(65535)', $this->_platform->getBinaryTypeDeclarationSQL(['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])); } /** @@ -523,13 +523,13 @@ 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() @@ -543,7 +543,7 @@ public function testDoesNotPropagateForeignKeyCreationForNonSupportingEngines() self::assertSame( ['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( + $this->platform->getCreateTableSQL( $table, AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS ) @@ -557,7 +557,7 @@ public function testDoesNotPropagateForeignKeyCreationForNonSupportingEngines() '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( + $this->platform->getCreateTableSQL( $table, AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS ) @@ -583,7 +583,7 @@ public function testDoesNotPropagateForeignKeyAlterationForNonSupportingEngines( $tableDiff->changedForeignKeys = $changedForeignKeys; $tableDiff->removedForeignKeys = $removedForeignKeys; - self::assertEmpty($this->_platform->getAlterTableSQL($tableDiff)); + self::assertEmpty($this->platform->getAlterTableSQL($tableDiff)); $table->addOption('engine', 'InnoDB'); @@ -600,7 +600,7 @@ public function testDoesNotPropagateForeignKeyAlterationForNonSupportingEngines( '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) ); } @@ -672,7 +672,7 @@ public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() self::assertSame( ['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) + $this->platform->getCreateTableSQL($table) ); $diffTable = clone $table; @@ -683,7 +683,7 @@ public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() $comparator = new Comparator(); - self::assertEmpty($this->_platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))); + self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))); } /** @@ -724,7 +724,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL() */ public function testReturnsGuidTypeDeclarationSQL() { - self::assertSame('CHAR(36)', $this->_platform->getGuidTypeDeclarationSQL([])); + self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([])); } /** @@ -842,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); } /** @@ -850,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); } /** @@ -858,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); } /** @@ -866,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); } /** @@ -874,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); } /** @@ -882,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); } /** @@ -890,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); @@ -907,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') ); } @@ -926,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 9b303a6e76e..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; @@ -23,13 +25,13 @@ abstract class AbstractPlatformTestCase extends DbalTestCase { /** @var AbstractPlatform */ - protected $_platform; + protected $platform; abstract public function createPlatform(); protected function setUp() { - $this->_platform = $this->createPlatform(); + $this->platform = $this->createPlatform(); } /** @@ -37,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)); } /** @@ -52,14 +54,14 @@ 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)); } /** @@ -68,11 +70,11 @@ public function testQuoteSingleIdentifier() */ 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() { @@ -89,25 +91,25 @@ public function getReturnsForeignKeyReferentialActionSQL() 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'); } /** @@ -120,9 +122,9 @@ public function testRegistersCommentedDoctrineMappingTypeImplicitly() } $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)); } /** @@ -131,7 +133,7 @@ public function testRegistersCommentedDoctrineMappingTypeImplicitly() */ public function testIsCommentedDoctrineType(Type $type, $commented) { - self::assertSame($commented, $this->_platform->isCommentedDoctrineType($type)); + self::assertSame($commented, $this->platform->isCommentedDoctrineType($type)); } public function getIsCommentedDoctrineType() @@ -145,7 +147,7 @@ public function getIsCommentedDoctrineType() $data[$typeName] = [ $type, - $type->requiresSQLCommentHint($this->_platform), + $type->requiresSQLCommentHint($this->platform), ]; } @@ -156,8 +158,8 @@ 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() @@ -167,7 +169,7 @@ public function testGeneratesTableCreationSql() $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]); } @@ -180,7 +182,7 @@ public function testGenerateTableWithMultiColumnUniqueIndex() $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); } @@ -192,7 +194,7 @@ public function testGeneratesIndexCreationSql() self::assertEquals( $this->getGenerateIndexSql(), - $this->_platform->getCreateIndexSQL($indexDef, 'mytable') + $this->platform->getCreateIndexSQL($indexDef, 'mytable') ); } @@ -202,7 +204,7 @@ public function testGeneratesUniqueIndexCreationSql() { $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); } @@ -219,14 +221,14 @@ public function testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes() $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'); @@ -238,7 +240,7 @@ public function testGeneratesForeignKeyCreationSql() { $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()); } @@ -247,15 +249,15 @@ abstract public function getGenerateForeignKeySql(); public function testGeneratesConstraintCreationSql() { $idx = new Index('constraint_name', ['test'], true, false); - $sql = $this->_platform->getCreateConstraintSQL($idx, 'test'); + $sql = $this->platform->getCreateConstraintSQL($idx, 'test'); self::assertEquals($this->getGenerateConstraintUniqueIndexSql(), $sql); $pk = new Index('constraint_name', ['test'], true, true); - $sql = $this->_platform->getCreateConstraintSQL($pk, 'test'); + $sql = $this->platform->getCreateConstraintSQL($pk, 'test'); self::assertEquals($this->getGenerateConstraintPrimaryIndexSql(), $sql); $fk = new ForeignKeyConstraint(['fk_name'], 'foreign', ['id'], 'constraint_fk'); - $sql = $this->_platform->getCreateConstraintSQL($fk, 'test'); + $sql = $this->platform->getCreateConstraintSQL($fk, 'test'); self::assertEquals($this->getGenerateConstraintForeignKeySql($fk), $sql); } @@ -263,14 +265,14 @@ public function testGeneratesForeignKeySqlOnlyWhenSupportingForeignKeys() { $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'); } } @@ -284,7 +286,7 @@ 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); } @@ -298,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); } @@ -314,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(); @@ -356,7 +361,7 @@ public function testGeneratesTableAlterationSql() ['type', 'notnull', 'default'] ); - $sql = $this->_platform->getAlterTableSQL($tableDiff); + $sql = $this->platform->getAlterTableSQL($tableDiff); self::assertEquals($expectedSql, $sql); } @@ -364,7 +369,7 @@ public function testGeneratesTableAlterationSql() public function testGetCustomColumnDeclarationSql() { $field = ['columnDefinition' => 'MEDIUMINT(6) UNSIGNED']; - self::assertEquals('foo MEDIUMINT(6) UNSIGNED', $this->_platform->getColumnDeclarationSQL('foo', $field)); + self::assertEquals('foo MEDIUMINT(6) UNSIGNED', $this->platform->getColumnDeclarationSQL('foo', $field)); } public function testGetCreateTableSqlDispatchEvent() @@ -382,13 +387,13 @@ public function testGetCreateTableSqlDispatchEvent() $eventManager = new EventManager(); $eventManager->addEventListener([Events::onSchemaCreateTable, Events::onSchemaCreateTableColumn], $listenerMock); - $this->_platform->setEventManager($eventManager); + $this->platform->setEventManager($eventManager); $table = new Table('test'); $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() @@ -403,9 +408,9 @@ public function testGetDropTableSqlDispatchEvent() $eventManager = new EventManager(); $eventManager->addEventListener([Events::onSchemaDropTable], $listenerMock); - $this->_platform->setEventManager($eventManager); + $this->platform->setEventManager($eventManager); - $this->_platform->getDropTableSQL('TABLE'); + $this->platform->getDropTableSQL('TABLE'); } public function testGetAlterTableSqlDispatchEvent() @@ -447,7 +452,7 @@ public function testGetAlterTableSqlDispatchEvent() ]; $eventManager->addEventListener($events, $listenerMock); - $this->_platform->setEventManager($eventManager); + $this->platform->setEventManager($eventManager); $table = new Table('mytable'); $table->addColumn('removed', 'integer'); @@ -469,7 +474,7 @@ public function testGetAlterTableSqlDispatchEvent() ); $tableDiff->renamedColumns['renamed'] = new Column('renamed2', Type::getType('integer'), []); - $this->_platform->getAlterTableSQL($tableDiff); + $this->platform->getAlterTableSQL($tableDiff); } /** @@ -481,7 +486,7 @@ public function testCreateTableColumnComments() $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)); } /** @@ -509,7 +514,7 @@ public function testAlterTableColumnComments() ['comment'] ); - self::assertEquals($this->getAlterTableColumnCommentsSQL(), $this->_platform->getAlterTableSQL($tableDiff)); + self::assertEquals($this->getAlterTableColumnCommentsSQL(), $this->platform->getAlterTableSQL($tableDiff)); } public function testCreateTableColumnTypeComments() @@ -519,7 +524,7 @@ public function testCreateTableColumnTypeComments() $table->addColumn('data', 'array'); $table->setPrimaryKey(['id']); - self::assertEquals($this->getCreateTableColumnTypeCommentsSQL(), $this->_platform->getCreateTableSQL($table)); + self::assertEquals($this->getCreateTableColumnTypeCommentsSQL(), $this->platform->getCreateTableSQL($table)); } public function getCreateTableColumnCommentsSQL() @@ -545,7 +550,7 @@ public function testGetDefaultValueDeclarationSQL() 'default' => 'non_timestamp', ]; - self::assertEquals(" DEFAULT 'non_timestamp'", $this->_platform->getDefaultValueDeclarationSQL($field)); + self::assertEquals(" DEFAULT 'non_timestamp'", $this->platform->getDefaultValueDeclarationSQL($field)); } /** @@ -557,12 +562,12 @@ 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) ); } } @@ -577,7 +582,7 @@ public function testGetDefaultValueDeclarationSQLForIntegerTypes() self::assertEquals( ' DEFAULT 1', - $this->_platform->getDefaultValueDeclarationSQL($field) + $this->platform->getDefaultValueDeclarationSQL($field) ); } } @@ -587,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), @@ -596,7 +601,7 @@ public function testGetDefaultValueDeclarationSQLForDateType() : void self::assertSame( ' DEFAULT ' . $currentDateSql, - $this->_platform->getDefaultValueDeclarationSQL($field) + $this->platform->getDefaultValueDeclarationSQL($field) ); } } @@ -606,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')); } @@ -621,7 +626,7 @@ public function testQuotedColumnInPrimaryKeyPropagation() $table->addColumn('create', 'string'); $table->setPrimaryKey(['create']); - $sql = $this->_platform->getCreateTableSQL($table); + $sql = $this->platform->getCreateTableSQL($table); self::assertEquals($this->getQuotedColumnInPrimaryKeySQL(), $sql); } @@ -639,7 +644,7 @@ public function testQuotedColumnInIndexPropagation() $table->addColumn('create', 'string'); $table->addIndex(['create']); - $sql = $this->_platform->getCreateTableSQL($table); + $sql = $this->platform->getCreateTableSQL($table); self::assertEquals($this->getQuotedColumnInIndexSQL(), $sql); } @@ -649,7 +654,7 @@ public function testQuotedNameInIndexSQL() $table->addColumn('column1', 'string'); $table->addIndex(['column1'], '`key`'); - $sql = $this->_platform->getCreateTableSQL($table); + $sql = $this->platform->getCreateTableSQL($table); self::assertEquals($this->getQuotedNameInIndexSQL(), $sql); } @@ -687,7 +692,7 @@ public function testQuotedColumnInForeignKeyPropagation() $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); } @@ -700,7 +705,7 @@ public function testQuotesReservedKeywordInUniqueConstraintDeclarationSQL() self::assertSame( $this->getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(), - $this->_platform->getUniqueConstraintDeclarationSQL('select', $index) + $this->platform->getUniqueConstraintDeclarationSQL('select', $index) ); } @@ -716,7 +721,7 @@ public function testQuotesReservedKeywordInTruncateTableSQL() { self::assertSame( $this->getQuotesReservedKeywordInTruncateTableSQL(), - $this->_platform->getTruncateTableSQL('select') + $this->platform->getTruncateTableSQL('select') ); } @@ -733,12 +738,12 @@ public function testQuotesReservedKeywordInIndexDeclarationSQL() $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) ); } @@ -757,7 +762,7 @@ protected function supportsInlineIndexDeclaration() public function testSupportsCommentOnStatement() { - self::assertSame($this->supportsCommentOnStatement(), $this->_platform->supportsCommentOnStatement()); + self::assertSame($this->supportsCommentOnStatement(), $this->platform->supportsCommentOnStatement()); } /** @@ -773,7 +778,7 @@ protected function supportsCommentOnStatement() */ public function testGetCreateSchemaSQL() { - $this->_platform->getCreateSchemaSQL('schema'); + $this->platform->getCreateSchemaSQL('schema'); } /** @@ -793,8 +798,8 @@ public function testAlterTableChangeQuotedColumn() ); self::assertContains( - $this->_platform->quoteIdentifier('select'), - implode(';', $this->_platform->getAlterTableSQL($tableDiff)) + $this->platform->quoteIdentifier('select'), + implode(';', $this->platform->getAlterTableSQL($tableDiff)) ); } @@ -803,7 +808,7 @@ public function testAlterTableChangeQuotedColumn() */ public function testUsesSequenceEmulatedIdentityColumns() { - self::assertFalse($this->_platform->usesSequenceEmulatedIdentityColumns()); + self::assertFalse($this->platform->usesSequenceEmulatedIdentityColumns()); } /** @@ -812,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() @@ -827,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() @@ -840,7 +845,7 @@ protected function getBinaryMaxLength() */ public function testReturnsBinaryTypeDeclarationSQL() { - $this->_platform->getBinaryTypeDeclarationSQL([]); + $this->platform->getBinaryTypeDeclarationSQL([]); } public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() @@ -853,7 +858,7 @@ public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() */ public function hasNativeJsonType() { - self::assertFalse($this->_platform->hasNativeJsonType()); + self::assertFalse($this->platform->hasNativeJsonType()); } /** @@ -868,8 +873,8 @@ public function testReturnsJsonTypeDeclarationSQL() ]; self::assertSame( - $this->_platform->getClobTypeDeclarationSQL($column), - $this->_platform->getJsonTypeDeclarationSQL($column) + $this->platform->getClobTypeDeclarationSQL($column), + $this->platform->getJsonTypeDeclarationSQL($column) ); } @@ -888,7 +893,7 @@ public function testAlterTableRenameIndex() self::assertSame( $this->getAlterTableRenameIndexSQL(), - $this->_platform->getAlterTableSQL($tableDiff) + $this->platform->getAlterTableSQL($tableDiff) ); } @@ -919,7 +924,7 @@ public function testQuotesAlterTableRenameIndex() self::assertSame( $this->getQuotedAlterTableRenameIndexSQL(), - $this->_platform->getAlterTableSQL($tableDiff) + $this->platform->getAlterTableSQL($tableDiff) ); } @@ -973,14 +978,14 @@ public function testQuotesAlterTableRenameColumn() 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 */ @@ -1015,14 +1020,14 @@ public function testQuotesAlterTableChangeColumnLength() 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 */ @@ -1043,7 +1048,7 @@ public function testAlterTableRenameIndexInSchema() self::assertSame( $this->getAlterTableRenameIndexInSchemaSQL(), - $this->_platform->getAlterTableSQL($tableDiff) + $this->platform->getAlterTableSQL($tableDiff) ); } @@ -1074,7 +1079,7 @@ public function testQuotesAlterTableRenameIndexInSchema() self::assertSame( $this->getQuotedAlterTableRenameIndexInSchemaSQL(), - $this->_platform->getAlterTableSQL($tableDiff) + $this->platform->getAlterTableSQL($tableDiff) ); } @@ -1096,9 +1101,9 @@ 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)) ); } @@ -1108,8 +1113,8 @@ public function testQuotesDropForeignKeySQL() $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() @@ -1128,8 +1133,8 @@ public function testQuotesDropConstraintSQL() $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() @@ -1144,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() @@ -1156,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') ); } @@ -1171,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 !') ); } /** * @see testGetCommentOnColumnSQL * - * @return array + * @return string[] */ abstract protected function getCommentOnColumnSQL(); @@ -1190,9 +1195,9 @@ public function testGetCommentOnColumnSQL() self::assertSame( $this->getCommentOnColumnSQL(), [ - $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 ] ); } @@ -1203,11 +1208,11 @@ public function testGetCommentOnColumnSQL() */ 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() @@ -1265,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() @@ -1282,15 +1287,15 @@ 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) ); } @@ -1300,7 +1305,7 @@ public function testQuoteStringLiteral() */ public function testReturnsGuidTypeDeclarationSQL() { - $this->_platform->getGuidTypeDeclarationSQL([]); + $this->platform->getGuidTypeDeclarationSQL([]); } /** @@ -1323,11 +1328,11 @@ public function testGeneratesAlterTableRenameColumnSQL() ['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(); @@ -1364,12 +1369,12 @@ public function testQuotesTableIdentifiersInAlterTableSQL() self::assertSame( $this->getQuotesTableIdentifiersInAlterTableSQL(), - $this->_platform->getAlterTableSQL($tableDiff) + $this->platform->getAlterTableSQL($tableDiff) ); } /** - * @return array + * @return string[] */ abstract protected function getQuotesTableIdentifiersInAlterTableSQL(); @@ -1394,7 +1399,7 @@ public function testAlterStringToFixedString() ['fixed'] ); - $sql = $this->_platform->getAlterTableSQL($tableDiff); + $sql = $this->platform->getAlterTableSQL($tableDiff); $expectedSql = $this->getAlterStringToFixedStringSQL(); @@ -1402,7 +1407,7 @@ public function testAlterStringToFixedString() } /** - * @return array + * @return string[] */ abstract protected function getAlterStringToFixedStringSQL(); @@ -1430,26 +1435,28 @@ public function testGeneratesAlterTableRenameIndexUsedByForeignKeySQL() self::assertSame( $this->getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(), - $this->_platform->getAlterTableSQL($tableDiff) + $this->platform->getAlterTableSQL($tableDiff) ); } /** - * @return array + * @return string[] */ abstract protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(); /** + * @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() { @@ -1464,16 +1471,18 @@ public function getGeneratesDecimalTypeDeclarationSQL() } /** + * @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() { @@ -1491,7 +1500,7 @@ 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/', '\\') ); } @@ -1501,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 06b1604912b..5c0da268107 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types\Type; +use function sprintf; abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCase { @@ -63,7 +64,7 @@ public function testGeneratesForeignKeySqlForNonStandardOptions() ); self::assertEquals( 'CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE', - $this->_platform->getForeignKeyDeclarationSQL($foreignKey) + $this->platform->getForeignKeyDeclarationSQL($foreignKey) ); $foreignKey = new ForeignKeyConstraint( @@ -75,7 +76,7 @@ public function testGeneratesForeignKeySqlForNonStandardOptions() ); self::assertEquals( 'CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) MATCH full NOT DEFERRABLE INITIALLY IMMEDIATE', - $this->_platform->getForeignKeyDeclarationSQL($foreignKey) + $this->platform->getForeignKeyDeclarationSQL($foreignKey) ); $foreignKey = new ForeignKeyConstraint( @@ -87,7 +88,7 @@ public function testGeneratesForeignKeySqlForNonStandardOptions() ); self::assertEquals( 'CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) DEFERRABLE INITIALLY IMMEDIATE', - $this->_platform->getForeignKeyDeclarationSQL($foreignKey) + $this->platform->getForeignKeyDeclarationSQL($foreignKey) ); $foreignKey = new ForeignKeyConstraint( @@ -99,7 +100,7 @@ public function testGeneratesForeignKeySqlForNonStandardOptions() ); self::assertEquals( 'CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) NOT DEFERRABLE INITIALLY DEFERRED', - $this->_platform->getForeignKeyDeclarationSQL($foreignKey) + $this->platform->getForeignKeyDeclarationSQL($foreignKey) ); $foreignKey = new ForeignKeyConstraint( @@ -111,7 +112,7 @@ public function testGeneratesForeignKeySqlForNonStandardOptions() ); self::assertEquals( 'CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) NOT DEFERRABLE INITIALLY DEFERRED', - $this->_platform->getForeignKeyDeclarationSQL($foreignKey) + $this->platform->getForeignKeyDeclarationSQL($foreignKey) ); $foreignKey = new ForeignKeyConstraint( @@ -123,44 +124,44 @@ public function testGeneratesForeignKeySqlForNonStandardOptions() ); self::assertEquals( 'CONSTRAINT my_fk FOREIGN KEY (foreign_id) REFERENCES my_table (id) MATCH full DEFERRABLE INITIALLY DEFERRED', - $this->_platform->getForeignKeyDeclarationSQL($foreignKey) + $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() @@ -169,9 +170,12 @@ public function testGenerateTableWithAutoincrement() $column = $table->addColumn('id', 'integer'); $column->setAutoincrement(true); - self::assertEquals(['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 [ @@ -191,9 +195,9 @@ public function testGenerateTableWithAutoincrementDoesNotSetDefault(string $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); } /** @@ -207,9 +211,9 @@ public function testCreateTableWithAutoincrementAndNotNullAddsConstraint(string $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); } /** @@ -218,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), @@ -233,15 +237,15 @@ public function testGeneratesTypeDeclarationForIntegers() { self::assertEquals( 'INT', - $this->_platform->getIntegerTypeDeclarationSQL([]) + $this->platform->getIntegerTypeDeclarationSQL([]) ); self::assertEquals( 'SERIAL', - $this->_platform->getIntegerTypeDeclarationSQL(['autoincrement' => true]) + $this->platform->getIntegerTypeDeclarationSQL(['autoincrement' => true]) ); self::assertEquals( 'SERIAL', - $this->_platform->getIntegerTypeDeclarationSQL( + $this->platform->getIntegerTypeDeclarationSQL( ['autoincrement' => true, 'primary' => true] ) ); @@ -251,18 +255,18 @@ public function testGeneratesTypeDeclarationForStrings() { self::assertEquals( 'CHAR(10)', - $this->_platform->getVarcharTypeDeclarationSQL( + $this->platform->getVarcharTypeDeclarationSQL( ['length' => 10, 'fixed' => true] ) ); self::assertEquals( 'VARCHAR(50)', - $this->_platform->getVarcharTypeDeclarationSQL(['length' => 50]), + $this->platform->getVarcharTypeDeclarationSQL(['length' => 50]), 'Variable string declaration is not correct' ); self::assertEquals( 'VARCHAR(255)', - $this->_platform->getVarcharTypeDeclarationSQL([]), + $this->platform->getVarcharTypeDeclarationSQL([]), 'Long string declaration is not correct' ); } @@ -277,41 +281,41 @@ public function testGeneratesSequenceSqlCommands() $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()); } /** @@ -324,13 +328,13 @@ 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); } @@ -485,7 +489,7 @@ public function testThrowsExceptionWithInvalidBooleanLiteral() public function testGetCreateSchemaSQL() { $schemaName = 'schema'; - $sql = $this->_platform->getCreateSchemaSQL($schemaName); + $sql = $this->platform->getCreateSchemaSQL($schemaName); self::assertEquals('CREATE SCHEMA ' . $schemaName, $sql); } @@ -537,7 +541,7 @@ public function testAlterDecimalPrecisionScale() ['precision', 'scale'] ); - $sql = $this->_platform->getAlterTableSQL($tableDiff); + $sql = $this->platform->getAlterTableSQL($tableDiff); $expectedSql = [ 'ALTER TABLE mytable ALTER dloo1 TYPE NUMERIC(16, 6)', @@ -564,7 +568,7 @@ public function testDroppingConstraintsBeforeColumns() $comparator = new Comparator(); $tableDiff = $comparator->diffTable($oldTable, $newTable); - $sql = $this->_platform->getAlterTableSQL($tableDiff); + $sql = $this->platform->getAlterTableSQL($tableDiff); $expectedSql = [ 'ALTER TABLE mytable DROP CONSTRAINT FK_6B2BD609727ACA70', @@ -580,7 +584,7 @@ public function testDroppingConstraintsBeforeColumns() */ public function testUsesSequenceEmulatedIdentityColumns() { - self::assertTrue($this->_platform->usesSequenceEmulatedIdentityColumns()); + self::assertTrue($this->platform->usesSequenceEmulatedIdentityColumns()); } /** @@ -588,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')); } /** @@ -598,7 +602,7 @@ public function testReturnsIdentitySequenceName() public function testCreateSequenceWithCache($cacheSize, $expectedSql) { $sequence = new Sequence('foo', 1, 1, $cacheSize); - self::assertContains($expectedSql, $this->_platform->getCreateSequenceSQL($sequence)); + self::assertContains($expectedSql, $this->platform->getCreateSequenceSQL($sequence)); } public function dataCreateSequenceWithCache() @@ -620,13 +624,13 @@ protected function getBinaryMaxLength() public function testReturnsBinaryTypeDeclarationSQL() { - 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([])); + self::assertSame('BYTEA', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); + self::assertSame('BYTEA', $this->platform->getBinaryTypeDeclarationSQL(['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])); + 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() @@ -646,7 +650,7 @@ 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', ['length' => 42]); @@ -656,7 +660,7 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType() // 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'); @@ -666,7 +670,7 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType() // 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))); } /** @@ -691,7 +695,7 @@ protected function getQuotedAlterTableRenameIndexSQL() /** * PostgreSQL boolean strings provider * - * @return array + * @return mixed[] */ public function pgBooleanProvider() { @@ -778,7 +782,7 @@ public function testGetNullCommentOnColumnSQL() { self::assertEquals( 'COMMENT ON COLUMN mytable.id IS NULL', - $this->_platform->getCommentOnColumnSQL('mytable', 'id', null) + $this->platform->getCommentOnColumnSQL('mytable', 'id', null) ); } @@ -787,7 +791,7 @@ public function testGetNullCommentOnColumnSQL() */ public function testReturnsGuidTypeDeclarationSQL() { - self::assertSame('UUID', $this->_platform->getGuidTypeDeclarationSQL([])); + self::assertSame('UUID', $this->platform->getGuidTypeDeclarationSQL([])); } /** @@ -842,10 +846,10 @@ public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers() $tableDiff = $comparator->diffTable($table1, $table2); - self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); + self::assertInstanceOf(TableDiff::class, $tableDiff); self::assertSame( ['COMMENT ON COLUMN "foo"."bar" IS \'baz\''], - $this->_platform->getAlterTableSQL($tableDiff) + $this->platform->getAlterTableSQL($tableDiff) ); } @@ -894,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')); } /** @@ -905,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') ); } @@ -916,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') ); } @@ -925,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); } /** @@ -935,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 ); @@ -946,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); } /** @@ -954,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); } /** @@ -964,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 ); @@ -975,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); } /** @@ -985,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 ); @@ -998,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 ef75fa7dfe6..1341c9e8819 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php @@ -52,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) ); } @@ -88,25 +88,25 @@ 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([]) + $this->platform->getIntegerTypeDeclarationSQL([]) ); self::assertEquals( 'INT IDENTITY', - $this->_platform->getIntegerTypeDeclarationSQL(['autoincrement' => true]) + $this->platform->getIntegerTypeDeclarationSQL(['autoincrement' => true]) ); self::assertEquals( 'INT IDENTITY', - $this->_platform->getIntegerTypeDeclarationSQL( + $this->platform->getIntegerTypeDeclarationSQL( ['autoincrement' => true, 'primary' => true] ) ); @@ -116,50 +116,50 @@ public function testGeneratesTypeDeclarationsForStrings() { self::assertEquals( 'NCHAR(10)', - $this->_platform->getVarcharTypeDeclarationSQL( + $this->platform->getVarcharTypeDeclarationSQL( ['length' => 10, 'fixed' => true] ) ); self::assertEquals( 'NVARCHAR(50)', - $this->_platform->getVarcharTypeDeclarationSQL(['length' => 50]), + $this->platform->getVarcharTypeDeclarationSQL(['length' => 50]), 'Variable string declaration is not correct' ); self::assertEquals( 'NVARCHAR(255)', - $this->_platform->getVarcharTypeDeclarationSQL([]), + $this->platform->getVarcharTypeDeclarationSQL([]), 'Long string declaration is not correct' ); - self::assertSame('VARCHAR(MAX)', $this->_platform->getClobTypeDeclarationSQL([])); + self::assertSame('VARCHAR(MAX)', $this->platform->getClobTypeDeclarationSQL([])); self::assertSame( 'VARCHAR(MAX)', - $this->_platform->getClobTypeDeclarationSQL(['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() @@ -181,7 +181,7 @@ public function testModifyLimitQuery() { $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); } @@ -189,19 +189,19 @@ public function testModifyLimitQueryWithEmptyOffset() { $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'; $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); } @@ -210,7 +210,7 @@ public function testModifyLimitQueryWithAscOrderBy() { $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); } @@ -219,7 +219,7 @@ public function testModifyLimitQueryWithLowercaseOrderBy() { $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); } @@ -227,7 +227,7 @@ public function testModifyLimitQueryWithDescOrderBy() { $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); } @@ -235,7 +235,7 @@ public function testModifyLimitQueryWithMultipleOrderBy() { $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); } @@ -243,7 +243,7 @@ public function testModifyLimitQueryWithSubSelect() { $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); } @@ -251,34 +251,34 @@ public function testModifyLimitQueryWithSubSelectAndOrder() { $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'; $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'; $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'; $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'; $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); } @@ -286,7 +286,7 @@ public function testModifyLimitQueryWithFromColumnNames() { $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); } @@ -305,7 +305,7 @@ public function testModifyLimitQueryWithExtraLongQuery() $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); } @@ -314,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); } @@ -344,7 +344,7 @@ public function testModifyLimitQueryWithSubSelectInSelectList() '(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); } @@ -354,8 +354,8 @@ 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 ' . @@ -374,7 +374,7 @@ public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause() 'FROM user u ' . "WHERE u.status = 'disabled' " . 'ORDER BY u.username DESC'; - $sql = $this->_platform->modifyLimitQuery($querySql, 10, 5); + $sql = $this->platform->modifyLimitQuery($querySql, 10, 5); $this->expectCteWithMinAndMaxRowNums($alteredSql, 6, 15, $sql); } @@ -395,7 +395,7 @@ public function testModifyLimitQueryWithAggregateFunctionInOrderByClause() 'FROM operator_model_operator ' . 'GROUP BY code ' . 'ORDER BY MAX(heading_id) DESC'; - $sql = $this->_platform->modifyLimitQuery($querySql, 1, 0); + $sql = $this->platform->modifyLimitQuery($querySql, 1, 0); $this->expectCteWithMaxRowNum($alteredSql, 1, $sql); } @@ -419,7 +419,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBas . 'LEFT JOIN join_table t2 ON t1.id = t2.table_id' . ') dctrn_result ' . 'ORDER BY id_0 ASC'; - $sql = $this->_platform->modifyLimitQuery($querySql, 5); + $sql = $this->platform->modifyLimitQuery($querySql, 5); $this->expectCteWithMaxRowNum($alteredSql, 5, $sql); } @@ -443,7 +443,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoi . 'LEFT JOIN join_table t2 ON t1.id = t2.table_id' . ') dctrn_result ' . 'ORDER BY name_1 ASC'; - $sql = $this->_platform->modifyLimitQuery($querySql, 5); + $sql = $this->platform->modifyLimitQuery($querySql, 5); $this->expectCteWithMaxRowNum($alteredSql, 5, $sql); } @@ -467,7 +467,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBo . '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); + $sql = $this->platform->modifyLimitQuery($querySql, 5); $this->expectCteWithMaxRowNum($alteredSql, 5, $sql); } @@ -478,7 +478,7 @@ public function testModifyLimitSubquerySimple() . '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); + $sql = $this->platform->modifyLimitQuery($querySql, 20); $this->expectCteWithMaxRowNum($alteredSql, 20, $sql); } @@ -487,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')); } /** @@ -497,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')); } /** @@ -509,7 +509,7 @@ public function testCreateClusteredIndex() { $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')); } /** @@ -522,7 +522,7 @@ public function testCreateNonClusteredPrimaryKeyInTable() $table->setPrimaryKey(['id']); $table->getIndex('primary')->addFlag('nonclustered'); - self::assertEquals(['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)); } /** @@ -532,13 +532,13 @@ public function testCreateNonClusteredPrimaryKey() { $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 Index('idx', ['id'], false, true); - self::assertEquals('ALTER TABLE tbl ADD PRIMARY KEY (id)', $this->_platform->getCreateIndexSQL($idx, 'tbl')); + self::assertEquals('ALTER TABLE tbl ADD PRIMARY KEY (id)', $this->platform->getCreateIndexSQL($idx, 'tbl')); } protected function getQuotedColumnInPrimaryKeySQL() @@ -575,7 +575,7 @@ protected function getQuotedColumnInForeignKeySQL() public function testGetCreateSchemaSQL() { $schemaName = 'schema'; - $sql = $this->_platform->getCreateSchemaSQL($schemaName); + $sql = $this->platform->getCreateSchemaSQL($schemaName); self::assertEquals('CREATE SCHEMA ' . $schemaName, $sql); } @@ -590,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() @@ -603,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() @@ -618,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() @@ -633,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)); } /** @@ -705,7 +705,7 @@ public function testGeneratesCreateTableSQLWithColumnComments() "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) ); } @@ -888,7 +888,7 @@ public function testGeneratesAlterTableSQLWithColumnComments() "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) ); } @@ -897,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() @@ -980,13 +980,13 @@ protected function getBinaryMaxLength() public function testReturnsBinaryTypeDeclarationSQL() { - 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('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(['fixed' => true])); - self::assertSame('BINARY(255)', $this->_platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 0])); - self::assertSame('BINARY(8000)', $this->_platform->getBinaryTypeDeclarationSQL(['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])); } /** @@ -995,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])); } /** @@ -1045,7 +1045,7 @@ public function testChangeColumnsTypeWithDefaultValue() new Column('col_string', Type::getType('string'), ['default' => 666]) ); - $expected = $this->_platform->getAlterTableSQL($tableDiff); + $expected = $this->platform->getAlterTableSQL($tableDiff); self::assertSame( $expected, @@ -1121,7 +1121,7 @@ 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() @@ -1144,7 +1144,7 @@ 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() @@ -1191,7 +1191,7 @@ 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() @@ -1301,7 +1301,7 @@ public function getGeneratesIdentifierNamesInAlterTableSQL() */ public function testReturnsGuidTypeDeclarationSQL() { - self::assertSame('UNIQUEIDENTIFIER', $this->_platform->getGuidTypeDeclarationSQL([])); + self::assertSame('UNIQUEIDENTIFIER', $this->platform->getGuidTypeDeclarationSQL([])); } /** @@ -1409,12 +1409,12 @@ public function testModifyLimitQueryWithTopNSubQueryWithOrderBy() { $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'; $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); } @@ -1423,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); } /** @@ -1433,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 ); @@ -1444,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); } /** @@ -1454,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 ); @@ -1465,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); } /** @@ -1475,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 ); @@ -1486,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), @@ -1495,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') ); } @@ -1521,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 841021b9653..ce2b7df42a8 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php @@ -14,7 +14,7 @@ class DB2PlatformTest extends AbstractPlatformTestCase { /** @var DB2Platform */ - protected $_platform; + protected $platform; public function createPlatform() { @@ -137,7 +137,7 @@ public function getCreateTableColumnTypeCommentsSQL() public function testHasCorrectPlatformName() { - self::assertEquals('db2', $this->_platform->getName()); + self::assertEquals('db2', $this->platform->getName()); } public function testGeneratesCreateTableSQLWithCommonIndexes() @@ -155,7 +155,7 @@ public function testGeneratesCreateTableSQLWithCommonIndexes() 'CREATE INDEX IDX_D87F7E0C5E237E06 ON test (name)', 'CREATE INDEX composite_idx ON test (id, name)', ], - $this->_platform->getCreateTableSQL($table) + $this->platform->getCreateTableSQL($table) ); } @@ -181,7 +181,7 @@ public function testGeneratesCreateTableSQLWithForeignKeyConstraints() '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) ); } @@ -195,7 +195,7 @@ public function testGeneratesCreateTableSQLWithCheckConstraints() self::assertEquals( ['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) + $this->platform->getCreateTableSQL($table) ); } @@ -208,71 +208,71 @@ public function testGeneratesColumnTypesDeclarationSQL() '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)); + 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() @@ -286,22 +286,22 @@ public function getIsCommentedDoctrineType() 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( + $this->platform->getCreatePrimaryKeySQL( new Index('any_pk_name', ['a', 'b'], true, true), 'foo' ) @@ -310,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() @@ -407,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])); } /** @@ -421,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])); } /** @@ -494,7 +494,7 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() */ public function testReturnsGuidTypeDeclarationSQL() { - self::assertSame('CHAR(36)', $this->_platform->getGuidTypeDeclarationSQL([])); + self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([])); } /** @@ -555,11 +555,11 @@ public function testGeneratesAlterColumnSQL($changedProperty, Column $column, $e $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() { @@ -686,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); } /** @@ -694,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); } /** @@ -702,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 95938f477c1..7171ad714d6 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php @@ -17,7 +17,7 @@ public function createPlatform() : MariaDb1027Platform public function testHasNativeJsonType() : void { - self::assertFalse($this->_platform->hasNativeJsonType()); + self::assertFalse($this->platform->hasNativeJsonType()); } /** @@ -27,13 +27,13 @@ public function testHasNativeJsonType() : void */ 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 bef9aa6a545..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([])); + 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')); } /** diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php index 3372ef94051..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 da210021a85..5af2b0cf571 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php @@ -15,6 +15,7 @@ use Doctrine\DBAL\Types\Type; use function array_walk; use function preg_replace; +use function sprintf; use function strtoupper; use function uniqid; @@ -101,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) ); } @@ -135,32 +136,32 @@ 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([]) + $this->platform->getIntegerTypeDeclarationSQL([]) ); self::assertEquals( 'NUMBER(10)', - $this->_platform->getIntegerTypeDeclarationSQL(['autoincrement' => true]) + $this->platform->getIntegerTypeDeclarationSQL(['autoincrement' => true]) ); self::assertEquals( 'NUMBER(10)', - $this->_platform->getIntegerTypeDeclarationSQL( + $this->platform->getIntegerTypeDeclarationSQL( ['autoincrement' => true, 'primary' => true] ) ); @@ -170,35 +171,35 @@ public function testGeneratesTypeDeclarationsForStrings() { self::assertEquals( 'CHAR(10)', - $this->_platform->getVarcharTypeDeclarationSQL( + $this->platform->getVarcharTypeDeclarationSQL( ['length' => 10, 'fixed' => true] ) ); self::assertEquals( 'VARCHAR2(50)', - $this->_platform->getVarcharTypeDeclarationSQL(['length' => 50]), + $this->platform->getVarcharTypeDeclarationSQL(['length' => 50]), 'Variable string declaration is not correct' ); self::assertEquals( 'VARCHAR2(255)', - $this->_platform->getVarcharTypeDeclarationSQL([]), + $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()); } /** @@ -225,6 +226,8 @@ public function getGenerateForeignKeySql() } /** + * @param mixed[] $options + * * @group DBAL-1097 * @dataProvider getGeneratesAdvancedForeignKeyOptionsSQLData */ @@ -232,11 +235,11 @@ public function testGeneratesAdvancedForeignKeyOptionsSQL(array $options, $expec { $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() { @@ -266,37 +269,37 @@ public function getReturnsForeignKeyReferentialActionSQL() 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); } @@ -308,12 +311,31 @@ public function testGenerateTableWithAutoincrement() $column = $table->addColumn($columnName, 'integer'); $column->setAutoincrement(true); $targets = [ - "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;", + 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); + $statements = $this->platform->getCreateTableSQL($table); //strip all the whitespace from the statements array_walk($statements, static function (&$value) { $value = preg_replace('/\s+/', ' ', $value); @@ -429,7 +451,7 @@ public function testAlterTableNotNULL() ); $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)); + self::assertEquals($expectedSql, $this->platform->getAlterTableSQL($tableDiff)); } /** @@ -437,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() @@ -454,13 +476,13 @@ protected function getBinaryMaxLength() public function testReturnsBinaryTypeDeclarationSQL() { - 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([])); + 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(['fixed' => true])); - self::assertSame('RAW(2000)', $this->_platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 0])); - self::assertSame('RAW(2000)', $this->_platform->getBinaryTypeDeclarationSQL(['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])); } /** @@ -469,8 +491,8 @@ 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() @@ -487,7 +509,7 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType() // VARBINARY -> BINARY // BINARY -> VARBINARY - self::assertEmpty($this->_platform->getAlterTableSQL($comparator->diffTable($table1, $table2))); + self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table1, $table2))); } /** @@ -495,7 +517,7 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType() */ public function testUsesSequenceEmulatedIdentityColumns() { - self::assertTrue($this->_platform->usesSequenceEmulatedIdentityColumns()); + self::assertTrue($this->platform->usesSequenceEmulatedIdentityColumns()); } /** @@ -504,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"')); } /** @@ -517,7 +539,7 @@ public function testReturnsIdentitySequenceName() public function testCreateSequenceWithCache($cacheSize, $expectedSql) { $sequence = new Sequence('foo', 1, 1, $cacheSize); - self::assertContains($expectedSql, $this->_platform->getCreateSequenceSQL($sequence)); + self::assertContains($expectedSql, $this->platform->getCreateSequenceSQL($sequence)); } public function dataCreateSequenceWithCache() @@ -603,7 +625,7 @@ protected function getQuotesDropForeignKeySQL() */ public function testReturnsGuidTypeDeclarationSQL() { - self::assertSame('CHAR(36)', $this->_platform->getGuidTypeDeclarationSQL([])); + self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([])); } /** @@ -620,7 +642,7 @@ 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() @@ -695,10 +717,10 @@ public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers() $tableDiff = $comparator->diffTable($table1, $table2); - self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); + self::assertInstanceOf(TableDiff::class, $tableDiff); self::assertSame( ['COMMENT ON COLUMN "foo"."bar" IS \'baz\''], - $this->_platform->getAlterTableSQL($tableDiff) + $this->platform->getAlterTableSQL($tableDiff) ); } @@ -710,9 +732,9 @@ public function testQuotedTableNames() // 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() @@ -844,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); } /** @@ -852,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); } /** @@ -860,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); } /** @@ -868,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); } /** @@ -876,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); } /** @@ -884,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 48297877125..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([])); + self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL([])); } public function testReturnsSmallIntTypeDeclarationSQL() { self::assertSame( 'SMALLSERIAL', - $this->_platform->getSmallIntTypeDeclarationSQL(['autoincrement' => true]) + $this->platform->getSmallIntTypeDeclarationSQL(['autoincrement' => true]) ); self::assertSame( 'SMALLINT', - $this->_platform->getSmallIntTypeDeclarationSQL(['autoincrement' => false]) + $this->platform->getSmallIntTypeDeclarationSQL(['autoincrement' => false]) ); self::assertSame( 'SMALLINT', - $this->_platform->getSmallIntTypeDeclarationSQL([]) + $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 673a724ecdc..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(['jsonb' => false])); - self::assertSame('JSONB', $this->_platform->getJsonTypeDeclarationSQL(['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 4022eb0ff04..b45a152ab0a 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php @@ -13,6 +13,6 @@ public function createPlatform() public function testSupportsPartialIndexes() { - self::assertTrue($this->_platform->supportsPartialIndexes()); + self::assertTrue($this->platform->supportsPartialIndexes()); } } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php index c384d16de45..7e91777d6ef 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php @@ -7,7 +7,7 @@ class SQLAnywhere11PlatformTest extends SQLAnywherePlatformTest { /** @var SQLAnywhere11Platform */ - protected $_platform; + protected $platform; public function createPlatform() { @@ -21,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 4219c9d0514..7cbb2c69bb8 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php @@ -9,7 +9,7 @@ class SQLAnywhere12PlatformTest extends SQLAnywhere11PlatformTest { /** @var SQLAnywhere12Platform */ - protected $_platform; + protected $platform; public function createPlatform() { @@ -23,7 +23,7 @@ public function testDoesNotSupportSequences() public function testSupportsSequences() { - self::assertTrue($this->_platform->supportsSequences()); + self::assertTrue($this->platform->supportsSequences()); } public function testGeneratesSequenceSqlCommands() @@ -31,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') + $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) ); } @@ -59,7 +59,7 @@ public function testGeneratesDateTimeTzColumnTypeDeclarationSQL() { self::assertEquals( 'TIMESTAMP WITH TIME ZONE', - $this->_platform->getDateTimeTzTypeDeclarationSQL([ + $this->platform->getDateTimeTzTypeDeclarationSQL([ 'length' => 10, 'fixed' => true, 'unsigned' => true, @@ -70,20 +70,20 @@ public function testGeneratesDateTimeTzColumnTypeDeclarationSQL() 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', ['a', 'b'], @@ -96,7 +96,7 @@ public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL() ); self::assertEquals( 'CREATE VIRTUAL CLUSTERED INDEX fooindex ON footable (a, b) FOR OLAP WORKLOAD', - $this->_platform->getCreateIndexSQL( + $this->platform->getCreateIndexSQL( new Index( 'fooindex', ['a', 'b'], @@ -111,7 +111,7 @@ 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', ['a', 'b'], @@ -126,7 +126,7 @@ 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', ['a', 'b'], diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php index bbf99527f65..9692ffb1f76 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php @@ -16,7 +16,7 @@ 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', ['a', 'b'], @@ -31,7 +31,7 @@ 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', ['a', 'b'], @@ -46,7 +46,7 @@ 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', ['a', 'b'], @@ -65,7 +65,7 @@ public function testThrowsExceptionOnInvalidWithNullsNotDistinctIndexOptions() { $this->expectException('UnexpectedValueException'); - $this->_platform->getCreateIndexSQL( + $this->platform->getCreateIndexSQL( new Index( 'fooindex', ['a', 'b'], diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php index 7c6d161c371..294b9836e2e 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\DBAL\Platforms; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\SQLAnywherePlatform; @@ -9,12 +10,14 @@ 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; @@ -22,7 +25,7 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase { /** @var SQLAnywherePlatform */ - protected $_platform; + protected $platform; public function createPlatform() { @@ -119,7 +122,7 @@ public function getCreateTableColumnTypeCommentsSQL() public function testHasCorrectPlatformName() { - self::assertEquals('sqlanywhere', $this->_platform->getName()); + self::assertEquals('sqlanywhere', $this->platform->getName()); } public function testGeneratesCreateTableSQLWithCommonIndexes() @@ -137,7 +140,7 @@ public function testGeneratesCreateTableSQLWithCommonIndexes() 'CREATE INDEX IDX_D87F7E0C5E237E06 ON test (name)', 'CREATE INDEX composite_idx ON test (id, name)', ], - $this->_platform->getCreateTableSQL($table) + $this->platform->getCreateTableSQL($table) ); } @@ -162,7 +165,7 @@ public function testGeneratesCreateTableSQLWithForeignKeyConstraints() '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) + $this->platform->getCreateTableSQL($table, AbstractPlatform::CREATE_FOREIGNKEYS) ); } @@ -176,7 +179,7 @@ public function testGeneratesCreateTableSQLWithCheckConstraints() self::assertEquals( ['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) + $this->platform->getCreateTableSQL($table) ); } @@ -195,7 +198,7 @@ public function testGeneratesTableAlterationWithRemovedColumnCommentSql() self::assertEquals( ['COMMENT ON COLUMN mytable.foo IS NULL'], - $this->_platform->getAlterTableSQL($tableDiff) + $this->platform->getAlterTableSQL($tableDiff) ); } @@ -207,7 +210,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)); } public function getLockHints() @@ -225,12 +228,12 @@ public function getLockHints() public function testHasCorrectMaxIdentifierLength() { - self::assertEquals(128, $this->_platform->getMaxIdentifierLength()); + self::assertEquals(128, $this->platform->getMaxIdentifierLength()); } public function testFixesSchemaElementNames() { - $maxIdentifierLength = $this->_platform->getMaxIdentifierLength(); + $maxIdentifierLength = $this->platform->getMaxIdentifierLength(); $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $schemaElementName = ''; @@ -242,11 +245,11 @@ 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) ); } @@ -259,67 +262,67 @@ public function testGeneratesColumnTypesDeclarationSQL() '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()); + 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( + $this->platform->getPrimaryKeyDeclarationSQL( new Index(null, ['a', 'b'], true, true, ['clustered']), 'pk' ) ); self::assertEquals( 'PRIMARY KEY (a, b)', - $this->_platform->getPrimaryKeyDeclarationSQL( + $this->platform->getPrimaryKeyDeclarationSQL( new Index(null, ['a', 'b'], true, true) ) ); @@ -327,23 +330,23 @@ public function testGeneratesPrimaryKeyDeclarationSQL() public function testCannotGeneratePrimaryKeyDeclarationSQLWithEmptyColumns() { - $this->expectException('\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); - $this->_platform->getPrimaryKeyDeclarationSQL(new Index('pk', [], 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( + $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( + $this->platform->getCreatePrimaryKeySQL( new Index('any_pk_name', ['a', 'b'], true, true), new Table('foo') ) @@ -354,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, ['a', 'b'], true, false, ['clustered']) ) ); self::assertEquals( 'UNIQUE (a, b)', - $this->_platform->getUniqueConstraintDeclarationSQL(null, new Index(null, ['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', [], true)); + $this->platform->getUniqueConstraintDeclarationSQL('constr', new Index('constr', [], true)); } public function testGeneratesForeignKeyConstraintsWithAdvancedPlatformOptionsSQL() @@ -379,7 +382,7 @@ 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( + $this->platform->getForeignKeyDeclarationSQL( new ForeignKeyConstraint(['a', 'b'], 'foreign_table', ['c', 'd'], 'fk', [ 'notnull' => true, 'match' => SQLAnywherePlatform::FOREIGN_KEY_MATCH_SIMPLE_UNIQUE, @@ -393,7 +396,7 @@ public function testGeneratesForeignKeyConstraintsWithAdvancedPlatformOptionsSQL ); self::assertEquals( 'FOREIGN KEY (a, b) REFERENCES foreign_table (c, d)', - $this->_platform->getForeignKeyDeclarationSQL( + $this->platform->getForeignKeyDeclarationSQL( new ForeignKeyConstraint(['a', 'b'], 'foreign_table', ['c', 'd']) ) ); @@ -401,56 +404,56 @@ public function testGeneratesForeignKeyConstraintsWithAdvancedPlatformOptionsSQL 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([], 'foreign_tbl', ['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(['a', 'b'], 'foreign_tbl', [])); + $this->expectException(InvalidArgumentException::class); + $this->platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint(['a', 'b'], 'foreign_tbl', [])); } public function testCannotGenerateForeignKeyConstraintSQLWithEmptyForeignTableName() { - $this->expectException('\InvalidArgumentException'); - $this->_platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint(['a', 'b'], '', ['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', []), 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', ['a', 'b'], @@ -465,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', [])); + $this->platform->getIndexDeclarationSQL('index', new Index('index', [])); } public function testGeneratesDropIndexSQL() { $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') )); @@ -484,97 +487,97 @@ public function testGeneratesDropIndexSQL() public function testCannotGenerateDropIndexSQLWithInvalidIndexParameter() { - $this->expectException('\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); - $this->_platform->getDropIndexSQL(['index'], 'table'); + $this->platform->getDropIndexSQL(['index'], 'table'); } public function testCannotGenerateDropIndexSQLWithInvalidTableParameter() { - $this->expectException('\InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); - $this->_platform->getDropIndexSQL('index', ['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() @@ -582,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() ); } @@ -597,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) ); } @@ -632,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) ); } @@ -640,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) ); } @@ -652,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() @@ -770,13 +773,13 @@ protected function getBinaryMaxLength() public function testReturnsBinaryTypeDeclarationSQL() { - 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('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(['fixed' => true])); - self::assertSame('BINARY(1)', $this->_platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 0])); - self::assertSame('BINARY(32767)', $this->_platform->getBinaryTypeDeclarationSQL(['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])); } /** @@ -785,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])); } /** @@ -858,7 +861,7 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() */ public function testReturnsGuidTypeDeclarationSQL() { - self::assertSame('UNIQUEIDENTIFIER', $this->_platform->getGuidTypeDeclarationSQL([])); + self::assertSame('UNIQUEIDENTIFIER', $this->platform->getGuidTypeDeclarationSQL([])); } /** @@ -909,10 +912,10 @@ public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers() $tableDiff = $comparator->diffTable($table1, $table2); - self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); + self::assertInstanceOf(TableDiff::class, $tableDiff); self::assertSame( ['COMMENT ON COLUMN "foo"."bar" IS \'baz\''], - $this->_platform->getAlterTableSQL($tableDiff) + $this->platform->getAlterTableSQL($tableDiff) ); } @@ -986,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 ); @@ -997,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); } /** @@ -1007,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 ); @@ -1018,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); } /** @@ -1028,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 ); @@ -1039,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); } /** @@ -1049,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/SQLServer2008PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php index 024bf65de93..3083ab7b606 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php @@ -13,6 +13,6 @@ public function createPlatform() 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 00dcdf24cb6..b908c427c28 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php @@ -15,12 +15,12 @@ public function createPlatform() 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() @@ -28,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') + $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); } @@ -130,7 +130,7 @@ public function testModifyLimitQueryWithExtraLongQuery() $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); + $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) '; @@ -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,7 +158,7 @@ public function testModifyLimitQueryWithOrderByClause() */ public function testModifyLimitQueryWithSubSelectInSelectList() { - $sql = $this->_platform->modifyLimitQuery( + $sql = $this->platform->modifyLimitQuery( 'SELECT ' . 'u.id, ' . '(u.foo/2) foodiv, ' . @@ -188,7 +188,7 @@ public function testModifyLimitQueryWithSubSelectInSelectList() */ public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause() { - $sql = $this->_platform->modifyLimitQuery( + $sql = $this->platform->modifyLimitQuery( 'SELECT ' . 'u.id, ' . '(u.foo/2) foodiv, ' . @@ -220,7 +220,7 @@ public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause() */ public function testModifyLimitQueryWithAggregateFunctionInOrderByClause() { - $sql = $this->_platform->modifyLimitQuery( + $sql = $this->platform->modifyLimitQuery( 'SELECT ' . 'MAX(heading_id) aliased, ' . 'code ' . @@ -245,7 +245,7 @@ public function testModifyLimitQueryWithAggregateFunctionInOrderByClause() 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'; @@ -254,7 +254,7 @@ public function testModifyLimitQueryWithFromSubquery() 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'; @@ -263,7 +263,7 @@ public function testModifyLimitQueryWithFromSubqueryAndOrder() 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'; @@ -290,7 +290,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBas . '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); + $sql = $this->platform->modifyLimitQuery($querySql, 5); self::assertEquals($alteredSql, $sql); } @@ -313,7 +313,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoi . '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); + $sql = $this->platform->modifyLimitQuery($querySql, 5); self::assertEquals($alteredSql, $sql); } @@ -336,7 +336,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBo . '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); + $sql = $this->platform->modifyLimitQuery($querySql, 5); self::assertEquals($alteredSql, $sql); } @@ -347,7 +347,7 @@ public function testModifyLimitSubquerySimple() . '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); + $sql = $this->platform->modifyLimitQuery($querySql, 20); self::assertEquals($alteredSql, $sql); } @@ -355,12 +355,12 @@ public function testModifyLimitQueryWithTopNSubQueryWithOrderBy() { $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'; $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); } @@ -368,7 +368,7 @@ public function testModifyLimitQueryWithNewlineBeforeOrderBy() { $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 eeaf5171bf3..ed2842813aa 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php @@ -21,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)); } /** @@ -30,7 +30,7 @@ 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() diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php index 67abba9fca5..f2e12ae7b22 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php @@ -32,41 +32,41 @@ public function getGenerateTableWithMultiColumnUniqueIndexSql() 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(['autoincrement' => true, 'unsigned' => true]) + $this->platform->getIntegerTypeDeclarationSQL(['autoincrement' => true, 'unsigned' => true]) ); } @@ -78,25 +78,25 @@ public function testGeneratesTypeDeclarationForTinyIntegers() { self::assertEquals( 'TINYINT', - $this->_platform->getTinyIntTypeDeclarationSQL([]) + $this->platform->getTinyIntTypeDeclarationSQL([]) ); self::assertEquals( 'INTEGER PRIMARY KEY AUTOINCREMENT', - $this->_platform->getTinyIntTypeDeclarationSQL(['autoincrement' => true]) + $this->platform->getTinyIntTypeDeclarationSQL(['autoincrement' => true]) ); self::assertEquals( 'INTEGER PRIMARY KEY AUTOINCREMENT', - $this->_platform->getTinyIntTypeDeclarationSQL( + $this->platform->getTinyIntTypeDeclarationSQL( ['autoincrement' => true, 'primary' => true] ) ); self::assertEquals( 'TINYINT', - $this->_platform->getTinyIntTypeDeclarationSQL(['unsigned' => false]) + $this->platform->getTinyIntTypeDeclarationSQL(['unsigned' => false]) ); self::assertEquals( 'TINYINT UNSIGNED', - $this->_platform->getTinyIntTypeDeclarationSQL(['unsigned' => true]) + $this->platform->getTinyIntTypeDeclarationSQL(['unsigned' => true]) ); } @@ -108,29 +108,29 @@ public function testGeneratesTypeDeclarationForSmallIntegers() { self::assertEquals( 'SMALLINT', - $this->_platform->getSmallIntTypeDeclarationSQL([]) + $this->platform->getSmallIntTypeDeclarationSQL([]) ); self::assertEquals( 'INTEGER PRIMARY KEY AUTOINCREMENT', - $this->_platform->getSmallIntTypeDeclarationSQL(['autoincrement' => true]) + $this->platform->getSmallIntTypeDeclarationSQL(['autoincrement' => true]) ); self::assertEquals( 'INTEGER PRIMARY KEY AUTOINCREMENT', - $this->_platform->getTinyIntTypeDeclarationSQL(['autoincrement' => true, 'unsigned' => true]) + $this->platform->getTinyIntTypeDeclarationSQL(['autoincrement' => true, 'unsigned' => true]) ); self::assertEquals( 'INTEGER PRIMARY KEY AUTOINCREMENT', - $this->_platform->getSmallIntTypeDeclarationSQL( + $this->platform->getSmallIntTypeDeclarationSQL( ['autoincrement' => true, 'primary' => true] ) ); self::assertEquals( 'SMALLINT', - $this->_platform->getSmallIntTypeDeclarationSQL(['unsigned' => false]) + $this->platform->getSmallIntTypeDeclarationSQL(['unsigned' => false]) ); self::assertEquals( 'SMALLINT UNSIGNED', - $this->_platform->getSmallIntTypeDeclarationSQL(['unsigned' => true]) + $this->platform->getSmallIntTypeDeclarationSQL(['unsigned' => true]) ); } @@ -142,29 +142,29 @@ public function testGeneratesTypeDeclarationForMediumIntegers() { self::assertEquals( 'MEDIUMINT', - $this->_platform->getMediumIntTypeDeclarationSQL([]) + $this->platform->getMediumIntTypeDeclarationSQL([]) ); self::assertEquals( 'INTEGER PRIMARY KEY AUTOINCREMENT', - $this->_platform->getMediumIntTypeDeclarationSQL(['autoincrement' => true]) + $this->platform->getMediumIntTypeDeclarationSQL(['autoincrement' => true]) ); self::assertEquals( 'INTEGER PRIMARY KEY AUTOINCREMENT', - $this->_platform->getMediumIntTypeDeclarationSQL(['autoincrement' => true, 'unsigned' => true]) + $this->platform->getMediumIntTypeDeclarationSQL(['autoincrement' => true, 'unsigned' => true]) ); self::assertEquals( 'INTEGER PRIMARY KEY AUTOINCREMENT', - $this->_platform->getMediumIntTypeDeclarationSQL( + $this->platform->getMediumIntTypeDeclarationSQL( ['autoincrement' => true, 'primary' => true] ) ); self::assertEquals( 'MEDIUMINT', - $this->_platform->getMediumIntTypeDeclarationSQL(['unsigned' => false]) + $this->platform->getMediumIntTypeDeclarationSQL(['unsigned' => false]) ); self::assertEquals( 'MEDIUMINT UNSIGNED', - $this->_platform->getMediumIntTypeDeclarationSQL(['unsigned' => true]) + $this->platform->getMediumIntTypeDeclarationSQL(['unsigned' => true]) ); } @@ -172,29 +172,29 @@ public function testGeneratesTypeDeclarationForIntegers() { self::assertEquals( 'INTEGER', - $this->_platform->getIntegerTypeDeclarationSQL([]) + $this->platform->getIntegerTypeDeclarationSQL([]) ); self::assertEquals( 'INTEGER PRIMARY KEY AUTOINCREMENT', - $this->_platform->getIntegerTypeDeclarationSQL(['autoincrement' => true]) + $this->platform->getIntegerTypeDeclarationSQL(['autoincrement' => true]) ); self::assertEquals( 'INTEGER PRIMARY KEY AUTOINCREMENT', - $this->_platform->getIntegerTypeDeclarationSQL(['autoincrement' => true, 'unsigned' => true]) + $this->platform->getIntegerTypeDeclarationSQL(['autoincrement' => true, 'unsigned' => true]) ); self::assertEquals( 'INTEGER PRIMARY KEY AUTOINCREMENT', - $this->_platform->getIntegerTypeDeclarationSQL( + $this->platform->getIntegerTypeDeclarationSQL( ['autoincrement' => true, 'primary' => true] ) ); self::assertEquals( 'INTEGER', - $this->_platform->getIntegerTypeDeclarationSQL(['unsigned' => false]) + $this->platform->getIntegerTypeDeclarationSQL(['unsigned' => false]) ); self::assertEquals( 'INTEGER UNSIGNED', - $this->_platform->getIntegerTypeDeclarationSQL(['unsigned' => true]) + $this->platform->getIntegerTypeDeclarationSQL(['unsigned' => true]) ); } @@ -206,29 +206,29 @@ public function testGeneratesTypeDeclarationForBigIntegers() { self::assertEquals( 'BIGINT', - $this->_platform->getBigIntTypeDeclarationSQL([]) + $this->platform->getBigIntTypeDeclarationSQL([]) ); self::assertEquals( 'INTEGER PRIMARY KEY AUTOINCREMENT', - $this->_platform->getBigIntTypeDeclarationSQL(['autoincrement' => true]) + $this->platform->getBigIntTypeDeclarationSQL(['autoincrement' => true]) ); self::assertEquals( 'INTEGER PRIMARY KEY AUTOINCREMENT', - $this->_platform->getBigIntTypeDeclarationSQL(['autoincrement' => true, 'unsigned' => true]) + $this->platform->getBigIntTypeDeclarationSQL(['autoincrement' => true, 'unsigned' => true]) ); self::assertEquals( 'INTEGER PRIMARY KEY AUTOINCREMENT', - $this->_platform->getBigIntTypeDeclarationSQL( + $this->platform->getBigIntTypeDeclarationSQL( ['autoincrement' => true, 'primary' => true] ) ); self::assertEquals( 'BIGINT', - $this->_platform->getBigIntTypeDeclarationSQL(['unsigned' => false]) + $this->platform->getBigIntTypeDeclarationSQL(['unsigned' => false]) ); self::assertEquals( 'BIGINT UNSIGNED', - $this->_platform->getBigIntTypeDeclarationSQL(['unsigned' => true]) + $this->platform->getBigIntTypeDeclarationSQL(['unsigned' => true]) ); } @@ -236,18 +236,18 @@ public function testGeneratesTypeDeclarationForStrings() { self::assertEquals( 'CHAR(10)', - $this->_platform->getVarcharTypeDeclarationSQL( + $this->platform->getVarcharTypeDeclarationSQL( ['length' => 10, 'fixed' => true] ) ); self::assertEquals( 'VARCHAR(50)', - $this->_platform->getVarcharTypeDeclarationSQL(['length' => 50]), + $this->platform->getVarcharTypeDeclarationSQL(['length' => 50]), 'Variable string declaration is not correct' ); self::assertEquals( 'VARCHAR(255)', - $this->_platform->getVarcharTypeDeclarationSQL([]), + $this->platform->getVarcharTypeDeclarationSQL([]), 'Long string declaration is not correct' ); } @@ -285,19 +285,19 @@ 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); } @@ -322,7 +322,7 @@ public function testGenerateTableSqlShouldNotAutoQuotePrimaryKey() $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] @@ -340,7 +340,7 @@ public function testAlterTableAddColumns() 'ALTER TABLE user ADD COLUMN count INTEGER DEFAULT 1', ]; - self::assertEquals($expected, $this->_platform->getAlterTableSQL($diff)); + self::assertEquals($expected, $this->platform->getAlterTableSQL($diff)); } /** @@ -350,9 +350,10 @@ 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'); @@ -392,7 +393,7 @@ public function testCreateTableWithDeferredForeignKeys() 'CREATE INDEX IDX_8D93D6493D8E604F ON user (parent)', ]; - self::assertEquals($sql, $this->_platform->getCreateTableSQL($table)); + self::assertEquals($sql, $this->platform->getCreateTableSQL($table)); } public function testAlterTable() @@ -436,7 +437,7 @@ public function testAlterTable() 'CREATE INDEX IDX_8D93D6495A8A6C8D ON client (comment)', ]; - self::assertEquals($sql, $this->_platform->getAlterTableSQL($diff)); + self::assertEquals($sql, $this->platform->getAlterTableSQL($diff)); } protected function getQuotedColumnInPrimaryKeySQL() @@ -483,13 +484,13 @@ protected function getBinaryMaxLength() public function testReturnsBinaryTypeDeclarationSQL() { - 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([])); + self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); + self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL(['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])); + 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])); } /** @@ -593,7 +594,7 @@ public function testQuotesAlterTableRenameIndexInSchema() */ public function testReturnsGuidTypeDeclarationSQL() { - self::assertSame('CHAR(36)', $this->_platform->getGuidTypeDeclarationSQL([])); + self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([])); } /** @@ -726,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); } /** @@ -734,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); } /** @@ -742,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); } /** @@ -750,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') ); } @@ -784,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 5a783ef6415..88676130a52 100644 --- a/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php @@ -7,6 +7,7 @@ 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; @@ -161,7 +162,7 @@ public function testRowCount() */ protected function createConnection() { - return $this->getMockBuilder('Doctrine\DBAL\Portability\Connection') + return $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() ->getMock(); } @@ -179,6 +180,6 @@ protected function createStatement(\Doctrine\DBAL\Driver\Statement $wrappedState */ protected function createWrappedStatement() { - return $this->createMock('Doctrine\Tests\Mocks\DriverStatementMock'); + return $this->createMock(DriverStatementMock::class); } } diff --git a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php index 1fe2ac97416..efa173829c3 100644 --- a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php @@ -2,6 +2,7 @@ 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; @@ -16,7 +17,7 @@ class ExpressionBuilderTest extends DbalTestCase protected function setUp() { - $conn = $this->createMock('Doctrine\DBAL\Connection'); + $conn = $this->createMock(Connection::class); $this->expr = new ExpressionBuilder($conn); diff --git a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php index 1bbb61e8a06..fdd28d87847 100644 --- a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Query\Expression\ExpressionBuilder; use Doctrine\DBAL\Query\QueryBuilder; +use Doctrine\DBAL\Query\QueryException; use Doctrine\Tests\DbalTestCase; /** @@ -18,7 +19,7 @@ class QueryBuilderTest extends DbalTestCase protected function setUp() { - $this->conn = $this->createMock('Doctrine\DBAL\Connection'); + $this->conn = $this->createMock(Connection::class); $expressionBuilder = new ExpressionBuilder($this->conn); @@ -650,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()); } @@ -893,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 09b518dcf21..68d3cbcedd3 100644 --- a/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php +++ b/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\SQLParserUtils; +use Doctrine\DBAL\SQLParserUtilsException; use Doctrine\Tests\DbalTestCase; /** @@ -460,7 +461,7 @@ public function dataQueryWithMissingParameters() */ 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/ComparatorTest.php b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php index b0b27d09d79..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; @@ -203,7 +186,7 @@ public function testCompareNewField() 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')); @@ -213,7 +196,7 @@ public function testCompareChangedColumns_ChangeType() 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')); @@ -229,7 +212,7 @@ public function testCompareChangedColumns_ChangeCustomSchemaOption() self::assertEquals([], $c->diffColumn($column1, $column1)); } - public function testCompareChangeColumns_MultipleNewColumnsRename() + public function testCompareChangeColumnsMultipleNewColumnsRename() { $tableA = new Table('foo'); $tableA->addColumn('datefield1', 'datetime'); @@ -523,7 +506,7 @@ public function testTableAddForeignKey() $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); } @@ -542,7 +525,7 @@ public function testTableRemoveForeignKey() $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); } @@ -562,7 +545,7 @@ public function testTableUpdateForeignKey() $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); } @@ -585,7 +568,7 @@ public function testMovedForeignKeyForeignTable() $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); } @@ -680,7 +663,7 @@ public function testCompareForeignKeyBasedOnPropertiesNotName() self::assertFalse($tableDiff); } - public function testCompareForeignKey_RestrictNoAction_AreTheSame() + public function testCompareForeignKeyRestrictNoActionAreTheSame() { $fk1 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'NO ACTION']); $fk2 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'RESTRICT']); @@ -692,7 +675,7 @@ public function testCompareForeignKey_RestrictNoAction_AreTheSame() /** * @group DBAL-492 */ - public function testCompareForeignKeyNamesUnqualified_AsNoSchemaInformationIsAvailable() + public function testCompareForeignKeyNamesUnqualifiedAsNoSchemaInformationIsAvailable() { $fk1 = new ForeignKeyConstraint(['foo'], 'foo.bar', ['baz'], 'fk1'); $fk2 = new ForeignKeyConstraint(['foo'], 'baz.bar', ['baz'], 'fk1'); @@ -811,7 +794,7 @@ public function testDetectChangeIdentifierType() $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); } @@ -837,7 +820,7 @@ public function testDiff() $c = new Comparator(); $tableDiff = $c->diffTable($table, $newtable); - self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); + 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); @@ -853,7 +836,7 @@ public function testChangedSequence() $sequence = $schema->createSequence('baz'); $schemaNew = clone $schema; - /* @var $schemaNew Schema */ + /** @var Schema $schemaNew */ $schemaNew->getSequence('baz')->setAllocationSize(20); $c = new Comparator(); @@ -987,6 +970,7 @@ public function testAutoIncrementSequences() /** * Check that added autoincrement sequence is not populated in newSequences + * * @group DBAL-562 */ public function testAutoIncrementNoSequences() @@ -1170,10 +1154,10 @@ public function testComplexDiffColumn() public function testComparesNamespaces() { $comparator = new Comparator(); - $fromSchema = $this->getMockBuilder('Doctrine\DBAL\Schema\Schema') + $fromSchema = $this->getMockBuilder(Schema::class) ->setMethods(['getNamespaces', 'hasNamespace']) ->getMock(); - $toSchema = $this->getMockBuilder('Doctrine\DBAL\Schema\Schema') + $toSchema = $this->getMockBuilder(Schema::class) ->setMethods(['getNamespaces', 'hasNamespace']) ->getMock(); @@ -1230,7 +1214,6 @@ public function testCompareGuidColumns() /** * @group DBAL-1009 - * * @dataProvider getCompareColumnComments */ public function testCompareColumnComments($comment1, $comment2, $equals) diff --git a/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php b/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php index 10bd92d52e6..2c317fc5dea 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php @@ -3,11 +3,14 @@ namespace Doctrine\Tests\DBAL\Schema; use Doctrine\DBAL\Schema\ForeignKeyConstraint; +use Doctrine\DBAL\Schema\Index; use PHPUnit\Framework\TestCase; class ForeignKeyConstraintTest extends TestCase { /** + * @param string[] $indexColumns + * * @group DBAL-1062 * @dataProvider getIntersectsIndexColumnsData */ @@ -15,7 +18,7 @@ public function testIntersectsIndexColumns(array $indexColumns, $expectedResult) { $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,7 +29,7 @@ public function testIntersectsIndexColumns(array $indexColumns, $expectedResult) } /** - * @return array + * @return mixed[] */ public function getIntersectsIndexColumnsData() { diff --git a/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php b/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php index 9ae399c7a04..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,7 +38,7 @@ public function testInheritTableOptionsFromDatabase() : void public function testTableOptions() : void { $eventManager = new EventManager(); - $driverMock = $this->createMock('Doctrine\DBAL\Driver'); + $driverMock = $this->createMock(Driver::class); $platform = new MySqlPlatform(); // default, no overrides @@ -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 2a3837140c0..737a8223812 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php @@ -5,7 +5,10 @@ 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; @@ -21,9 +24,9 @@ class MySqlSchemaManagerTest extends 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') + $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(); @@ -36,7 +39,7 @@ public function testCompositeForeignKeys() $fkeys = $this->manager->listTableForeignKeys('dummy'); self::assertCount(1, $fkeys, 'Table has to have one foreign key.'); - self::assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]); + 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())); } diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php index b25f81601be..8a6d9575bce 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php @@ -7,6 +7,7 @@ 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 TestCase @@ -37,7 +38,7 @@ public function testSchemaDiffToSaveSql() 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') @@ -45,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')) + ->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')) + ->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')); } diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php index c9bad262d74..f7254c97cb7 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php @@ -4,8 +4,11 @@ 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; @@ -43,7 +46,7 @@ public function testTableMatchingCaseInsensitive() public function testGetUnknownTableThrowsException() { - $this->expectException('Doctrine\DBAL\Schema\SchemaException'); + $this->expectException(SchemaException::class); $schema = new Schema(); $schema->getTable('unknown'); @@ -51,7 +54,7 @@ public function testGetUnknownTableThrowsException() public function testCreateTableTwiceThrowsException() { - $this->expectException('Doctrine\DBAL\Schema\SchemaException'); + $this->expectException(SchemaException::class); $tableName = 'foo'; $table = new Table($tableName); @@ -94,7 +97,7 @@ public function testCreateTable() $table = $schema->createTable('foo'); - self::assertInstanceOf('Doctrine\DBAL\Schema\Table', $table); + self::assertInstanceOf(Table::class, $table); self::assertEquals('foo', $table->getName()); self::assertTrue($schema->hasTable('foo')); } @@ -106,7 +109,7 @@ public function testAddSequences() $schema = new Schema([], [$sequence]); self::assertTrue($schema->hasSequence('a_seq')); - self::assertInstanceOf('Doctrine\DBAL\Schema\Sequence', $schema->getSequence('a_seq')); + self::assertInstanceOf(Sequence::class, $schema->getSequence('a_seq')); $sequences = $schema->getSequences(); self::assertArrayHasKey('public.a_seq', $sequences); @@ -128,7 +131,7 @@ public function testSequenceAccessCaseInsensitive() public function testGetUnknownSequenceThrowsException() { - $this->expectException('Doctrine\DBAL\Schema\SchemaException'); + $this->expectException(SchemaException::class); $schema = new Schema(); $schema->getSequence('unknown'); @@ -144,7 +147,7 @@ public function testCreateSequence() self::assertEquals(20, $sequence->getInitialValue()); self::assertTrue($schema->hasSequence('a_seq')); - self::assertInstanceOf('Doctrine\DBAL\Schema\Sequence', $schema->getSequence('a_seq')); + self::assertInstanceOf(Sequence::class, $schema->getSequence('a_seq')); $sequences = $schema->getSequences(); self::assertArrayHasKey('public.a_seq', $sequences); @@ -162,7 +165,7 @@ public function testDropSequence() public function testAddSequenceTwiceThrowsException() { - $this->expectException('Doctrine\DBAL\Schema\SchemaException'); + $this->expectException(SchemaException::class); $sequence = new Sequence('a_seq', 1, 1); @@ -352,7 +355,7 @@ public function testCreatesNamespaceThroughAddingSequenceImplicitly() public function testVisitsVisitor() { $schema = new Schema(); - $visitor = $this->createMock('Doctrine\DBAL\Schema\Visitor\Visitor'); + $visitor = $this->createMock(Visitor::class); $schema->createNamespace('foo'); $schema->createNamespace('bar'); @@ -398,7 +401,7 @@ public function testVisitsVisitor() public function testVisitsNamespaceVisitor() { $schema = new Schema(); - $visitor = $this->createMock('Doctrine\DBAL\Schema\Visitor\AbstractVisitor'); + $visitor = $this->createMock(AbstractVisitor::class); $schema->createNamespace('foo'); $schema->createNamespace('bar'); diff --git a/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php b/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php index 442c283ef59..cedc3583137 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php @@ -1,24 +1,8 @@ . - */ 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; @@ -29,7 +13,10 @@ */ class SingleDatabaseSynchronizerTest extends TestCase { + /** @var Connection */ private $conn; + + /** @var SingleDatabaseSynchronizer */ private $synchronizer; protected function setUp() diff --git a/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php index 097c9e2f1e1..80b9ef7b2c2 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php @@ -3,6 +3,7 @@ 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; @@ -25,7 +26,7 @@ public function testReturnsName() public function testPrefersNameFromTableObject() { $platformMock = new MockPlatform(); - $tableMock = $this->getMockBuilder('Doctrine\DBAL\Schema\Table') + $tableMock = $this->getMockBuilder(Table::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php index 09cc4662f48..ac5fead5bcf 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php @@ -8,6 +8,7 @@ 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; @@ -41,8 +42,8 @@ public function testColumns() 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()); } @@ -92,7 +93,7 @@ public function testDropColumn() public function testGetUnknownColumnThrowsException() { - $this->expectException('Doctrine\DBAL\Schema\SchemaException'); + $this->expectException(SchemaException::class); $table = new Table('foo', [], [], []); $table->getColumn('unknown'); @@ -100,7 +101,7 @@ public function testGetUnknownColumnThrowsException() public function testAddColumnTwiceThrowsException() { - $this->expectException('Doctrine\DBAL\Schema\SchemaException'); + $this->expectException(SchemaException::class); $type = Type::getType('integer'); $columns = []; @@ -156,14 +157,14 @@ public function testAddIndexes() 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', [], [], []); $table->getIndex('unknownIndex'); @@ -171,7 +172,7 @@ public function testGetUnknownIndexThrowsException() public function testAddTwoPrimaryThrowsException() { - $this->expectException('Doctrine\DBAL\Schema\SchemaException'); + $this->expectException(SchemaException::class); $type = Type::getType('integer'); $columns = [new Column('foo', $type), new Column('bar', $type)]; @@ -184,7 +185,7 @@ public function testAddTwoPrimaryThrowsException() public function testAddTwoIndexesWithSameNameThrowsException() { - $this->expectException('Doctrine\DBAL\Schema\SchemaException'); + $this->expectException(SchemaException::class); $type = Type::getType('integer'); $columns = [new Column('foo', $type), new Column('bar', $type)]; @@ -222,7 +223,7 @@ public function testBuilderSetPrimaryKey() $table->setPrimaryKey(['bar']); self::assertTrue($table->hasIndex('primary')); - self::assertInstanceOf('Doctrine\DBAL\Schema\Index', $table->getPrimaryKey()); + self::assertInstanceOf(Index::class, $table->getPrimaryKey()); self::assertTrue($table->getIndex('primary')->isUnique()); self::assertTrue($table->getIndex('primary')->isPrimary()); } @@ -253,7 +254,7 @@ public function testBuilderAddIndex() public function testBuilderAddIndexWithInvalidNameThrowsException() { - $this->expectException('Doctrine\DBAL\Schema\SchemaException'); + $this->expectException(SchemaException::class); $table = new Table('foo'); $table->addColumn('bar', 'integer'); @@ -262,7 +263,7 @@ public function testBuilderAddIndexWithInvalidNameThrowsException() public function testBuilderAddIndexWithUnknownColumnThrowsException() { - $this->expectException('Doctrine\DBAL\Schema\SchemaException'); + $this->expectException(SchemaException::class); $table = new Table('foo'); $table->addIndex(['bar'], 'invalidName'); @@ -276,9 +277,9 @@ public function testBuilderOptions() 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'); @@ -289,9 +290,9 @@ public function testAddForeignKeyConstraint_UnknownLocalColumn_ThrowsException() $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'); @@ -316,7 +317,7 @@ public function testAddForeignKeyConstraint() 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')); @@ -334,7 +335,7 @@ public function testAddIndexWithCaseSensitiveColumnProblem() self::assertTrue($table->getIndex('my_idx')->spansColumns(['id'])); } - public function testAddPrimaryKey_ColumnsAreExplicitlySetToNotNull() + public function testAddPrimaryKeyColumnsAreExplicitlySetToNotNull() { $table = new Table('foo'); $column = $table->addColumn('id', 'integer', ['notnull' => false]); @@ -822,18 +823,18 @@ public function testNormalizesColumnNames($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)); diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php index f94e1c1d019..e64b4c523f3 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php @@ -25,7 +25,7 @@ protected function setUp() { parent::setUp(); - $this->platformMock = $this->getMockBuilder('Doctrine\DBAL\Platforms\AbstractPlatform') + $this->platformMock = $this->getMockBuilder(AbstractPlatform::class) ->setMethods( [ 'getCreateForeignKeySQL', @@ -134,7 +134,7 @@ public function testResetsQueries() */ private function createForeignKeyConstraintMock() { - return $this->getMockBuilder('Doctrine\DBAL\Schema\ForeignKeyConstraint') + return $this->getMockBuilder(ForeignKeyConstraint::class) ->disableOriginalConstructor() ->getMock(); } @@ -144,7 +144,7 @@ private function createForeignKeyConstraintMock() */ private function createSequenceMock() { - return $this->getMockBuilder('Doctrine\DBAL\Schema\Sequence') + return $this->getMockBuilder(Sequence::class) ->disableOriginalConstructor() ->getMock(); } @@ -154,7 +154,7 @@ private function createSequenceMock() */ 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 c65996cab7b..b2aff283871 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php @@ -2,6 +2,10 @@ 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; @@ -18,7 +22,7 @@ public function testGetQueriesUsesAcceptedForeignKeys() $keyConstraintOne = $this->getStubKeyConstraint('first'); $keyConstraintTwo = $this->getStubKeyConstraint('second'); - $platform = $this->getMockBuilder('Doctrine\DBAL\Platforms\AbstractPlatform') + $platform = $this->getMockBuilder(AbstractPlatform::class) ->setMethods(['getDropForeignKeySQL']) ->getMockForAbstractClass(); @@ -43,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) @@ -53,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') @@ -70,13 +74,13 @@ private function getStubKeyConstraint($name) 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/SchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php index d326a817c0d..4ebfd1cac54 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\DBAL\Schema\Visitor; +use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Schema\Schema; use PHPUnit\Framework\TestCase; @@ -9,7 +10,7 @@ class SchemaSqlCollectorTest extends TestCase { public function testCreateSchema() { - $platformMock = $this->getMockBuilder('Doctrine\DBAL\Platforms\MySqlPlatform') + $platformMock = $this->getMockBuilder(MySqlPlatform::class) ->setMethods(['getCreateTableSql', 'getCreateSequenceSql', 'getCreateForeignKeySql']) ->getMock(); $platformMock->expects($this->exactly(2)) @@ -31,7 +32,7 @@ public function testCreateSchema() public function testDropSchema() { - $platformMock = $this->getMockBuilder('Doctrine\DBAL\Platforms\MySqlPlatform') + $platformMock = $this->getMockBuilder(MySqlPlatform::class) ->setMethods(['getDropTableSql', 'getDropSequenceSql', 'getDropForeignKeySql']) ->getMock(); $platformMock->expects($this->exactly(2)) diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php index 0eafb7eae01..4985605c60d 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php @@ -1,27 +1,13 @@ . - */ 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 @@ -31,14 +17,14 @@ class PoolingShardConnectionTest extends TestCase public function testConnect() { $conn = DriverManager::getConnection([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'global' => ['memory' => true], 'shards' => [ ['id' => 1, 'memory' => true], ['id' => 2, 'memory' => true], ], - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', + 'shardChoser' => MultiTenantShardChoser::class, ]); self::assertFalse($conn->isConnected(0)); @@ -68,13 +54,13 @@ public function testNoGlobalServerException() $this->expectExceptionMessage("Connection Parameters require 'global' and 'shards' configurations."); DriverManager::getConnection([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'shards' => [ ['id' => 1, 'memory' => true], ['id' => 2, 'memory' => true], ], - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', + 'shardChoser' => MultiTenantShardChoser::class, ]); } @@ -84,10 +70,10 @@ public function testNoShardsServersException() $this->expectExceptionMessage("Connection Parameters require 'global' and 'shards' configurations."); DriverManager::getConnection([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'global' => ['memory' => true], - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', + 'shardChoser' => MultiTenantShardChoser::class, ]); } @@ -97,7 +83,7 @@ public function testNoShardsChoserException() $this->expectExceptionMessage("Missing Shard Choser configuration 'shardChoser'"); DriverManager::getConnection([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'global' => ['memory' => true], 'shards' => [ @@ -113,14 +99,14 @@ public function testShardChoserWrongInstance() $this->expectExceptionMessage("The 'shardChoser' configuration is not a valid instance of Doctrine\DBAL\Sharding\ShardChoser\ShardChoser"); DriverManager::getConnection([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'global' => ['memory' => true], 'shards' => [ ['id' => 1, 'memory' => true], ['id' => 2, 'memory' => true], ], - 'shardChoser' => new \stdClass(), + 'shardChoser' => new stdClass(), ]); } @@ -130,13 +116,13 @@ public function testShardNonNumericId() $this->expectExceptionMessage('Shard Id has to be a non-negative number.'); DriverManager::getConnection([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'global' => ['memory' => true], 'shards' => [ ['id' => 'foo', 'memory' => true], ], - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', + 'shardChoser' => MultiTenantShardChoser::class, ]); } @@ -146,13 +132,13 @@ public function testShardMissingId() $this->expectExceptionMessage("Missing 'id' for one configured shard. Please specify a unique shard-id."); DriverManager::getConnection([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'global' => ['memory' => true], 'shards' => [ ['memory' => true], ], - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', + 'shardChoser' => MultiTenantShardChoser::class, ]); } @@ -162,32 +148,32 @@ public function testDuplicateShardId() $this->expectExceptionMessage('Shard 1 is duplicated in the configuration.'); DriverManager::getConnection([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'global' => ['memory' => true], 'shards' => [ ['id' => 1, 'memory' => true], ['id' => 1, 'memory' => true], ], - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', + 'shardChoser' => MultiTenantShardChoser::class, ]); } public function testSwitchShardWithOpenTransactionException() { $conn = DriverManager::getConnection([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'global' => ['memory' => true], 'shards' => [ ['id' => 1, 'memory' => true], ], - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', + '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); } @@ -195,13 +181,13 @@ public function testSwitchShardWithOpenTransactionException() public function testGetActiveShardId() { $conn = DriverManager::getConnection([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'global' => ['memory' => true], 'shards' => [ ['id' => 1, 'memory' => true], ], - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', + 'shardChoser' => MultiTenantShardChoser::class, ]); self::assertNull($conn->getActiveShardId()); @@ -219,17 +205,17 @@ public function testGetActiveShardId() public function testGetParamsOverride() { $conn = DriverManager::getConnection([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'global' => ['memory' => true, 'host' => 'localhost'], 'shards' => [ ['id' => 1, 'memory' => true, 'host' => 'foo'], ], - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', + 'shardChoser' => MultiTenantShardChoser::class, ]); self::assertEquals([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'global' => ['memory' => true, 'host' => 'localhost'], 'shards' => [ @@ -242,7 +228,7 @@ public function testGetParamsOverride() $conn->connect(1); self::assertEquals([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'global' => ['memory' => true, 'host' => 'localhost'], 'shards' => [ @@ -258,14 +244,14 @@ public function testGetParamsOverride() public function testGetHostOverride() { $conn = DriverManager::getConnection([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'host' => 'localhost', 'global' => ['memory' => true], 'shards' => [ ['id' => 1, 'memory' => true, 'host' => 'foo'], ], - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', + 'shardChoser' => MultiTenantShardChoser::class, ]); self::assertEquals('localhost', $conn->getHost()); @@ -277,14 +263,14 @@ public function testGetHostOverride() public function testGetPortOverride() { $conn = DriverManager::getConnection([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'port' => 3306, 'global' => ['memory' => true], 'shards' => [ ['id' => 1, 'memory' => true, 'port' => 3307], ], - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', + 'shardChoser' => MultiTenantShardChoser::class, ]); self::assertEquals(3306, $conn->getPort()); @@ -296,14 +282,14 @@ public function testGetPortOverride() public function testGetUsernameOverride() { $conn = DriverManager::getConnection([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'user' => 'foo', 'global' => ['memory' => true], 'shards' => [ ['id' => 1, 'memory' => true, 'user' => 'bar'], ], - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', + 'shardChoser' => MultiTenantShardChoser::class, ]); self::assertEquals('foo', $conn->getUsername()); @@ -315,14 +301,14 @@ public function testGetUsernameOverride() public function testGetPasswordOverride() { $conn = DriverManager::getConnection([ - 'wrapperClass' => 'Doctrine\DBAL\Sharding\PoolingShardConnection', + 'wrapperClass' => PoolingShardConnection::class, 'driver' => 'pdo_sqlite', 'password' => 'foo', 'global' => ['memory' => true], 'shards' => [ ['id' => 1, 'memory' => true, 'password' => 'bar'], ], - 'shardChoser' => 'Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser', + '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 cc5809effab..fc1b1ddb0c7 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php @@ -18,14 +18,16 @@ */ 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 TestCase { private function createConnectionMock() { - return $this->getMockBuilder('Doctrine\DBAL\Sharding\PoolingShardConnection') + return $this->getMockBuilder(PoolingShardConnection::class) ->setMethods(['connect', 'getParams', 'fetchAll']) ->disableOriginalConstructor() ->getMock(); @@ -33,7 +35,7 @@ private function createConnectionMock() 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(static function ($value) { @@ -42,14 +44,12 @@ private function createPassthroughShardChoser() 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(static function ($value) { - return 1; - })); + ->willReturn(1); return $mock; } @@ -130,10 +130,10 @@ public function testQueryAllWithStaticShardChoser() $conn = $this->createConnectionMock(); $conn->expects($this->at(0))->method('getParams')->will($this->returnValue( - ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createStaticShardChoser()] + ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createStaticShardChooser()] )); $conn->expects($this->at(1))->method('getParams')->will($this->returnValue( - ['shards' => [ ['id' => 1], ['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)) diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php index d49831e907d..94634dadb69 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php @@ -1,21 +1,4 @@ . - */ namespace Doctrine\Tests\DBAL\Sharding\SQLAzure; diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php index 04dc31723ef..edc88d376c9 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php @@ -2,6 +2,8 @@ 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; @@ -9,28 +11,28 @@ 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(['sharding' => ['distributionKey' => 'abc', 'distributionType' => 'integer']]); - $sm = new SQLAzureShardManager($conn); + 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(['sharding' => ['federationName' => 'abc', 'distributionType' => 'integer']]); - $sm = new SQLAzureShardManager($conn); + new SQLAzureShardManager($conn); } public function testNoDistributionType() { - $this->expectException('Doctrine\DBAL\Sharding\ShardingException'); + $this->expectException(ShardingException::class); $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionKey' => 'foo']]); - $sm = new SQLAzureShardManager($conn); + new SQLAzureShardManager($conn); } public function testGetDefaultDistributionValue() @@ -46,7 +48,7 @@ public function testSelectGlobalTransactionActive() $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); @@ -68,7 +70,7 @@ public function testSelectShard() $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); @@ -82,16 +84,19 @@ public function testSelectShardNoDistributionValue() $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') + $conn = $this->getMockBuilder(Connection::class) ->setMethods(['getParams', 'exec', 'isTransactionActive']) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php b/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php index d3eaf32ccfa..0c78b5c1771 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php @@ -1,24 +1,8 @@ . - */ namespace Doctrine\Tests\DBAL\Sharding\ShardChoser; +use Doctrine\DBAL\Sharding\PoolingShardConnection; use Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser; use PHPUnit\Framework\TestCase; @@ -35,7 +19,7 @@ public function testPickShard() private function createConnectionMock() { - return $this->getMockBuilder('Doctrine\DBAL\Sharding\PoolingShardConnection') + 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 88559c07ceb..7f18b20936a 100644 --- a/tests/Doctrine/Tests/DBAL/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/StatementTest.php @@ -4,6 +4,8 @@ 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; @@ -25,28 +27,28 @@ class StatementTest extends DbalTestCase protected function setUp() { - $this->pdoStatement = $this->getMockBuilder('\PDOStatement') + $this->pdoStatement = $this->getMockBuilder(PDOStatement::class) ->setMethods(['execute', 'bindParam', 'bindValue']) ->getMock(); $platform = new MockPlatform(); - $driverConnection = $this->createMock('\Doctrine\DBAL\Driver\Connection'); + $driverConnection = $this->createMock(DriverConnection::class); $driverConnection->expects($this->any()) ->method('prepare') ->will($this->returnValue($this->pdoStatement)); - $driver = $this->createMock('\Doctrine\DBAL\Driver'); + $driver = $this->createMock(Driver::class); $constructorArgs = [ ['platform' => $platform], $driver, ]; - $this->conn = $this->getMockBuilder('\Doctrine\DBAL\Connection') + $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)); @@ -65,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)); @@ -87,7 +89,7 @@ public function testExecuteCallsLoggerStartQueryWithParametersWhenParamsPassedTo $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)); @@ -127,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') diff --git a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php index 84907e09316..a85efd0a88c 100644 --- a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php +++ b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php @@ -29,7 +29,7 @@ protected function setUp() $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([[1]]); $this->connectionMock->method('executeUpdate') diff --git a/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php b/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php index b536c0c1d21..ecb4155f74f 100644 --- a/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php @@ -3,6 +3,7 @@ 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; @@ -11,22 +12,22 @@ class ArrayTest extends DbalTestCase { /** @var AbstractPlatform */ - protected $_platform; + private $platform; /** @var Type */ - protected $_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([], $this->_platform) + $this->type->convertToDatabaseValue([], $this->platform) ); } @@ -34,20 +35,20 @@ public function testArrayConvertsToPHPValue() { self::assertInternalType( 'array', - $this->_type->convertToPHPValue(serialize([]), $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)); } /** @@ -55,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 985c06605c5..8140cf6d109 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php @@ -4,6 +4,7 @@ use DateTime; use DateTimeImmutable; +use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DBAL\Mocks\MockPlatform; use PHPUnit\Framework\TestCase; @@ -30,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); } /** @@ -53,7 +54,7 @@ public function testDateConvertsToDatabaseValue() */ public function testInvalidTypeConversionToDatabaseValue($value) { - $this->expectException('Doctrine\DBAL\Types\ConversionException'); + $this->expectException(ConversionException::class); $this->type->convertToDatabaseValue($value, $this->platform); } diff --git a/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php b/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php index 21b043d1c70..a7e3377107a 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php @@ -9,29 +9,29 @@ class BooleanTest extends DbalTestCase { /** @var MockPlatform */ - protected $_platform; + private $platform; /** @var Type */ - protected $_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 2740e708e10..f0183ef854c 100644 --- a/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php @@ -19,7 +19,7 @@ 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$/', @@ -35,7 +35,7 @@ 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$/', @@ -49,7 +49,7 @@ public function testConversionFailedFormatPreservesPreviousException() $exception = ConversionException::conversionFailedFormat('foo', 'bar', 'baz', $previous); - self::assertInstanceOf('Doctrine\DBAL\Types\ConversionException', $exception); + self::assertInstanceOf(ConversionException::class, $exception); self::assertSame($previous, $exception->getPrevious()); } diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTest.php index 6b41eab3c50..a8c7327b337 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\DBAL\Types; use DateTime; +use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; use function date_default_timezone_set; @@ -34,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'); @@ -49,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/DateTimeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php index d104f83a835..7d571f80eb2 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\DBAL\Types; use DateTime; +use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; class DateTimeTest extends BaseDateTypeTestCase @@ -37,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/DateTimeTzTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php index 8f97ff83167..4b6c8fb208f 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\DBAL\Types; use DateTime; +use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; class DateTimeTzTest extends BaseDateTypeTestCase @@ -37,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 aedb6c98bb6..3d1164afbfb 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php @@ -9,24 +9,24 @@ class DecimalTest extends DbalTestCase { /** @var MockPlatform */ - protected $_platform; + private $platform; /** @var Type */ - protected $_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 e3fc70a8be9..e68bf0bc46f 100644 --- a/tests/Doctrine/Tests/DBAL/Types/FloatTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/FloatTest.php @@ -9,34 +9,34 @@ class FloatTest extends DbalTestCase { /** @var MockPlatform */ - protected $_platform; + private $platform; /** @var Type */ - protected $_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 439e9de7168..978cfd50fb7 100644 --- a/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php @@ -10,37 +10,37 @@ class GuidTypeTest extends DbalTestCase { /** @var MockPlatform */ - protected $_platform; + private $platform; /** @var Type */ - protected $_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 07fda0d8165..848ff05dfc8 100644 --- a/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php @@ -9,25 +9,25 @@ class IntegerTest extends DbalTestCase { /** @var MockPlatform */ - protected $_platform; + private $platform; /** @var Type */ - protected $_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/JsonTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php index 18ef77a6394..4f204a8baec 100644 --- a/tests/Doctrine/Tests/DBAL/Types/JsonTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php @@ -3,6 +3,7 @@ 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; @@ -65,7 +66,7 @@ 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); } diff --git a/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php b/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php index 7f1794e0d0c..858004b73f4 100644 --- a/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php @@ -2,6 +2,7 @@ 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; @@ -11,37 +12,37 @@ class ObjectTest extends DbalTestCase { /** @var MockPlatform */ - protected $_platform; + private $platform; /** @var Type */ - protected $_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)); } /** @@ -49,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 3d4770a9c43..4a453421b36 100644 --- a/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php @@ -9,25 +9,25 @@ class SmallIntTest extends DbalTestCase { /** @var MockPlatform */ - protected $_platform; + private $platform; /** @var Type */ - protected $_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 b19dff22683..74716e4f23c 100644 --- a/tests/Doctrine/Tests/DBAL/Types/StringTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/StringTest.php @@ -9,42 +9,42 @@ class StringTest extends DbalTestCase { /** @var MockPlatform */ - protected $_platform; + private $platform; /** @var Type */ - protected $_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([], $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/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/VarDateTimeTest.php b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php index a4e5139d266..2322aa474fe 100644 --- a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php @@ -3,33 +3,35 @@ 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 DbalTestCase { /** @var MockPlatform */ - protected $_platform; + private $platform; /** @var Type */ - protected $_type; + private $type; protected function setUp() { - $this->_platform = new MockPlatform(); + $this->platform = new MockPlatform(); if (! Type::hasType('vardatetime')) { - Type::addType('vardatetime', 'Doctrine\DBAL\Types\VarDateTimeType'); + 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'); - $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); } @@ -37,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')); @@ -45,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')); @@ -59,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)); + 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 2c94e29555d..e7800fceba3 100644 --- a/tests/Doctrine/Tests/DBAL/UtilTest.php +++ b/tests/Doctrine/Tests/DBAL/UtilTest.php @@ -64,9 +64,9 @@ public static function dataConvertPositionalToNamedParameters() } /** - * @param string $inputSQL - * @param string $expectedOutputSQL - * @param array $expectedOutputParamsMap + * @param string $inputSQL + * @param string $expectedOutputSQL + * @param mixed[] $expectedOutputParamsMap * * @dataProvider dataConvertPositionalToNamedParameters */ diff --git a/tests/Doctrine/Tests/DbalFunctionalTestCase.php b/tests/Doctrine/Tests/DbalFunctionalTestCase.php index 9fabe2d8101..77cfd8d6900 100644 --- a/tests/Doctrine/Tests/DbalFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DbalFunctionalTestCase.php @@ -25,39 +25,39 @@ class DbalFunctionalTestCase extends DbalTestCase * * @var Connection */ - private static $_sharedConn; + private static $sharedConnection; /** @var Connection */ - protected $_conn; + protected $connection; /** @var DebugStack */ - protected $_sqlLoggerStack; + protected $sqlLoggerStack; protected function resetSharedConn() { - if (! self::$_sharedConn) { + if (! self::$sharedConnection) { return; } - self::$_sharedConn->close(); - self::$_sharedConn = null; + 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 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(); } } @@ -67,10 +67,10 @@ protected function onNotSuccessfulTest(Throwable $t) throw $t; } - if (isset($this->_sqlLoggerStack->queries) && count($this->_sqlLoggerStack->queries)) { + if (isset($this->sqlLoggerStack->queries) && count($this->sqlLoggerStack->queries)) { $queries = ''; - $i = count($this->_sqlLoggerStack->queries); - foreach (array_reverse($this->_sqlLoggerStack->queries) as $query) { + $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); diff --git a/tests/Doctrine/Tests/DbalPerformanceTestListener.php b/tests/Doctrine/Tests/DbalPerformanceTestListener.php index 06e8ce77e96..e9265c0f35f 100644 --- a/tests/Doctrine/Tests/DbalPerformanceTestListener.php +++ b/tests/Doctrine/Tests/DbalPerformanceTestListener.php @@ -30,7 +30,7 @@ public function endTest(Test $test, float $time) : void } // we identify perf tests by class, method, and dataset - $class = str_replace('Doctrine\Tests\DBAL\Performance\\', '', get_class($test)); + $class = str_replace('\\Doctrine\\Tests\\DBAL\\Performance\\', '', get_class($test)); if (! isset($this->timings[$class])) { $this->timings[$class] = []; diff --git a/tests/Doctrine/Tests/Mocks/ConnectionMock.php b/tests/Doctrine/Tests/Mocks/ConnectionMock.php index 989b063adc6..157584f09f7 100644 --- a/tests/Doctrine/Tests/Mocks/ConnectionMock.php +++ b/tests/Doctrine/Tests/Mocks/ConnectionMock.php @@ -8,34 +8,40 @@ class ConnectionMock extends Connection { /** @var DatabasePlatformMock */ - private $_platformMock; + private $platformMock; /** @var int */ - private $_lastInsertId = 0; + private $lastInsertId = 0; /** @var string[][] */ - private $_inserts = array(); + private $inserts = []; + /** + * {@inheritDoc} + */ public function __construct(array $params, $driver, $config = null, $eventManager = null) { - $this->_platformMock = new DatabasePlatformMock(); + $this->platformMock = new DatabasePlatformMock(); parent::__construct($params, $driver, $config, $eventManager); } public function getDatabasePlatform() { - return $this->_platformMock; + return $this->platformMock; } + /** + * {@inheritDoc} + */ public function insert($tableName, array $data, array $types = []) { - $this->_inserts[$tableName][] = $data; + $this->inserts[$tableName][] = $data; } public function lastInsertId($seqName = null) { - return $this->_lastInsertId; + return $this->lastInsertId; } public function quote($input, $type = null) @@ -48,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 = []; - $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 231d6dbc5dc..690809e308a 100644 --- a/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php +++ b/tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php @@ -8,72 +8,96 @@ class DatabasePlatformMock extends AbstractPlatform { /** @var string */ - private $_sequenceNextValSql = ''; + private $sequenceNextValSql = ''; /** @var bool */ - private $_prefersIdentityColumns = true; + private $prefersIdentityColumns = true; /** @var bool */ - private $_prefersSequences = false; + private $prefersSequences = false; public function prefersIdentityColumns() { - return $this->_prefersIdentityColumns; + return $this->prefersIdentityColumns; } public function prefersSequences() { - return $this->_prefersSequences; + return $this->prefersSequences; } public function getSequenceNextValSQL($sequenceName) { - return $this->_sequenceNextValSql; + return $this->sequenceNextValSql; } + /** + * {@inheritDoc} + */ public function getBooleanTypeDeclarationSQL(array $field) { } + /** + * {@inheritDoc} + */ public function getIntegerTypeDeclarationSQL(array $field) { } + /** + * {@inheritDoc} + */ public function getBigIntTypeDeclarationSQL(array $field) { } + /** + * {@inheritDoc} + */ public function getSmallIntTypeDeclarationSQL(array $field) { } + /** + * {@inheritDoc} + */ protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef) { } + /** + * {@inheritDoc} + */ public function getVarcharTypeDeclarationSQL(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() @@ -86,8 +110,9 @@ 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/DriverMock.php b/tests/Doctrine/Tests/Mocks/DriverMock.php index 432bb9135ac..9b5f4245472 100644 --- a/tests/Doctrine/Tests/Mocks/DriverMock.php +++ b/tests/Doctrine/Tests/Mocks/DriverMock.php @@ -11,11 +11,14 @@ class DriverMock implements Driver { /** @var DatabasePlatformMock */ - private $_platformMock; + private $platformMock; /** @var AbstractSchemaManager */ - private $_schemaManagerMock; + private $schemaManagerMock; + /** + * {@inheritDoc} + */ public function connect(array $params, $username = null, $password = null, array $driverOptions = []) { return new DriverConnectionMock(); @@ -23,31 +26,29 @@ public function connect(array $params, $username = null, $password = null, array public function getDatabasePlatform() { - if (! $this->_platformMock) { - $this->_platformMock = new DatabasePlatformMock(); + if (! $this->platformMock) { + $this->platformMock = new DatabasePlatformMock(); } - return $this->_platformMock; + return $this->platformMock; } 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(AbstractPlatform $platform) { - $this->_platformMock = $platform; + $this->platformMock = $platform; } public function setSchemaManager(AbstractSchemaManager $sm) { - $this->_schemaManagerMock = $sm; + $this->schemaManagerMock = $sm; } public function getName() 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/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 7e95418bc18..f4740769b8b 100644 --- a/tests/Doctrine/Tests/Types/MySqlPointType.php +++ b/tests/Doctrine/Tests/Types/MySqlPointType.php @@ -8,16 +8,25 @@ 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 ['point'];