diff --git a/.gitignore b/.gitignore index 8b9a3da4a22..aa1b09adbc1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.phpunit.result.cache build/ logs/ reports/ diff --git a/composer.json b/composer.json index df888004dce..4e5631af098 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "doctrine/coding-standard": "^5.0", "jetbrains/phpstorm-stubs": "^2018.1.2", "phpstan/phpstan": "^0.11.1", - "phpunit/phpunit": "^7.4", + "phpunit/phpunit": "^8.0", "symfony/console": "^2.0.5|^3.0|^4.0", "symfony/phpunit-bridge": "^3.4.5|^4.0.5" }, diff --git a/composer.lock b/composer.lock index 9d34a231f1e..6cbca943384 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c0b2296029841f54d6b8438c7773e861", + "content-hash": "3bc5aa75b3af3332def5f89114986259", "packages": [ { "name": "doctrine/cache", @@ -1535,40 +1535,40 @@ }, { "name": "phpunit/php-code-coverage", - "version": "6.0.8", + "version": "7.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "848f78b3309780fef7ec8c4666b7ab4e6b09b22f" + "reference": "4832739a02c418397e404da6c3e4fe680b7a4de7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/848f78b3309780fef7ec8c4666b7ab4e6b09b22f", - "reference": "848f78b3309780fef7ec8c4666b7ab4e6b09b22f", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/4832739a02c418397e404da6c3e4fe680b7a4de7", + "reference": "4832739a02c418397e404da6c3e4fe680b7a4de7", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", - "php": "^7.1", - "phpunit/php-file-iterator": "^2.0", + "php": "^7.2", + "phpunit/php-file-iterator": "^2.0.2", "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.0", + "phpunit/php-token-stream": "^3.0.1", "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^3.1", + "sebastian/environment": "^4.1", "sebastian/version": "^2.0.1", "theseer/tokenizer": "^1.1" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^8.0" }, "suggest": { - "ext-xdebug": "^2.6.0" + "ext-xdebug": "^2.6.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "6.0-dev" + "dev-master": "7.0-dev" } }, "autoload": { @@ -1594,7 +1594,7 @@ "testing", "xunit" ], - "time": "2018-10-04T03:41:23+00:00" + "time": "2019-02-01T07:29:14+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1738,16 +1738,16 @@ }, { "name": "phpunit/php-token-stream", - "version": "3.0.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace" + "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/21ad88bbba7c3d93530d93994e0a33cd45f02ace", - "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/c99e3be9d3e85f60646f152f9002d46ed7770d18", + "reference": "c99e3be9d3e85f60646f152f9002d46ed7770d18", "shasum": "" }, "require": { @@ -1783,20 +1783,20 @@ "keywords": [ "tokenizer" ], - "time": "2018-02-01T13:16:43+00:00" + "time": "2018-10-30T05:52:18+00:00" }, { "name": "phpunit/phpunit", - "version": "7.4.0", + "version": "8.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "f3837fa1e07758057ae06e8ddec6d06ba183f126" + "reference": "130104cf796a88dd1547dc5beb8bd555c2deb55e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f3837fa1e07758057ae06e8ddec6d06ba183f126", - "reference": "f3837fa1e07758057ae06e8ddec6d06ba183f126", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/130104cf796a88dd1547dc5beb8bd555c2deb55e", + "reference": "130104cf796a88dd1547dc5beb8bd555c2deb55e", "shasum": "" }, "require": { @@ -1806,27 +1806,25 @@ "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", + "ext-xmlwriter": "*", "myclabs/deep-copy": "^1.7", "phar-io/manifest": "^1.0.2", "phar-io/version": "^2.0", - "php": "^7.1", + "php": "^7.2", "phpspec/prophecy": "^1.7", - "phpunit/php-code-coverage": "^6.0.7", + "phpunit/php-code-coverage": "^7.0", "phpunit/php-file-iterator": "^2.0.1", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^2.0", "sebastian/comparator": "^3.0", "sebastian/diff": "^3.0", - "sebastian/environment": "^3.1", + "sebastian/environment": "^4.1", "sebastian/exporter": "^3.1", - "sebastian/global-state": "^2.0", + "sebastian/global-state": "^3.0", "sebastian/object-enumerator": "^3.0.3", "sebastian/resource-operations": "^2.0", "sebastian/version": "^2.0.1" }, - "conflict": { - "phpunit/phpunit-mock-objects": "*" - }, "require-dev": { "ext-pdo": "*" }, @@ -1841,7 +1839,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "7.4-dev" + "dev-master": "8.0-dev" } }, "autoload": { @@ -1867,7 +1865,7 @@ "testing", "xunit" ], - "time": "2018-10-05T04:05:24+00:00" + "time": "2019-02-01T05:41:59+00:00" }, { "name": "psr/log", @@ -2083,28 +2081,31 @@ }, { "name": "sebastian/environment", - "version": "3.1.0", + "version": "4.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" + "reference": "6fda8ce1974b62b14935adc02a9ed38252eca656" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", - "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6fda8ce1974b62b14935adc02a9ed38252eca656", + "reference": "6fda8ce1974b62b14935adc02a9ed38252eca656", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^6.1" + "phpunit/phpunit": "^7.5" + }, + "suggest": { + "ext-posix": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1.x-dev" + "dev-master": "4.1-dev" } }, "autoload": { @@ -2129,7 +2130,7 @@ "environment", "hhvm" ], - "time": "2017-07-01T08:51:00+00:00" + "time": "2019-02-01T05:27:49+00:00" }, { "name": "sebastian/exporter", @@ -2200,23 +2201,26 @@ }, { "name": "sebastian/global-state", - "version": "2.0.0", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", - "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", + "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.2", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "ext-dom": "*", + "phpunit/phpunit": "^8.0" }, "suggest": { "ext-uopz": "*" @@ -2224,7 +2228,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -2247,7 +2251,7 @@ "keywords": [ "global state" ], - "time": "2017-04-27T15:39:26+00:00" + "time": "2019-02-01T05:30:01+00:00" }, { "name": "sebastian/object-enumerator", @@ -2877,6 +2881,64 @@ "homepage": "https://symfony.com", "time": "2018-02-19T16:50:22+00:00" }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.10.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "backendtea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2018-08-06T14:22:27+00:00" + }, { "name": "symfony/polyfill-mbstring", "version": "v1.10.0", @@ -2978,20 +3040,21 @@ }, { "name": "webmozart/assert", - "version": "1.3.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a" + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", - "reference": "0df1908962e7a3071564e857d86874dad1ef204a", + "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" }, "require-dev": { "phpunit/phpunit": "^4.6", @@ -3024,7 +3087,7 @@ "check", "validate" ], - "time": "2018-01-29T19:49:41+00:00" + "time": "2018-12-25T11:19:39+00:00" } ], "aliases": [], diff --git a/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php b/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php index 1d500046260..2a8fe528c9d 100644 --- a/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php +++ b/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php @@ -33,7 +33,7 @@ class QueryCacheProfileTest extends DbalTestCase 'driver' => 'database_driver', ]; - protected function setUp() + protected function setUp() : void { $this->queryCacheProfile = new QueryCacheProfile(self::LIFETIME, self::CACHE_KEY); } @@ -110,7 +110,7 @@ public function testConnectionParamsShouldBeHashed() self::assertArrayHasKey('connectionParams', $params); foreach ($this->connectionParams as $param) { - self::assertNotContains($param, $params['connectionParams']); + self::assertStringNotContainsString($param, $params['connectionParams']); } } diff --git a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php index 8310ea15c66..87189bec852 100644 --- a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php +++ b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php @@ -20,7 +20,7 @@ class ConfigurationTest extends DbalTestCase /** * {@inheritdoc} */ - protected function setUp() + protected function setUp() : void { $this->config = new Configuration(); } diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php index 52e95cfc528..3b085ea54c1 100644 --- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php @@ -27,7 +27,7 @@ use Doctrine\Tests\Mocks\ServerInfoAwareConnectionMock; use Doctrine\Tests\Mocks\VersionAwarePlatformDriverMock; use Exception; -use PHPUnit_Framework_MockObject_MockObject; +use PHPUnit\Framework\MockObject\MockObject; use ReflectionObject; use stdClass; use function call_user_func_array; @@ -49,7 +49,7 @@ class ConnectionTest extends DbalTestCase 'port' => '1234', ]; - protected function setUp() + protected function setUp() : void { $this->connection = DriverManager::getConnection($this->params); } @@ -170,7 +170,6 @@ public function testEventManagerPassedToPlatform() /** * @requires extension pdo_sqlite - * @expectedException \Doctrine\DBAL\DBALException * @dataProvider getQueryMethods */ public function testDriverExceptionIsWrapped($method) @@ -519,7 +518,7 @@ public function testFetchAssoc() ->with(FetchMode::ASSOCIATIVE) ->will($this->returnValue($result)); - /** @var PHPUnit_Framework_MockObject_MockObject|Connection $conn */ + /** @var Connection|MockObject $conn */ $conn = $this->getMockBuilder(Connection::class) ->setMethods(['executeQuery']) ->setConstructorArgs([['platform' => new Mocks\MockPlatform()], $driverMock]) @@ -555,7 +554,7 @@ public function testFetchArray() ->with(FetchMode::NUMERIC) ->will($this->returnValue($result)); - /** @var PHPUnit_Framework_MockObject_MockObject|Connection $conn */ + /** @var Connection|MockObject $conn */ $conn = $this->getMockBuilder(Connection::class) ->setMethods(['executeQuery']) ->setConstructorArgs([['platform' => new Mocks\MockPlatform()], $driverMock]) @@ -592,7 +591,7 @@ public function testFetchColumn() ->with($column) ->will($this->returnValue($result)); - /** @var PHPUnit_Framework_MockObject_MockObject|Connection $conn */ + /** @var Connection|MockObject $conn */ $conn = $this->getMockBuilder(Connection::class) ->setMethods(['executeQuery']) ->setConstructorArgs([['platform' => new Mocks\MockPlatform()], $driverMock]) @@ -650,7 +649,7 @@ public function testFetchAll() ->method('fetchAll') ->will($this->returnValue($result)); - /** @var PHPUnit_Framework_MockObject_MockObject|Connection $conn */ + /** @var Connection|MockObject $conn */ $conn = $this->getMockBuilder(Connection::class) ->setMethods(['executeQuery']) ->setConstructorArgs([['platform' => new Mocks\MockPlatform()], $driverMock]) @@ -742,13 +741,13 @@ public function testCallConnectOnce($method, $params) */ public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform() { - /** @var VersionAwarePlatformDriverMock|PHPUnit_Framework_MockObject_MockObject $driverMock */ + /** @var VersionAwarePlatformDriverMock|MockObject $driverMock */ $driverMock = $this->createMock(VersionAwarePlatformDriverMock::class); - /** @var ServerInfoAwareConnectionMock|PHPUnit_Framework_MockObject_MockObject $driverConnectionMock */ + /** @var ServerInfoAwareConnectionMock|MockObject $driverConnectionMock */ $driverConnectionMock = $this->createMock(ServerInfoAwareConnectionMock::class); - /** @var AbstractPlatform|PHPUnit_Framework_MockObject_MockObject $platformMock */ + /** @var AbstractPlatform|MockObject $platformMock */ $platformMock = $this->getMockForAbstractClass(AbstractPlatform::class); $connection = new Connection([], $driverMock); @@ -787,7 +786,7 @@ public function testConnectionParamsArePassedToTheQueryCacheProfileInExecuteCach $params = [666]; $types = [ParameterType::INTEGER]; - /** @var QueryCacheProfile|PHPUnit_Framework_MockObject_MockObject $queryCacheProfileMock */ + /** @var QueryCacheProfile|MockObject $queryCacheProfileMock */ $queryCacheProfileMock = $this->createMock(QueryCacheProfile::class); $queryCacheProfileMock @@ -824,7 +823,7 @@ public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecute ->with('cacheKey') ->will($this->returnValue(['realKey' => []])); - /** @var QueryCacheProfile|PHPUnit_Framework_MockObject_MockObject $queryCacheProfileMock */ + /** @var QueryCacheProfile|MockObject $queryCacheProfileMock */ $queryCacheProfileMock = $this->createMock(QueryCacheProfile::class); $queryCacheProfileMock @@ -871,7 +870,7 @@ public function testThrowsExceptionWhenInValidPlatformSpecified() : void */ public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnectingToNonExistentDatabase() { - /** @var VersionAwarePlatformDriverMock|PHPUnit_Framework_MockObject_MockObject $driverMock */ + /** @var VersionAwarePlatformDriverMock|MockObject $driverMock */ $driverMock = $this->createMock(VersionAwarePlatformDriverMock::class); $connection = new Connection(['dbname' => 'foo'], $driverMock); diff --git a/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php b/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php index 9c0cc18c0be..ccd1becfac9 100644 --- a/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php @@ -20,7 +20,7 @@ public function testDriverExceptionDuringQueryAcceptsBinaryData() /** @var Driver $driver */ $driver = $this->createMock(Driver::class); $e = DBALException::driverExceptionDuringQuery($driver, new Exception(), '', ['ABC', chr(128)]); - self::assertContains('with params ["ABC", "\x80"]', $e->getMessage()); + self::assertStringContainsString('with params ["ABC", "\x80"]', $e->getMessage()); } public function testDriverExceptionDuringQueryAcceptsResource() @@ -28,7 +28,7 @@ public function testDriverExceptionDuringQueryAcceptsResource() /** @var Driver $driver */ $driver = $this->createMock(Driver::class); $e = DBALException::driverExceptionDuringQuery($driver, new Exception(), 'INSERT INTO file (`content`) VALUES (?)', [1 => fopen(__FILE__, 'r')]); - self::assertContains('Resource', $e->getMessage()); + self::assertStringContainsString('Resource', $e->getMessage()); } public function testAvoidOverWrappingOnDriverException() diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php index 0475ea11b89..6a16dd65a91 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\DBAL\Driver; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as DriverExceptionInterface; use Doctrine\DBAL\Driver\ExceptionConverterDriver; @@ -28,6 +29,7 @@ use Doctrine\DBAL\VersionAwarePlatformDriver; use Doctrine\Tests\DbalTestCase; use Exception; +use ReflectionProperty; use function get_class; use function sprintf; @@ -58,7 +60,7 @@ abstract class AbstractDriverTest extends DbalTestCase */ protected $driver; - protected function setUp() + protected function setUp() : void { parent::setUp(); @@ -158,15 +160,13 @@ public function testCreatesDatabasePlatformForVersion() } } - /** - * @expectedException \Doctrine\DBAL\DBALException - */ public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion() { if (! $this->driver instanceof VersionAwarePlatformDriver) { $this->markTestSkipped('This test is only intended for version aware platform drivers.'); } + $this->expectException(DBALException::class); $this->driver->createDatabasePlatformForVersion('foo'); } @@ -198,7 +198,11 @@ public function testReturnsSchemaManager() $schemaManager = $this->driver->getSchemaManager($connection); self::assertEquals($this->createSchemaManager($connection), $schemaManager); - self::assertAttributeSame($connection, '_conn', $schemaManager); + + $re = new ReflectionProperty($schemaManager, '_conn'); + $re->setAccessible(true); + + self::assertSame($connection, $re->getValue($schemaManager)); } /** diff --git a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php index a60772295a6..b6b32751262 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\Driver\IBMDB2\DB2Connection; use Doctrine\Tests\DbalTestCase; -use PHPUnit_Framework_MockObject_MockObject; +use PHPUnit\Framework\MockObject\MockObject; use function extension_loaded; class DB2ConnectionTest extends DbalTestCase @@ -12,11 +12,11 @@ class DB2ConnectionTest extends DbalTestCase /** * The ibm_db2 driver connection mock under test. * - * @var DB2Connection|PHPUnit_Framework_MockObject_MockObject + * @var DB2Connection|MockObject */ private $connectionMock; - protected function setUp() + protected function setUp() : void { if (! extension_loaded('ibm_db2')) { $this->markTestSkipped('ibm_db2 is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php index 9bd3172dd1d..a192edf6f52 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php @@ -6,7 +6,7 @@ use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\Tests\DbalFunctionalTestCase; -use PHPUnit_Framework_MockObject_MockObject; +use PHPUnit\Framework\MockObject\MockObject; use function extension_loaded; use function restore_error_handler; use function set_error_handler; @@ -16,11 +16,11 @@ class MysqliConnectionTest extends DbalFunctionalTestCase /** * The mysqli driver connection mock under test. * - * @var MysqliConnection|PHPUnit_Framework_MockObject_MockObject + * @var MysqliConnection|MockObject */ private $connectionMock; - protected function setUp() + protected function setUp() : void { if (! extension_loaded('mysqli')) { $this->markTestSkipped('mysqli is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php index 0628738400e..81466a3a72e 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\Driver\OCI8\OCI8Connection; use Doctrine\Tests\DbalTestCase; -use PHPUnit_Framework_MockObject_MockObject; +use PHPUnit\Framework\MockObject\MockObject; use function extension_loaded; class OCI8ConnectionTest extends DbalTestCase @@ -12,11 +12,11 @@ class OCI8ConnectionTest extends DbalTestCase /** * The oci8 driver connection mock under test. * - * @var OCI8Connection|PHPUnit_Framework_MockObject_MockObject + * @var OCI8Connection|MockObject */ private $connectionMock; - protected function setUp() + protected function setUp() : void { if (! extension_loaded('oci8')) { $this->markTestSkipped('oci8 is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php index b51f3bf2f5b..86d57105cbb 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php @@ -11,7 +11,7 @@ class OCI8StatementTest extends DbalTestCase { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('oci8')) { $this->markTestSkipped('oci8 is not installed.'); @@ -32,7 +32,6 @@ protected function setUp() * @param mixed[] $params * * @dataProvider executeDataProvider - * @expectedException \Doctrine\DBAL\Driver\OCI8\OCI8Exception */ public function testExecute(array $params) { @@ -73,6 +72,7 @@ public function testExecute(array $params) $reflProperty->setAccessible(true); $reflProperty->setValue($statement, $conn); + $this->expectException(OCI8Exception::class); $statement->execute($params); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php index 593f04d203c..c7564470252 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\Driver\PDOException; use Doctrine\Tests\DbalTestCase; -use PHPUnit_Framework_MockObject_MockObject; +use PHPUnit\Framework\MockObject\MockObject; use function extension_loaded; class PDOExceptionTest extends DbalTestCase @@ -25,11 +25,11 @@ class PDOExceptionTest extends DbalTestCase /** * The wrapped PDO exception mock. * - * @var \PDOException|PHPUnit_Framework_MockObject_MockObject + * @var \PDOException|MockObject */ private $wrappedException; - protected function setUp() + protected function setUp() : void { if (! extension_loaded('PDO')) { $this->markTestSkipped('PDO is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php index d70d36396ba..ccf6e3358f2 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\Driver\SQLAnywhere\SQLAnywhereConnection; use Doctrine\Tests\DbalTestCase; -use PHPUnit_Framework_MockObject_MockObject; +use PHPUnit\Framework\MockObject\MockObject; use function extension_loaded; class SQLAnywhereConnectionTest extends DbalTestCase @@ -12,11 +12,11 @@ class SQLAnywhereConnectionTest extends DbalTestCase /** * The sqlanywhere driver connection mock under test. * - * @var SQLAnywhereConnection|PHPUnit_Framework_MockObject_MockObject + * @var SQLAnywhereConnection|MockObject */ private $connectionMock; - protected function setUp() + protected function setUp() : void { if (! extension_loaded('sqlanywhere')) { $this->markTestSkipped('sqlanywhere is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php index b0e32708428..13ce72a942f 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\Driver\SQLSrv\SQLSrvConnection; use Doctrine\Tests\DbalTestCase; -use PHPUnit_Framework_MockObject_MockObject; +use PHPUnit\Framework\MockObject\MockObject; use function extension_loaded; class SQLSrvConnectionTest extends DbalTestCase @@ -12,11 +12,11 @@ class SQLSrvConnectionTest extends DbalTestCase /** * The sqlsrv driver connection mock under test. * - * @var SQLSrvConnection|PHPUnit_Framework_MockObject_MockObject + * @var SQLSrvConnection|MockObject */ private $connectionMock; - protected function setUp() + protected function setUp() : void { if (! extension_loaded('sqlsrv')) { $this->markTestSkipped('sqlsrv is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php index e5520afcf1e..828e4fc1a3a 100644 --- a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php @@ -25,10 +25,10 @@ class DriverManagerTest extends DbalTestCase { /** * @requires extension pdo_sqlite - * @expectedException \Doctrine\DBAL\DBALException */ public function testInvalidPdoInstance() { + $this->expectException(DBALException::class); DriverManager::getConnection(['pdo' => 'test']); } @@ -58,19 +58,17 @@ public function testPdoInstanceSetErrorMode() self::assertEquals(PDO::ERRMODE_EXCEPTION, $pdo->getAttribute(PDO::ATTR_ERRMODE)); } - /** - * @expectedException \Doctrine\DBAL\DBALException - */ public function testCheckParams() { + $this->expectException(DBALException::class); + DriverManager::getConnection([]); } - /** - * @expectedException \Doctrine\DBAL\DBALException - */ public function testInvalidDriver() { + $this->expectException(DBALException::class); + DriverManager::getConnection(['driver' => 'invalid_driver']); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php b/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php index 7c6de8e3795..69094c97838 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php @@ -18,7 +18,7 @@ */ class BlobTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { parent::setUp(); @@ -164,7 +164,7 @@ private function assertBlobContains($text) $blobValue = Type::getType('blob')->convertToPHPValue($rows[0], $this->connection->getDatabasePlatform()); - self::assertInternalType('resource', $blobValue); + self::assertIsResource($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 b9d03d5e66c..2c75b946500 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php @@ -18,13 +18,13 @@ class ConnectionTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { $this->resetSharedConn(); parent::setUp(); } - protected function tearDown() + protected function tearDown() : void { parent::tearDown(); $this->resetSharedConn(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php index f6ad3cb6b22..fdb0ace7078 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php @@ -4,6 +4,7 @@ use DateTime; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\Mysqli\Driver as MySQLiDriver; use Doctrine\DBAL\Driver\OCI8\Driver as Oci8Driver; use Doctrine\DBAL\Driver\PDOConnection; @@ -37,7 +38,7 @@ class DataAccessTest extends DbalFunctionalTestCase /** @var bool */ static private $generated = false; - protected function setUp() + protected function setUp() : void { parent::setUp(); @@ -238,7 +239,6 @@ public function testFetchAllWithTypes() /** * @group DBAL-209 - * @expectedException \Doctrine\DBAL\DBALException */ public function testFetchAllWithMissingTypes() { @@ -250,6 +250,9 @@ public function testFetchAllWithMissingTypes() $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 = ?'; + + $this->expectException(DBALException::class); + $this->connection->fetchAll($sql, [1, $datetime]); } @@ -304,9 +307,6 @@ public function testFetchAssocWithTypes() self::assertStringStartsWith($datetimeString, $row['test_datetime']); } - /** - * @expectedException \Doctrine\DBAL\DBALException - */ public function testFetchAssocWithMissingTypes() { if ($this->connection->getDriver() instanceof MySQLiDriver || @@ -317,6 +317,9 @@ public function testFetchAssocWithMissingTypes() $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 = ?'; + + $this->expectException(DBALException::class); + $this->connection->fetchAssoc($sql, [1, $datetime]); } @@ -345,9 +348,6 @@ public function testFetchArrayWithTypes() self::assertStringStartsWith($datetimeString, $row[1]); } - /** - * @expectedException \Doctrine\DBAL\DBALException - */ public function testFetchArrayWithMissingTypes() { if ($this->connection->getDriver() instanceof MySQLiDriver || @@ -358,7 +358,10 @@ public function testFetchArrayWithMissingTypes() $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->connection->fetchArray($sql, [1, $datetime]); + + $this->expectException(DBALException::class); + + $this->connection->fetchArray($sql, [1, $datetime]); } public function testFetchColumn() @@ -387,9 +390,6 @@ public function testFetchColumnWithTypes() self::assertStringStartsWith($datetimeString, $column); } - /** - * @expectedException \Doctrine\DBAL\DBALException - */ public function testFetchColumnWithMissingTypes() { if ($this->connection->getDriver() instanceof MySQLiDriver || @@ -400,7 +400,10 @@ public function testFetchColumnWithMissingTypes() $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->connection->fetchColumn($sql, [1, $datetime], 1); + + $this->expectException(DBALException::class); + + $this->connection->fetchColumn($sql, [1, $datetime], 1); } /** diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php index 738c259d5c0..8a0418d2f0a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php @@ -16,7 +16,7 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase */ protected $driver; - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php index 82da6090b7e..144365e0d4d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php @@ -8,7 +8,7 @@ class DB2DriverTest extends AbstractDriverTest { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('ibm_db2')) { $this->markTestSkipped('ibm_db2 is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php index 6c2ec6a9ca6..536c1093073 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php @@ -11,7 +11,7 @@ class DB2StatementTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('ibm_db2')) { $this->markTestSkipped('ibm_db2 is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php index bbd8d5ebd09..d2ced1912c4 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php @@ -4,13 +4,14 @@ use Doctrine\DBAL\Driver\Mysqli\Driver; use Doctrine\DBAL\Driver\Mysqli\MysqliConnection; +use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\Tests\DbalFunctionalTestCase; use const MYSQLI_OPT_CONNECT_TIMEOUT; use function extension_loaded; class ConnectionTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('mysqli')) { $this->markTestSkipped('mysqli is not installed.'); @@ -25,7 +26,7 @@ protected function setUp() $this->markTestSkipped('MySQLi only test.'); } - protected function tearDown() + protected function tearDown() : void { parent::tearDown(); } @@ -38,11 +39,10 @@ public function testDriverOptions() self::assertInstanceOf(MysqliConnection::class, $connection); } - /** - * @expectedException \Doctrine\DBAL\Driver\Mysqli\MysqliException - */ public function testUnsupportedDriverOption() { + $this->expectException(MysqliException::class); + $this->getConnection(['hello' => 'world']); // use local infile } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php index d7f02a40306..a7b7338beed 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php @@ -8,7 +8,7 @@ class DriverTest extends AbstractDriverTest { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('mysqli')) { $this->markTestSkipped('mysqli is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php index a781b31007d..b617b2bb0d3 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php @@ -8,7 +8,7 @@ class DriverTest extends AbstractDriverTest { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('oci8')) { $this->markTestSkipped('oci8 is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php index 1c3226852d6..4e23a2a059a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php @@ -13,7 +13,7 @@ class OCI8ConnectionTest extends DbalFunctionalTestCase /** @var OCI8Connection */ protected $driverConnection; - protected function setUp() + protected function setUp() : void { if (! extension_loaded('oci8')) { $this->markTestSkipped('oci8 is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php index db6a4d552ca..fce2820bde8 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php @@ -8,7 +8,7 @@ class StatementTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('oci8')) { $this->markTestSkipped('oci8 is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php index 214f90700c1..9a12cb8f714 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional\Driver; use Doctrine\DBAL\Driver\PDOConnection; +use Doctrine\DBAL\Driver\PDOException; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; use function extension_loaded; @@ -17,7 +18,7 @@ class PDOConnectionTest extends DbalFunctionalTestCase */ protected $driverConnection; - protected function setUp() + protected function setUp() : void { if (! extension_loaded('PDO')) { $this->markTestSkipped('PDO is not installed.'); @@ -34,7 +35,7 @@ protected function setUp() $this->markTestSkipped('PDO connection only test.'); } - protected function tearDown() + protected function tearDown() : void { $this->resetSharedConn(); @@ -46,26 +47,23 @@ public function testDoesNotRequireQueryForServerVersion() self::assertFalse($this->driverConnection->requiresQueryForServerVersion()); } - /** - * @expectedException \Doctrine\DBAL\Driver\PDOException - */ public function testThrowsWrappedExceptionOnConstruct() { + $this->expectException(PDOException::class); + new PDOConnection('foo'); } /** * @group DBAL-1022 - * @expectedException \Doctrine\DBAL\Driver\PDOException */ public function testThrowsWrappedExceptionOnExec() { + $this->expectException(PDOException::class); + $this->driverConnection->exec('foo'); } - /** - * @expectedException \Doctrine\DBAL\Driver\PDOException - */ public function testThrowsWrappedExceptionOnPrepare() { if ($this->connection->getDriver()->getName() === 'pdo_sqlsrv') { @@ -76,6 +74,8 @@ public function testThrowsWrappedExceptionOnPrepare() // so that PDO actually communicates with the database server to check the query. $this->driverConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); + $this->expectException(PDOException::class); + $this->driverConnection->prepare('foo'); // Some PDO adapters like PostgreSQL do not check the query server-side @@ -91,11 +91,10 @@ public function testThrowsWrappedExceptionOnPrepare() ); } - /** - * @expectedException \Doctrine\DBAL\Driver\PDOException - */ public function testThrowsWrappedExceptionOnQuery() { + $this->expectException(PDOException::class); + $this->driverConnection->query('foo'); } } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php index cb0f9633201..9fe297278f6 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php @@ -8,7 +8,7 @@ class DriverTest extends AbstractDriverTest { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('pdo_mysql')) { $this->markTestSkipped('pdo_mysql is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php index 604fbc8b123..3a5b44c22fa 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php @@ -8,7 +8,7 @@ class DriverTest extends AbstractDriverTest { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('PDO_OCI')) { $this->markTestSkipped('PDO_OCI is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php index 289621c5eba..2ea657cfa99 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php @@ -13,7 +13,7 @@ class DriverTest extends AbstractDriverTest { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('pdo_pgsql')) { $this->markTestSkipped('pdo_pgsql is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php index 0893bed2e70..7bfde54a6f3 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php @@ -10,7 +10,7 @@ class PDOPgsqlConnectionTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('pdo_pgsql')) { $this->markTestSkipped('pdo_pgsql is not loaded.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php index 36978d4b4fd..3df6d7a6540 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php @@ -8,7 +8,7 @@ class DriverTest extends AbstractDriverTest { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('pdo_sqlite')) { $this->markTestSkipped('pdo_sqlite is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php index f125eab3515..a20bf838a89 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php @@ -10,7 +10,7 @@ class DriverTest extends AbstractDriverTest { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('pdo_sqlsrv')) { $this->markTestSkipped('pdo_sqlsrv is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php index 63253a84408..e1df07bbac2 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php @@ -9,7 +9,7 @@ class ConnectionTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('sqlanywhere')) { $this->markTestSkipped('sqlanywhere is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php index 07d0189a88d..4e42e863a46 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php @@ -9,7 +9,7 @@ class DriverTest extends AbstractDriverTest { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('sqlanywhere')) { $this->markTestSkipped('sqlanywhere is not installed.'); @@ -38,7 +38,7 @@ public function testReturnsDatabaseNameWithoutDatabaseNameParameter() // SQL Anywhere has no "default" database. The name of the default database // is defined on server startup and therefore can be arbitrary. - self::assertInternalType('string', $this->driver->getDatabase($connection)); + self::assertIsString($this->driver->getDatabase($connection)); } /** diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php index 3cf5c282ea0..b67c8e571b4 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php @@ -9,7 +9,7 @@ class StatementTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('sqlanywhere')) { $this->markTestSkipped('sqlanywhere is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php index b09d7339fc9..0677878063d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php @@ -8,7 +8,7 @@ class DriverTest extends AbstractDriverTest { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('sqlsrv')) { $this->markTestSkipped('sqlsrv is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php index 38df9cb5181..2d52b5c0cd3 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php @@ -9,7 +9,7 @@ class StatementTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('sqlsrv')) { self::markTestSkipped('sqlsrv is not installed.'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php index e420000ba58..54b4bc1d90a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php @@ -20,7 +20,7 @@ class ExceptionTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php index 00dc7e876eb..d927285e2a3 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php @@ -20,7 +20,7 @@ */ class MasterSlaveConnectionTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php b/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php index 94fb02da547..88c28661634 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php @@ -13,7 +13,7 @@ class ModifyLimitQueryTest extends DbalFunctionalTestCase /** @var bool */ private static $tableCreated = false; - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php b/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php index fec2e5944d6..4dec0809fb4 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php @@ -147,7 +147,7 @@ public function ticketProvider() ]; } - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php index f1e5c5a229a..1ba37b61394 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php @@ -10,7 +10,7 @@ class PDOStatementTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { if (! extension_loaded('pdo')) { $this->markTestSkipped('PDO is not installed'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php b/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php index ec387638c40..64efb1aad6a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php @@ -11,7 +11,7 @@ final class NewPrimaryKeyWithNewAutoIncrementColumnTest extends DbalFunctionalTe /** * {@inheritDoc} */ - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php b/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php index 33894dc55b8..6f4e0642db1 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php @@ -21,7 +21,7 @@ class PortabilityTest extends DbalFunctionalTestCase /** @var Connection */ private $portableConnection; - protected function tearDown() + protected function tearDown() : void { if ($this->portableConnection) { $this->portableConnection->close(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php index 2c64c280b6d..82f9e6541ed 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php @@ -26,7 +26,7 @@ class ResultCacheTest extends DbalFunctionalTestCase /** @var DebugStack */ private $sqlLogger; - protected function setUp() + protected function setUp() : void { parent::setUp(); @@ -49,7 +49,7 @@ protected function setUp() $config->setResultCacheImpl($cache); } - protected function tearDown() + protected function tearDown() : void { $this->connection->getSchemaManager()->dropTable('caching'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php index 0feb30fa5ba..13503e3187b 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php @@ -17,7 +17,7 @@ class ComparatorTest extends DbalFunctionalTestCase /** @var Comparator */ private $comparator; - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php index 9cb4b7e51b1..92e0f497a6d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php @@ -15,7 +15,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase { - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php index b366cc9c002..14e082c07dc 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php @@ -14,7 +14,7 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase /** @var bool */ private static $privilegesGranted = false; - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php index 864820b595c..b30c861f704 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php @@ -19,7 +19,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase { - protected function tearDown() + protected function tearDown() : void { parent::tearDown(); @@ -48,7 +48,7 @@ public function testGetSchemaNames() { $names = $this->schemaManager->getSchemaNames(); - self::assertInternalType('array', $names); + self::assertIsArray($names); self::assertNotEmpty($names); self::assertContains('public', $names, 'The public schema should be found.'); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php index f076a806a7a..73eb07ea178 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php @@ -37,7 +37,7 @@ public function testDropAndCreateAdvancedIndex() ); $tableIndexes = $this->schemaManager->listTableIndexes('test_create_advanced_index'); - self::assertInternalType('array', $tableIndexes); + self::assertIsArray($tableIndexes); self::assertEquals('test', $tableIndexes['test']->getName()); self::assertEquals(['test'], $tableIndexes['test']->getColumns()); self::assertTrue($tableIndexes['test']->isUnique()); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php index 1c0afc93e66..6c2679baebb 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -59,7 +59,7 @@ protected function getPlatformName() return strtolower(str_replace('SchemaManagerTest', null, $testClass)); } - protected function setUp() + protected function setUp() : void { parent::setUp(); @@ -73,7 +73,7 @@ protected function setUp() } - protected function tearDown() + protected function tearDown() : void { parent::tearDown(); @@ -168,7 +168,7 @@ public function testListSequences() $sequences = $this->schemaManager->listSequences(); - self::assertInternalType('array', $sequences, 'listSequences() should return an array.'); + self::assertIsArray($sequences, 'listSequences() should return an array.'); $foundSequence = null; foreach ($sequences as $sequence) { @@ -227,7 +227,7 @@ public function testListTables() $this->createTestTable('list_tables_test'); $tables = $this->schemaManager->listTables(); - self::assertInternalType('array', $tables); + self::assertIsArray($tables); self::assertTrue(count($tables) > 0, "List Tables has to find at least one table named 'list_tables_test'."); $foundTable = false; @@ -278,7 +278,7 @@ public function testListTableColumns() self::assertEquals(false, $columns['id']->getunsigned()); self::assertEquals(true, $columns['id']->getnotnull()); self::assertEquals(null, $columns['id']->getdefault()); - self::assertInternalType('array', $columns['id']->getPlatformOptions()); + self::assertIsArray($columns['id']->getPlatformOptions()); self::assertArrayHasKey('test', $columns); self::assertEquals(1, array_search('test', $columnsKeys)); @@ -288,7 +288,7 @@ public function testListTableColumns() self::assertEquals(false, $columns['test']->getfixed()); self::assertEquals(false, $columns['test']->getnotnull()); self::assertEquals('expected default', $columns['test']->getdefault()); - self::assertInternalType('array', $columns['test']->getPlatformOptions()); + self::assertIsArray($columns['test']->getPlatformOptions()); self::assertEquals('foo', strtolower($columns['foo']->getname())); self::assertEquals(2, array_search('foo', $columnsKeys)); @@ -297,7 +297,7 @@ public function testListTableColumns() self::assertEquals(false, $columns['foo']->getfixed()); self::assertEquals(true, $columns['foo']->getnotnull()); self::assertEquals(null, $columns['foo']->getdefault()); - self::assertInternalType('array', $columns['foo']->getPlatformOptions()); + self::assertIsArray($columns['foo']->getPlatformOptions()); self::assertEquals('bar', strtolower($columns['bar']->getname())); self::assertEquals(3, array_search('bar', $columnsKeys)); @@ -309,28 +309,28 @@ public function testListTableColumns() self::assertEquals(false, $columns['bar']->getfixed()); self::assertEquals(false, $columns['bar']->getnotnull()); self::assertEquals(null, $columns['bar']->getdefault()); - self::assertInternalType('array', $columns['bar']->getPlatformOptions()); + self::assertIsArray($columns['bar']->getPlatformOptions()); self::assertEquals('baz1', strtolower($columns['baz1']->getname())); self::assertEquals(4, array_search('baz1', $columnsKeys)); self::assertInstanceOf(DateTimeType::class, $columns['baz1']->gettype()); self::assertEquals(true, $columns['baz1']->getnotnull()); self::assertEquals(null, $columns['baz1']->getdefault()); - self::assertInternalType('array', $columns['baz1']->getPlatformOptions()); + self::assertIsArray($columns['baz1']->getPlatformOptions()); self::assertEquals('baz2', strtolower($columns['baz2']->getname())); self::assertEquals(5, array_search('baz2', $columnsKeys)); self::assertContains($columns['baz2']->gettype()->getName(), ['time', 'date', 'datetime']); self::assertEquals(true, $columns['baz2']->getnotnull()); self::assertEquals(null, $columns['baz2']->getdefault()); - self::assertInternalType('array', $columns['baz2']->getPlatformOptions()); + self::assertIsArray($columns['baz2']->getPlatformOptions()); self::assertEquals('baz3', strtolower($columns['baz3']->getname())); self::assertEquals(6, array_search('baz3', $columnsKeys)); self::assertContains($columns['baz3']->gettype()->getName(), ['time', 'date', 'datetime']); self::assertEquals(true, $columns['baz3']->getnotnull()); self::assertEquals(null, $columns['baz3']->getdefault()); - self::assertInternalType('array', $columns['baz3']->getPlatformOptions()); + self::assertIsArray($columns['baz3']->getPlatformOptions()); } /** @@ -459,7 +459,7 @@ public function testDropAndCreateIndex() $this->schemaManager->dropAndCreateIndex($table->getIndex('test'), $table); $tableIndexes = $this->schemaManager->listTableIndexes('test_create_index'); - self::assertInternalType('array', $tableIndexes); + self::assertIsArray($tableIndexes); self::assertEquals('test', strtolower($tableIndexes['test']->getName())); self::assertEquals(['test'], array_map('strtolower', $tableIndexes['test']->getColumns())); @@ -1188,8 +1188,8 @@ public function testCommentNotDuplicated() $table->addColumn('id', 'integer', ['columnDefinition' => $columnDefinition, 'comment' => 'unexpected_column_comment']); $sql = $this->connection->getDatabasePlatform()->getCreateTableSQL($table); - self::assertContains('expected+column+comment', $sql[0]); - self::assertNotContains('unexpected_column_comment', $sql[0]); + self::assertStringContainsString('expected+column+comment', $sql[0]); + self::assertStringNotContainsString('unexpected_column_comment', $sql[0]); } /** diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php index 659e6d8dff2..a9f0ccdcfec 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php @@ -2,6 +2,7 @@ namespace Doctrine\Tests\DBAL\Functional\Schema; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema\Table; @@ -17,11 +18,11 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase { /** * SQLITE does not support databases. - * - * @expectedException \Doctrine\DBAL\DBALException */ public function testListDatabases() { + $this->expectException(DBALException::class); + $this->schemaManager->listDatabases(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php index 7bd7009c788..66b4a93a207 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php @@ -14,7 +14,7 @@ class StatementTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { parent::setUp(); @@ -69,7 +69,7 @@ public function testReuseStatementWithLongerResults() $stmt = $this->connection->prepare('SELECT param, val FROM stmt_longer_results ORDER BY param'); $stmt->execute(); - self::assertArraySubset([ + self::assertEquals([ ['param1', 'X'], ], $stmt->fetchAll(FetchMode::NUMERIC)); @@ -80,7 +80,7 @@ public function testReuseStatementWithLongerResults() $this->connection->insert('stmt_longer_results', $row2); $stmt->execute(); - self::assertArraySubset([ + self::assertEquals([ ['param1', 'X'], ['param2', 'A bit longer value'], ], $stmt->fetchAll(FetchMode::NUMERIC)); diff --git a/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php b/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php index f62b992015c..a6721b88f8d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php @@ -16,7 +16,7 @@ class TableGeneratorTest extends DbalFunctionalTestCase /** @var TableGenerator */ private $generator; - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php b/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php index 87a776c7e06..8dae876dc0c 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php @@ -9,7 +9,7 @@ class TemporaryTableTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { parent::setUp(); try { @@ -18,7 +18,7 @@ protected function setUp() } } - protected function tearDown() + protected function tearDown() : void { if ($this->connection) { try { diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php index 1adf993250f..eeb9b7e24ed 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php @@ -10,7 +10,7 @@ */ class DBAL202Test extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php index af41670690a..6b77db02f0a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php @@ -11,7 +11,7 @@ */ class DBAL421Test extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php index fa98ecb3eca..620b0a66249 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php @@ -11,7 +11,7 @@ */ class DBAL510Test extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php index 827a9124277..21c6e492622 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php @@ -16,7 +16,7 @@ class DBAL630Test extends DbalFunctionalTestCase /** @var bool */ private $running = false; - protected function setUp() + protected function setUp() : void { parent::setUp(); @@ -34,7 +34,7 @@ protected function setUp() $this->running = true; } - protected function tearDown() + protected function tearDown() : void { if ($this->running) { $this->connection->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php index ee0bce44e08..3e087b21b36 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php @@ -10,7 +10,7 @@ */ class DBAL752Test extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php b/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php index 0e086b598e4..768b65275f7 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php @@ -8,7 +8,6 @@ use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalFunctionalTestCase; use stdClass; -use Throwable; use function str_repeat; class TypeConversionTest extends DbalFunctionalTestCase @@ -16,7 +15,7 @@ class TypeConversionTest extends DbalFunctionalTestCase /** @var int */ static private $typeCounter = 0; - protected function setUp() + protected function setUp() : void { parent::setUp(); @@ -38,45 +37,79 @@ protected function setUp() $table->addColumn('test_decimal', 'decimal', ['notnull' => false, 'scale' => 2, 'precision' => 10]); $table->setPrimaryKey(['id']); - try { - $this->connection->getSchemaManager()->createTable($table); - } catch (Throwable $e) { - } + $this->connection + ->getSchemaManager() + ->dropAndCreateTable($table); } - public static function dataIdempotentDataConversion() + /** + * @dataProvider booleanProvider + */ + public function testIdempotentConversionToBoolean(string $type, $originalValue) : void { - $obj = new stdClass(); - $obj->foo = 'bar'; - $obj->bar = 'baz'; + $dbValue = $this->processValue($type, $originalValue); + + self::assertIsBool($dbValue); + self::assertEquals($originalValue, $dbValue); + } + + /** + * @return mixed[][] + */ + public static function booleanProvider() : iterable + { + return [ + 'true' => ['boolean', true], + 'false' => ['boolean', false], + ]; + } + /** + * @dataProvider integerProvider + */ + public function testIdempotentConversionToInteger(string $type, $originalValue) : void + { + $dbValue = $this->processValue($type, $originalValue); + + self::assertIsInt($dbValue); + self::assertEquals($originalValue, $dbValue); + } + + /** + * @return mixed[][] + */ + public static function integerProvider() : iterable + { return [ - ['string', 'ABCDEFGaaaBBB', 'string'], - ['boolean', true, 'bool'], - ['boolean', false, 'bool'], - ['bigint', 12345678, 'string'], - ['smallint', 123, 'int'], - ['datetime', new DateTime('2010-04-05 10:10:10'), 'DateTime'], - ['datetimetz', new DateTime('2010-04-05 10:10:10'), 'DateTime'], - ['date', new DateTime('2010-04-05'), 'DateTime'], - ['time', new DateTime('1970-01-01 10:10:10'), 'DateTime'], - ['text', str_repeat('foo ', 1000), 'string'], - ['array', ['foo' => 'bar'], 'array'], - ['json_array', ['foo' => 'bar'], 'array'], - ['object', $obj, 'object'], - ['float', 1.5, 'float'], - ['decimal', 1.55, 'string'], + 'smallint' => ['smallint', 123], ]; } /** - * @param string $type - * @param mixed $originalValue - * @param string $expectedPhpType - * - * @dataProvider dataIdempotentDataConversion + * @dataProvider floatProvider */ - public function testIdempotentDataConversion($type, $originalValue, $expectedPhpType) + public function testIdempotentConversionToFloat(string $type, $originalValue) : void + { + $dbValue = $this->processValue($type, $originalValue); + + self::assertIsFloat($dbValue); + self::assertEquals($originalValue, $dbValue); + } + + /** + * @return mixed[][] + */ + public static function floatProvider() : iterable + { + return [ + 'float' => ['float', 1.5], + ]; + } + + /** + * @dataProvider toStringProvider + */ + public function testIdempotentConversionToString(string $type, $originalValue) : void { if ($type === 'text' && $this->connection->getDriver() instanceof PDOOracleDriver) { // inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported @@ -84,31 +117,121 @@ public function testIdempotentDataConversion($type, $originalValue, $expectedPhp $this->markTestSkipped('DBAL doesn\'t support storing LOBs represented as streams using PDO_OCI'); } - $columnName = 'test_' . $type; - $typeInstance = Type::getType($type); - $insertionValue = $typeInstance->convertToDatabaseValue($originalValue, $this->connection->getDatabasePlatform()); + $dbValue = $this->processValue($type, $originalValue); - $this->connection->insert('type_conversion', ['id' => ++self::$typeCounter, $columnName => $insertionValue]); + self::assertIsString($dbValue); + self::assertEquals($originalValue, $dbValue); + } - $sql = 'SELECT ' . $columnName . ' FROM type_conversion WHERE id = ' . self::$typeCounter; - $actualDbValue = $typeInstance->convertToPHPValue($this->connection->fetchColumn($sql), $this->connection->getDatabasePlatform()); + /** + * @return mixed[][] + */ + public static function toStringProvider() : iterable + { + return [ + 'string' => ['string', 'ABCDEFGabcdefg'], + 'bigint' => ['bigint', 12345678], + 'text' => ['text', str_repeat('foo ', 1000)], + 'decimal' => ['decimal', 1.55], + ]; + } - if ($originalValue instanceof DateTime) { - self::assertInstanceOf($expectedPhpType, $actualDbValue, 'The expected type from the conversion to and back from the database should be ' . $expectedPhpType); - } else { - self::assertInternalType($expectedPhpType, $actualDbValue, 'The expected type from the conversion to and back from the database should be ' . $expectedPhpType); - } + /** + * @dataProvider toArrayProvider + */ + public function testIdempotentConversionToArray(string $type, $originalValue) : void + { + $dbValue = $this->processValue($type, $originalValue); + + self::assertIsArray($dbValue); + self::assertEquals($originalValue, $dbValue); + } + + /** + * @return mixed[][] + */ + public static function toArrayProvider() : iterable + { + return [ + 'array' => ['array', ['foo' => 'bar']], + 'json_array' => ['json_array', ['foo' => 'bar']], + ]; + } + + /** + * @dataProvider toObjectProvider + */ + public function testIdempotentConversionToObject(string $type, $originalValue) : void + { + $dbValue = $this->processValue($type, $originalValue); + + self::assertIsObject($dbValue); + self::assertEquals($originalValue, $dbValue); + } + + /** + * @return mixed[][] + */ + public static function toObjectProvider() : iterable + { + $obj = new stdClass(); + $obj->foo = 'bar'; + $obj->bar = 'baz'; + + return [ + 'object' => ['object', $obj], + ]; + } + + /** + * @dataProvider toDateTimeProvider + */ + public function testIdempotentConversionToDateTime(string $type, DateTime $originalValue) : void + { + $dbValue = $this->processValue($type, $originalValue); + + self::assertInstanceOf(DateTime::class, $dbValue); if ($type === 'datetimetz') { return; } - self::assertEquals($originalValue, $actualDbValue, 'Conversion between values should produce the same out as in value, but doesnt!'); + self::assertEquals($originalValue, $dbValue); + self::assertEquals( + $originalValue->getTimezone(), + $dbValue->getTimezone() + ); + } - if (! ($originalValue instanceof DateTime)) { - return; - } + /** + * @return mixed[][] + */ + public static function toDateTimeProvider() : iterable + { + return [ + 'datetime' => ['datetime', new DateTime('2010-04-05 10:10:10')], + 'datetimetz' => ['datetimetz', new DateTime('2010-04-05 10:10:10')], + 'date' => ['date', new DateTime('2010-04-05')], + 'time' => ['time', new DateTime('1970-01-01 10:10:10')], + ]; + } + + /** + * @param mixed $originalValue + */ + private function processValue(string $type, $originalValue) + { + $columnName = 'test_' . $type; + $typeInstance = Type::getType($type); + $insertionValue = $typeInstance->convertToDatabaseValue($originalValue, $this->connection->getDatabasePlatform()); + + $this->connection->insert('type_conversion', ['id' => ++self::$typeCounter, $columnName => $insertionValue]); + + $sql = 'SELECT ' . $columnName . ' FROM type_conversion WHERE id = ' . self::$typeCounter; - self::assertEquals($originalValue->getTimezone()->getName(), $actualDbValue->getTimezone()->getName(), 'Timezones should be the same.'); + return $typeInstance->convertToPHPValue( + $this->connection->fetchColumn($sql), + $this->connection->getDatabasePlatform() + ); } } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php b/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php index 55b49156f87..d212b969997 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php @@ -16,7 +16,7 @@ class BinaryTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php index e25de428aff..52cef4d9fc2 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php @@ -15,7 +15,7 @@ class WriteTest extends DbalFunctionalTestCase { - protected function setUp() + protected function setUp() : void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php b/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php index 914351c75dc..c2239639f26 100644 --- a/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php +++ b/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php @@ -10,12 +10,12 @@ class DebugStackTest extends DbalTestCase /** @var DebugStack */ private $logger; - protected function setUp() + protected function setUp() : void { $this->logger = new DebugStack(); } - protected function tearDown() + protected function tearDown() : void { unset($this->logger); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php index 6dec263df34..79dbc0040b1 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\DBAL\Platforms; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Index; @@ -13,6 +14,9 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase { + /** @var MySqlPlatform */ + protected $platform; + public function testModifyLimitQueryWitoutLimit() { $sql = $this->platform->modifyLimitQuery('SELECT n FROM Foo', null, 10); @@ -842,7 +846,10 @@ public function getGeneratesFloatDeclarationSQL() */ public function testQuotesTableNameInListTableIndexesSQL() { - self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableIndexesSQL("Foo'Bar\\", 'foo_db'), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\\\'", + $this->platform->getListTableIndexesSQL("Foo'Bar\\", 'foo_db') + ); } /** @@ -850,7 +857,10 @@ public function testQuotesTableNameInListTableIndexesSQL() */ public function testQuotesDatabaseNameInListTableIndexesSQL() { - self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableIndexesSQL('foo_table', "Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\\\'", + $this->platform->getListTableIndexesSQL('foo_table', "Foo'Bar\\") + ); } /** @@ -858,7 +868,10 @@ public function testQuotesDatabaseNameInListTableIndexesSQL() */ public function testQuotesDatabaseNameInListViewsSQL() { - self::assertContains("'Foo''Bar\\\\'", $this->platform->getListViewsSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\\\'", + $this->platform->getListViewsSQL("Foo'Bar\\") + ); } /** @@ -866,7 +879,10 @@ public function testQuotesDatabaseNameInListViewsSQL() */ public function testQuotesTableNameInListTableForeignKeysSQL() { - self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\\\'", + $this->platform->getListTableForeignKeysSQL("Foo'Bar\\") + ); } /** @@ -874,7 +890,10 @@ public function testQuotesTableNameInListTableForeignKeysSQL() */ public function testQuotesDatabaseNameInListTableForeignKeysSQL() { - self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableForeignKeysSQL('foo_table', "Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\\\'", + $this->platform->getListTableForeignKeysSQL('foo_table', "Foo'Bar\\") + ); } /** @@ -882,7 +901,10 @@ public function testQuotesDatabaseNameInListTableForeignKeysSQL() */ public function testQuotesTableNameInListTableColumnsSQL() { - self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableColumnsSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\\\'", + $this->platform->getListTableColumnsSQL("Foo'Bar\\") + ); } /** @@ -890,19 +912,22 @@ public function testQuotesTableNameInListTableColumnsSQL() */ public function testQuotesDatabaseNameInListTableColumnsSQL() { - self::assertContains("'Foo''Bar\\\\'", $this->platform->getListTableColumnsSQL('foo_table', "Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\\\'", + $this->platform->getListTableColumnsSQL('foo_table', "Foo'Bar\\") + ); } public function testListTableForeignKeysSQLEvaluatesDatabase() { $sql = $this->platform->getListTableForeignKeysSQL('foo'); - self::assertContains('DATABASE()', $sql); + self::assertStringContainsString('DATABASE()', $sql); $sql = $this->platform->getListTableForeignKeysSQL('foo', 'bar'); - self::assertContains('bar', $sql); - self::assertNotContains('DATABASE()', $sql); + self::assertStringContainsString('bar', $sql); + self::assertStringNotContainsString('DATABASE()', $sql); } public function testColumnCharsetDeclarationSQL() : void diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php index 8fee20fede2..5feba5f96f6 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php @@ -29,7 +29,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase abstract public function createPlatform(); - protected function setUp() + protected function setUp() : void { $this->platform = $this->createPlatform(); } @@ -266,10 +266,7 @@ public function testGeneratesForeignKeySqlOnlyWhenSupportingForeignKeys() $fk = new ForeignKeyConstraint(['fk_name'], 'foreign', ['id'], 'constraint_fk'); if ($this->platform->supportsForeignKeyConstraints()) { - self::assertInternalType( - 'string', - $this->platform->getCreateForeignKeySQL($fk, 'test') - ); + self::assertIsString($this->platform->getCreateForeignKeySQL($fk, 'test')); } else { $this->expectException(DBALException::class); $this->platform->getCreateForeignKeySQL($fk, 'test'); @@ -773,11 +770,10 @@ protected function supportsCommentOnStatement() return false; } - /** - * @expectedException \Doctrine\DBAL\DBALException - */ public function testGetCreateSchemaSQL() { + $this->expectException(DBALException::class); + $this->platform->getCreateSchemaSQL('schema'); } @@ -797,7 +793,7 @@ public function testAlterTableChangeQuotedColumn() ['type'] ); - self::assertContains( + self::assertStringContainsString( $this->platform->quoteIdentifier('select'), implode(';', $this->platform->getAlterTableSQL($tableDiff)) ); @@ -813,10 +809,11 @@ public function testUsesSequenceEmulatedIdentityColumns() /** * @group DBAL-563 - * @expectedException \Doctrine\DBAL\DBALException */ public function testReturnsIdentitySequenceName() { + $this->expectException(DBALException::class); + $this->platform->getIdentitySequenceName('mytable', 'mycolumn'); } @@ -840,11 +837,10 @@ protected function getBinaryMaxLength() return 4000; } - /** - * @expectedException \Doctrine\DBAL\DBALException - */ public function testReturnsBinaryTypeDeclarationSQL() { + $this->expectException(DBALException::class); + $this->platform->getBinaryTypeDeclarationSQL([]); } @@ -1301,10 +1297,11 @@ public function testQuoteStringLiteral() /** * @group DBAL-423 - * @expectedException \Doctrine\DBAL\DBALException */ public function testReturnsGuidTypeDeclarationSQL() { + $this->expectException(DBALException::class); + $this->platform->getGuidTypeDeclarationSQL([]); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php index 2624de8f71c..81d760e30b6 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 UnexpectedValueException; use function sprintf; abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCase @@ -477,13 +478,14 @@ public function testConvertFromBoolean($databaseValue, $prepareStatementValue, $ self::assertSame($booleanValue, $platform->convertFromBoolean($databaseValue)); } - /** - * @expectedException UnexpectedValueException - * @expectedExceptionMessage Unrecognized boolean literal 'my-bool' - */ public function testThrowsExceptionWithInvalidBooleanLiteral() { - $platform = $this->createPlatform()->convertBooleansToDatabaseValue('my-bool'); + $platform = $this->createPlatform(); + + $this->expectException(UnexpectedValueException::class); + $this->expectExceptionMessage("Unrecognized boolean literal 'my-bool'"); + + $platform->convertBooleansToDatabaseValue('my-bool'); } public function testGetCreateSchemaSQL() @@ -602,7 +604,7 @@ public function testReturnsIdentitySequenceName() public function testCreateSequenceWithCache($cacheSize, $expectedSql) { $sequence = new Sequence('foo', 1, 1, $cacheSize); - self::assertContains($expectedSql, $this->platform->getCreateSequenceSQL($sequence)); + self::assertStringContainsString($expectedSql, $this->platform->getCreateSequenceSQL($sequence)); } public function dataCreateSequenceWithCache() @@ -952,7 +954,10 @@ public function testReturnsCloseActiveDatabaseConnectionsSQL() */ public function testQuotesTableNameInListTableForeignKeysSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableForeignKeysSQL("Foo'Bar\\") + ); } /** @@ -960,11 +965,9 @@ public function testQuotesTableNameInListTableForeignKeysSQL() */ public function testQuotesSchemaNameInListTableForeignKeysSQL() { - self::assertContains( + self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", - $this->platform->getListTableForeignKeysSQL("Foo'Bar\\.baz_table"), - '', - true + $this->platform->getListTableForeignKeysSQL("Foo'Bar\\.baz_table") ); } @@ -973,7 +976,10 @@ public function testQuotesSchemaNameInListTableForeignKeysSQL() */ public function testQuotesTableNameInListTableConstraintsSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableConstraintsSQL("Foo'Bar\\") + ); } /** @@ -981,7 +987,10 @@ public function testQuotesTableNameInListTableConstraintsSQL() */ public function testQuotesTableNameInListTableIndexesSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableIndexesSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableIndexesSQL("Foo'Bar\\") + ); } /** @@ -989,11 +998,9 @@ public function testQuotesTableNameInListTableIndexesSQL() */ public function testQuotesSchemaNameInListTableIndexesSQL() { - self::assertContains( + self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", - $this->platform->getListTableIndexesSQL("Foo'Bar\\.baz_table"), - '', - true + $this->platform->getListTableIndexesSQL("Foo'Bar\\.baz_table") ); } @@ -1002,7 +1009,10 @@ public function testQuotesSchemaNameInListTableIndexesSQL() */ public function testQuotesTableNameInListTableColumnsSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableColumnsSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableColumnsSQL("Foo'Bar\\") + ); } /** @@ -1010,11 +1020,9 @@ public function testQuotesTableNameInListTableColumnsSQL() */ public function testQuotesSchemaNameInListTableColumnsSQL() { - self::assertContains( + self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", - $this->platform->getListTableColumnsSQL("Foo'Bar\\.baz_table"), - '', - true + $this->platform->getListTableColumnsSQL("Foo'Bar\\.baz_table") ); } @@ -1023,11 +1031,9 @@ public function testQuotesSchemaNameInListTableColumnsSQL() */ public function testQuotesDatabaseNameInCloseActiveDatabaseConnectionsSQL() { - self::assertContains( + self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", - $this->platform->getCloseActiveDatabaseConnectionsSQL("Foo'Bar\\"), - '', - true + $this->platform->getCloseActiveDatabaseConnectionsSQL("Foo'Bar\\") ); } } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php index 1341c9e8819..b43facd2406 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php @@ -47,11 +47,10 @@ public function getGenerateAlterTableSql() ]; } - /** - * @expectedException \Doctrine\DBAL\DBALException - */ public function testDoesNotSupportRegexp() { + $this->expectException(DBALException::class); + $this->platform->getRegexpExpression(); } @@ -1423,7 +1422,10 @@ public function testModifyLimitQueryWithTopNSubQueryWithOrderBy() */ public function testQuotesTableNameInListTableColumnsSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableColumnsSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableColumnsSQL("Foo'Bar\\") + ); } /** @@ -1431,11 +1433,9 @@ public function testQuotesTableNameInListTableColumnsSQL() */ public function testQuotesSchemaNameInListTableColumnsSQL() { - self::assertContains( + self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", - $this->platform->getListTableColumnsSQL("Foo'Bar\\.baz_table"), - '', - true + $this->platform->getListTableColumnsSQL("Foo'Bar\\.baz_table") ); } @@ -1444,7 +1444,10 @@ public function testQuotesSchemaNameInListTableColumnsSQL() */ public function testQuotesTableNameInListTableForeignKeysSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableForeignKeysSQL("Foo'Bar\\") + ); } /** @@ -1452,11 +1455,9 @@ public function testQuotesTableNameInListTableForeignKeysSQL() */ public function testQuotesSchemaNameInListTableForeignKeysSQL() { - self::assertContains( + self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", - $this->platform->getListTableForeignKeysSQL("Foo'Bar\\.baz_table"), - '', - true + $this->platform->getListTableForeignKeysSQL("Foo'Bar\\.baz_table") ); } @@ -1465,7 +1466,10 @@ public function testQuotesSchemaNameInListTableForeignKeysSQL() */ public function testQuotesTableNameInListTableIndexesSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableIndexesSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableIndexesSQL("Foo'Bar\\") + ); } /** @@ -1473,11 +1477,9 @@ public function testQuotesTableNameInListTableIndexesSQL() */ public function testQuotesSchemaNameInListTableIndexesSQL() { - self::assertContains( + self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", - $this->platform->getListTableIndexesSQL("Foo'Bar\\.baz_table"), - '', - true + $this->platform->getListTableIndexesSQL("Foo'Bar\\.baz_table") ); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php index ce2b7df42a8..5969e9d0355 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php @@ -686,7 +686,10 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() */ public function testQuotesTableNameInListTableColumnsSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableColumnsSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableColumnsSQL("Foo'Bar\\") + ); } /** @@ -694,7 +697,10 @@ public function testQuotesTableNameInListTableColumnsSQL() */ public function testQuotesTableNameInListTableIndexesSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableIndexesSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableIndexesSQL("Foo'Bar\\") + ); } /** @@ -702,6 +708,9 @@ public function testQuotesTableNameInListTableIndexesSQL() */ public function testQuotesTableNameInListTableForeignKeysSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableForeignKeysSQL("Foo'Bar\\") + ); } } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php index e8f8f0cdd7f..439c413d1a0 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php @@ -97,11 +97,10 @@ public function getGenerateAlterTableSql() ]; } - /** - * @expectedException \Doctrine\DBAL\DBALException - */ public function testRLike() { + $this->expectException(DBALException::class); + self::assertEquals('RLIKE', $this->platform->getRegexpExpression(), 'Regular expression operator is not correct'); } @@ -131,11 +130,10 @@ public function testGeneratesTransactionsCommands() ); } - /** - * @expectedException \Doctrine\DBAL\DBALException - */ public function testCreateDatabaseThrowsException() { + $this->expectException(DBALException::class); + self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar')); } @@ -539,7 +537,7 @@ public function testReturnsIdentitySequenceName() public function testCreateSequenceWithCache($cacheSize, $expectedSql) { $sequence = new Sequence('foo', 1, 1, $cacheSize); - self::assertContains($expectedSql, $this->platform->getCreateSequenceSQL($sequence)); + self::assertStringContainsString($expectedSql, $this->platform->getCreateSequenceSQL($sequence)); } public function dataCreateSequenceWithCache() @@ -875,7 +873,10 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() */ public function testQuotesDatabaseNameInListSequencesSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListSequencesSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListSequencesSQL("Foo'Bar\\") + ); } /** @@ -883,7 +884,10 @@ public function testQuotesDatabaseNameInListSequencesSQL() */ public function testQuotesTableNameInListTableIndexesSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableIndexesSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableIndexesSQL("Foo'Bar\\") + ); } /** @@ -891,7 +895,10 @@ public function testQuotesTableNameInListTableIndexesSQL() */ public function testQuotesTableNameInListTableForeignKeysSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableForeignKeysSQL("Foo'Bar\\") + ); } /** @@ -899,7 +906,10 @@ public function testQuotesTableNameInListTableForeignKeysSQL() */ public function testQuotesTableNameInListTableConstraintsSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableConstraintsSQL("Foo'Bar\\") + ); } /** @@ -907,7 +917,10 @@ public function testQuotesTableNameInListTableConstraintsSQL() */ public function testQuotesTableNameInListTableColumnsSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableColumnsSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableColumnsSQL("Foo'Bar\\") + ); } /** @@ -915,6 +928,9 @@ public function testQuotesTableNameInListTableColumnsSQL() */ public function testQuotesDatabaseNameInListTableColumnsSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableColumnsSQL('foo_table', "Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableColumnsSQL('foo_table', "Foo'Bar\\") + ); } } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php b/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php index 22ab967fd7e..b0c49ae6bb9 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php @@ -12,7 +12,7 @@ class ReservedKeywordsValidatorTest extends DbalTestCase /** @var ReservedKeywordsValidator */ private $validator; - protected function setUp() + protected function setUp() : void { $this->validator = new ReservedKeywordsValidator([new MySQLKeywords()]); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php index 219119c2cc1..767fb268408 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php @@ -995,11 +995,9 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() */ public function testQuotesSchemaNameInListTableColumnsSQL() { - self::assertContains( + self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", - $this->platform->getListTableColumnsSQL("Foo'Bar\\.baz_table"), - '', - true + $this->platform->getListTableColumnsSQL("Foo'Bar\\.baz_table") ); } @@ -1008,7 +1006,7 @@ public function testQuotesSchemaNameInListTableColumnsSQL() */ public function testQuotesTableNameInListTableConstraintsSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase("'Foo''Bar\\'", $this->platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true); } /** @@ -1016,11 +1014,9 @@ public function testQuotesTableNameInListTableConstraintsSQL() */ public function testQuotesSchemaNameInListTableConstraintsSQL() { - self::assertContains( + self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", - $this->platform->getListTableConstraintsSQL("Foo'Bar\\.baz_table"), - '', - true + $this->platform->getListTableConstraintsSQL("Foo'Bar\\.baz_table") ); } @@ -1029,7 +1025,10 @@ public function testQuotesSchemaNameInListTableConstraintsSQL() */ public function testQuotesTableNameInListTableForeignKeysSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableForeignKeysSQL("Foo'Bar\\") + ); } /** @@ -1037,11 +1036,9 @@ public function testQuotesTableNameInListTableForeignKeysSQL() */ public function testQuotesSchemaNameInListTableForeignKeysSQL() { - self::assertContains( + self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", - $this->platform->getListTableForeignKeysSQL("Foo'Bar\\.baz_table"), - '', - true + $this->platform->getListTableForeignKeysSQL("Foo'Bar\\.baz_table") ); } @@ -1050,7 +1047,10 @@ public function testQuotesSchemaNameInListTableForeignKeysSQL() */ public function testQuotesTableNameInListTableIndexesSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableIndexesSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableIndexesSQL("Foo'Bar\\") + ); } /** @@ -1058,11 +1058,9 @@ public function testQuotesTableNameInListTableIndexesSQL() */ public function testQuotesSchemaNameInListTableIndexesSQL() { - self::assertContains( + self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", - $this->platform->getListTableIndexesSQL("Foo'Bar\\.baz_table"), - '', - true + $this->platform->getListTableIndexesSQL("Foo'Bar\\.baz_table") ); } } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php index e42aaeb8eaf..8aa6bc0cda3 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php @@ -14,7 +14,7 @@ class SQLAzurePlatformTest extends DbalTestCase /** @var SQLAzurePlatform */ private $platform; - protected function setUp() + protected function setUp() : void { $this->platform = new SQLAzurePlatform(); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php index f2e12ae7b22..26cc4d304eb 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php @@ -262,19 +262,17 @@ public function getGenerateUniqueIndexSql() return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; } - /** - * @expectedException \Doctrine\DBAL\DBALException - */ public function testGeneratesForeignKeyCreationSql() { + $this->expectException(DBALException::class); + parent::testGeneratesForeignKeyCreationSql(); } - /** - * @expectedException \Doctrine\DBAL\DBALException - */ public function testGeneratesConstraintCreationSql() { + $this->expectException(DBALException::class); + parent::testGeneratesConstraintCreationSql(); } @@ -727,7 +725,10 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() */ public function testQuotesTableNameInListTableConstraintsSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableConstraintsSQL("Foo'Bar\\") + ); } /** @@ -735,7 +736,10 @@ public function testQuotesTableNameInListTableConstraintsSQL() */ public function testQuotesTableNameInListTableColumnsSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableColumnsSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableColumnsSQL("Foo'Bar\\") + ); } /** @@ -743,7 +747,10 @@ public function testQuotesTableNameInListTableColumnsSQL() */ public function testQuotesTableNameInListTableIndexesSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableIndexesSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableIndexesSQL("Foo'Bar\\") + ); } /** @@ -751,7 +758,10 @@ public function testQuotesTableNameInListTableIndexesSQL() */ public function testQuotesTableNameInListTableForeignKeysSQL() { - self::assertContains("'Foo''Bar\\'", $this->platform->getListTableForeignKeysSQL("Foo'Bar\\"), '', true); + self::assertStringContainsStringIgnoringCase( + "'Foo''Bar\\'", + $this->platform->getListTableForeignKeysSQL("Foo'Bar\\") + ); } public function testDateAddStaticNumberOfDays() diff --git a/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php b/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php index b4d5168d497..74ace7cc042 100644 --- a/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php @@ -9,24 +9,25 @@ use Doctrine\DBAL\Portability\Statement; use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\Mocks\DriverStatementMock; -use PHPUnit_Framework_MockObject_MockObject; +use PHPUnit\Framework\MockObject\MockObject; +use ReflectionProperty; use function iterator_to_array; class StatementTest extends DbalTestCase { - /** @var Connection|PHPUnit_Framework_MockObject_MockObject */ + /** @var Connection|MockObject */ protected $conn; /** @var Statement */ protected $stmt; - /** @var DriverStatement|PHPUnit_Framework_MockObject_MockObject */ + /** @var DriverStatement|MockObject */ protected $wrappedStmt; /** * {@inheritdoc} */ - protected function setUp() + protected function setUp() : void { $this->wrappedStmt = $this->createWrappedStatement(); $this->conn = $this->createConnection(); @@ -133,9 +134,12 @@ public function testSetFetchMode() ->with($fetchMode, $arg1, $arg2) ->will($this->returnValue(true)); - self::assertAttributeSame(FetchMode::MIXED, 'defaultFetchMode', $this->stmt); + $re = new ReflectionProperty($this->stmt, 'defaultFetchMode'); + $re->setAccessible(true); + + self::assertSame(FetchMode::MIXED, $re->getValue($this->stmt)); self::assertTrue($this->stmt->setFetchMode($fetchMode, $arg1, $arg2)); - self::assertAttributeSame($fetchMode, 'defaultFetchMode', $this->stmt); + self::assertSame($fetchMode, $re->getValue($this->stmt)); } public function testGetIterator() @@ -159,7 +163,7 @@ public function testRowCount() } /** - * @return Connection|PHPUnit_Framework_MockObject_MockObject + * @return Connection|MockObject */ protected function createConnection() { @@ -177,7 +181,7 @@ protected function createStatement(DriverStatement $wrappedStatement, Connection } /** - * @return DriverStatement|PHPUnit_Framework_MockObject_MockObject + * @return DriverStatement|MockObject */ protected function createWrappedStatement() { diff --git a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php index efa173829c3..d419f8d5fd4 100644 --- a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php @@ -15,7 +15,7 @@ class ExpressionBuilderTest extends DbalTestCase /** @var ExpressionBuilder */ protected $expr; - protected function setUp() + protected function setUp() : void { $conn = $this->createMock(Connection::class); diff --git a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php index fdd28d87847..b6d4d090374 100644 --- a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php @@ -17,7 +17,7 @@ class QueryBuilderTest extends DbalTestCase /** @var Connection */ protected $conn; - protected function setUp() + protected function setUp() : void { $this->conn = $this->createMock(Connection::class); diff --git a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php index bdde3d4fbcb..b3f91149b32 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php @@ -8,8 +8,8 @@ use Doctrine\DBAL\Driver; use Doctrine\DBAL\Platforms\DB2Platform; use Doctrine\DBAL\Schema\DB2SchemaManager; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject; use function in_array; /** @@ -17,13 +17,13 @@ */ final class DB2SchemaManagerTest extends TestCase { - /** @var Connection|PHPUnit_Framework_MockObject_MockObject */ + /** @var Connection|MockObject */ private $conn; /** @var DB2SchemaManager */ private $manager; - protected function setUp() + protected function setUp() : void { $eventManager = new EventManager(); $driverMock = $this->createMock(Driver::class); @@ -87,7 +87,7 @@ public function testAssetFilteringSetsACallable() ); $callable = $this->conn->getConfiguration()->getSchemaAssetsFilter(); - $this->assertInternalType('callable', $callable); + self::assertIsCallable($callable); // BC check: Test that regexp expression is still preserved & accessible. $this->assertEquals($filterExpression, $this->conn->getConfiguration()->getFilterSchemaAssetsExpression()); diff --git a/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php index 737a8223812..4646700e0e7 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php @@ -21,7 +21,7 @@ class MySqlSchemaManagerTest extends TestCase /** @var Connection */ private $conn; - protected function setUp() + protected function setUp() : void { $eventManager = new EventManager(); $driverMock = $this->createMock(Driver::class); diff --git a/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php b/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php index 0d45a5ef5e5..568a4bfa79a 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php @@ -16,7 +16,7 @@ class MySQLSchemaTest extends TestCase /** @var AbstractPlatform */ private $platform; - protected function setUp() + protected function setUp() : void { $this->comparator = new Comparator(); $this->platform = new MySqlPlatform(); diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php index f7254c97cb7..5618feeefdb 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Schema\Visitor\AbstractVisitor; use Doctrine\DBAL\Schema\Visitor\Visitor; use PHPUnit\Framework\TestCase; +use ReflectionProperty; use function current; use function strlen; @@ -211,7 +212,11 @@ public function testDeepClone() $fk = $schemaNew->getTable('bar')->getForeignKeys(); $fk = current($fk); - self::assertSame($schemaNew->getTable('bar'), $this->readAttribute($fk, '_localTable')); + + $re = new ReflectionProperty($fk, '_localTable'); + $re->setAccessible(true); + + self::assertSame($schemaNew->getTable('bar'), $re->getValue($fk)); } /** @@ -279,13 +284,15 @@ public function testCreatesNamespace() /** * @group DBAL-669 - * @expectedException \Doctrine\DBAL\Schema\SchemaException */ public function testThrowsExceptionOnCreatingNamespaceTwice() { $schema = new Schema(); $schema->createNamespace('foo'); + + $this->expectException(SchemaException::class); + $schema->createNamespace('foo'); } diff --git a/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php b/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php index cedc3583137..80d43e0e1b4 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php @@ -19,7 +19,7 @@ class SingleDatabaseSynchronizerTest extends TestCase /** @var SingleDatabaseSynchronizer */ private $synchronizer; - protected function setUp() + protected function setUp() : void { $this->conn = DriverManager::getConnection([ 'driver' => 'pdo_sqlite', diff --git a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php index ac5fead5bcf..154a29ad7b0 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php @@ -783,7 +783,6 @@ public function testKeepsIndexOptionsOnRenamingUniqueIndex() /** * @group DBAL-234 - * @expectedException \Doctrine\DBAL\Schema\SchemaException */ public function testThrowsExceptionOnRenamingNonExistingIndex() { @@ -791,12 +790,13 @@ public function testThrowsExceptionOnRenamingNonExistingIndex() $table->addColumn('id', 'integer'); $table->addIndex(['id'], 'idx'); + $this->expectException(SchemaException::class); + $table->renameIndex('foo', 'bar'); } /** * @group DBAL-234 - * @expectedException \Doctrine\DBAL\Schema\SchemaException */ public function testThrowsExceptionOnRenamingToAlreadyExistingIndex() { @@ -806,6 +806,8 @@ public function testThrowsExceptionOnRenamingToAlreadyExistingIndex() $table->addIndex(['id'], 'idx_id'); $table->addIndex(['foo'], 'idx_foo'); + $this->expectException(SchemaException::class); + $table->renameIndex('idx_id', 'idx_foo'); } diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php index e64b4c523f3..790ba66db7b 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php @@ -7,12 +7,12 @@ use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Visitor\CreateSchemaSqlCollector; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject; class CreateSchemaSqlCollectorTest extends TestCase { - /** @var AbstractPlatform|PHPUnit_Framework_MockObject_MockObject */ + /** @var AbstractPlatform|MockObject */ private $platformMock; /** @var CreateSchemaSqlCollector */ @@ -21,7 +21,7 @@ class CreateSchemaSqlCollectorTest extends TestCase /** * {@inheritdoc} */ - protected function setUp() + protected function setUp() : void { parent::setUp(); @@ -130,7 +130,7 @@ public function testResetsQueries() } /** - * @return ForeignKeyConstraint|PHPUnit_Framework_MockObject_MockObject + * @return ForeignKeyConstraint|MockObject */ private function createForeignKeyConstraintMock() { @@ -140,7 +140,7 @@ private function createForeignKeyConstraintMock() } /** - * @return Sequence|PHPUnit_Framework_MockObject_MockObject + * @return Sequence|MockObject */ private function createSequenceMock() { @@ -150,7 +150,7 @@ private function createSequenceMock() } /** - * @return Table|PHPUnit_Framework_MockObject_MockObject + * @return Table|MockObject */ private function createTableMock() { diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php index 2e67d0a023f..5424c7bb676 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php @@ -17,7 +17,7 @@ abstract class AbstractTestCase extends TestCase /** @var SQLAzureShardManager */ protected $sm; - protected function setUp() + protected function setUp() : void { if (! isset($GLOBALS['db_type']) || strpos($GLOBALS['db_type'], 'sqlsrv') === false) { $this->markTestSkipped('No driver or sqlserver driver specified.'); diff --git a/tests/Doctrine/Tests/DBAL/StatementTest.php b/tests/Doctrine/Tests/DBAL/StatementTest.php index 7f18b20936a..f7ff02d2ac6 100644 --- a/tests/Doctrine/Tests/DBAL/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/StatementTest.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\DBAL\Logging\SQLLogger; @@ -25,7 +26,7 @@ class StatementTest extends DbalTestCase /** @var PDOStatement */ private $pdoStatement; - protected function setUp() + protected function setUp() : void { $this->pdoStatement = $this->getMockBuilder(PDOStatement::class) ->setMethods(['execute', 'bindParam', 'bindValue']) @@ -124,9 +125,6 @@ public function testExecuteCallsStartQueryWithTheParametersBoundViaBindParam() $statement->execute(); } - /** - * @expectedException \Doctrine\DBAL\DBALException - */ public function testExecuteCallsLoggerStopQueryOnException() { $logger = $this->createMock(SQLLogger::class); @@ -151,6 +149,9 @@ public function testExecuteCallsLoggerStopQueryOnException() ->will($this->throwException(new Exception('Mock test exception'))); $statement = new Statement('', $this->conn); + + $this->expectException(DBALException::class); + $statement->execute(); } } diff --git a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php index a85efd0a88c..eb06ddc350b 100644 --- a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php +++ b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php @@ -21,7 +21,7 @@ class RunSqlCommandTest extends TestCase /** @var Connection */ private $connectionMock; - protected function setUp() + protected function setUp() : void { $application = new Application(); $application->add(new RunSqlCommand()); @@ -48,7 +48,7 @@ public function testMissingSqlArgument() ]); $this->fail('Expected a runtime exception when omitting sql argument'); } catch (RuntimeException $e) { - self::assertContains("Argument 'SQL", $e->getMessage()); + self::assertStringContainsString("Argument 'SQL", $e->getMessage()); } } @@ -62,7 +62,7 @@ public function testIncorrectDepthOption() ]); $this->fail('Expected a logic exception when executing with a stringy depth'); } catch (LogicException $e) { - self::assertContains("Option 'depth'", $e->getMessage()); + self::assertStringContainsString("Option 'depth'", $e->getMessage()); } } diff --git a/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php b/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php index ecb4155f74f..66181f7e0c8 100644 --- a/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php @@ -17,7 +17,7 @@ class ArrayTest extends DbalTestCase /** @var Type */ private $type; - protected function setUp() + protected function setUp() : void { $this->platform = new MockPlatform(); $this->type = Type::getType('array'); @@ -25,18 +25,12 @@ protected function setUp() public function testArrayConvertsToDatabaseValue() { - self::assertInternalType( - 'string', - $this->type->convertToDatabaseValue([], $this->platform) - ); + self::assertIsString($this->type->convertToDatabaseValue([], $this->platform)); } public function testArrayConvertsToPHPValue() { - self::assertInternalType( - 'array', - $this->type->convertToPHPValue(serialize([]), $this->platform) - ); + self::assertIsArray($this->type->convertToPHPValue(serialize([]), $this->platform)); } public function testConversionFailure() diff --git a/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php b/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php index 8140cf6d109..2b447d95cfd 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php @@ -26,7 +26,7 @@ abstract class BaseDateTypeTestCase extends TestCase /** * {@inheritDoc} */ - protected function setUp() + protected function setUp() : void { $this->platform = new MockPlatform(); $this->currentTimezone = date_default_timezone_get(); @@ -37,14 +37,14 @@ protected function setUp() /** * {@inheritDoc} */ - protected function tearDown() + protected function tearDown() : void { date_default_timezone_set($this->currentTimezone); } public function testDateConvertsToDatabaseValue() { - self::assertInternalType('string', $this->type->convertToDatabaseValue(new DateTime(), $this->platform)); + self::assertIsString($this->type->convertToDatabaseValue(new DateTime(), $this->platform)); } /** @@ -94,10 +94,7 @@ public function testConvertDateTimeImmutableToPHPValue() */ public function testDateTimeImmutableConvertsToDatabaseValue() { - self::assertInternalType( - 'string', - $this->type->convertToDatabaseValue(new DateTimeImmutable(), $this->platform) - ); + self::assertIsString($this->type->convertToDatabaseValue(new DateTimeImmutable(), $this->platform)); } /** diff --git a/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php b/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php index fbcf5fb9357..e5bd3c201dc 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Types\BinaryType; +use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DBAL\Mocks\MockPlatform; use Doctrine\Tests\DbalTestCase; @@ -22,7 +23,7 @@ class BinaryTest extends DbalTestCase /** * {@inheritdoc} */ - protected function setUp() + protected function setUp() : void { $this->platform = new MockPlatform(); $this->type = Type::getType('binary'); @@ -53,7 +54,7 @@ public function testBinaryStringConvertsToPHPValue() $databaseValue = 'binary string'; $phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform); - self::assertInternalType('resource', $phpValue); + self::assertIsResource($phpValue); self::assertEquals($databaseValue, stream_get_contents($phpValue)); } @@ -67,10 +68,11 @@ public function testBinaryResourceConvertsToPHPValue() /** * @dataProvider getInvalidDatabaseValues - * @expectedException \Doctrine\DBAL\Types\ConversionException */ public function testThrowsConversionExceptionOnInvalidDatabaseValue($value) { + $this->expectException(ConversionException::class); + $this->type->convertToPHPValue($value, $this->platform); } diff --git a/tests/Doctrine/Tests/DBAL/Types/BlobTest.php b/tests/Doctrine/Tests/DBAL/Types/BlobTest.php index 5500836cfdb..57f26004140 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BlobTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/BlobTest.php @@ -22,7 +22,7 @@ class BlobTest extends DbalTestCase /** * {@inheritdoc} */ - protected function setUp() + protected function setUp() : void { $this->platform = new MockPlatform(); $this->type = Type::getType('blob'); @@ -38,7 +38,7 @@ public function testBinaryStringConvertsToPHPValue() $databaseValue = $this->getBinaryString(); $phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform); - self::assertInternalType('resource', $phpValue); + self::assertIsResource($phpValue); self::assertSame($databaseValue, stream_get_contents($phpValue)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php b/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php index a7e3377107a..ad9dcc673bf 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php @@ -14,7 +14,7 @@ class BooleanTest extends DbalTestCase /** @var Type */ private $type; - protected function setUp() + protected function setUp() : void { $this->platform = new MockPlatform(); $this->type = Type::getType('boolean'); @@ -22,12 +22,12 @@ protected function setUp() public function testBooleanConvertsToDatabaseValue() { - self::assertInternalType('integer', $this->type->convertToDatabaseValue(1, $this->platform)); + self::assertIsInt($this->type->convertToDatabaseValue(1, $this->platform)); } public function testBooleanConvertsToPHPValue() { - self::assertInternalType('bool', $this->type->convertToPHPValue(0, $this->platform)); + self::assertIsBool($this->type->convertToPHPValue(0, $this->platform)); } public function testBooleanNullConvertsToPHPValue() diff --git a/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php index 5fd15d812d3..38cf0a98a33 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php @@ -21,7 +21,7 @@ class DateImmutableTypeTest extends TestCase /** @var DateImmutableType */ private $type; - protected function setUp() + protected function setUp() : void { $this->type = Type::getType('date_immutable'); $this->platform = $this->prophesize(AbstractPlatform::class); diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTest.php index a8c7327b337..e7c76ba77ff 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTest.php @@ -12,7 +12,7 @@ class DateTest extends BaseDateTypeTestCase /** * {@inheritDoc} */ - protected function setUp() + protected function setUp() : void { $this->type = Type::getType('date'); diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php index dfedcca32b1..4c2ed8e104e 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php @@ -21,7 +21,7 @@ class DateTimeImmutableTypeTest extends TestCase /** @var DateTimeImmutableType */ private $type; - protected function setUp() + protected function setUp() : void { $this->type = Type::getType('datetime_immutable'); $this->platform = $this->prophesize(AbstractPlatform::class); diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php index 7d571f80eb2..615c14d584d 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php @@ -11,7 +11,7 @@ class DateTimeTest extends BaseDateTypeTestCase /** * {@inheritDoc} */ - protected function setUp() + protected function setUp() : void { $this->type = Type::getType('datetime'); diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php index df47f7b3991..aa602b629c2 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php @@ -21,7 +21,7 @@ class DateTimeTzImmutableTypeTest extends TestCase /** @var DateTimeTzImmutableType */ private $type; - protected function setUp() + protected function setUp() : void { $this->type = Type::getType('datetimetz_immutable'); $this->platform = $this->prophesize(AbstractPlatform::class); diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php index 4b6c8fb208f..419974c6b09 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php @@ -11,7 +11,7 @@ class DateTimeTzTest extends BaseDateTypeTestCase /** * {@inheritDoc} */ - protected function setUp() + protected function setUp() : void { $this->type = Type::getType('datetimetz'); diff --git a/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php b/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php index 3d1164afbfb..e702f7718ff 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php @@ -14,7 +14,7 @@ class DecimalTest extends DbalTestCase /** @var Type */ private $type; - protected function setUp() + protected function setUp() : void { $this->platform = new MockPlatform(); $this->type = Type::getType('decimal'); @@ -22,7 +22,7 @@ protected function setUp() public function testDecimalConvertsToPHPValue() { - self::assertInternalType('string', $this->type->convertToPHPValue('5.5', $this->platform)); + self::assertIsString($this->type->convertToPHPValue('5.5', $this->platform)); } public function testDecimalNullConvertsToPHPValue() diff --git a/tests/Doctrine/Tests/DBAL/Types/FloatTest.php b/tests/Doctrine/Tests/DBAL/Types/FloatTest.php index e68bf0bc46f..b3da2257c72 100644 --- a/tests/Doctrine/Tests/DBAL/Types/FloatTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/FloatTest.php @@ -14,7 +14,7 @@ class FloatTest extends DbalTestCase /** @var Type */ private $type; - protected function setUp() + protected function setUp() : void { $this->platform = new MockPlatform(); $this->type = Type::getType('float'); @@ -22,7 +22,7 @@ protected function setUp() public function testFloatConvertsToPHPValue() { - self::assertInternalType('float', $this->type->convertToPHPValue('5.5', $this->platform)); + self::assertIsFloat($this->type->convertToPHPValue('5.5', $this->platform)); } public function testFloatNullConvertsToPHPValue() @@ -32,7 +32,7 @@ public function testFloatNullConvertsToPHPValue() public function testFloatConvertToDatabaseValue() { - self::assertInternalType('float', $this->type->convertToDatabaseValue(5.5, $this->platform)); + self::assertIsFloat($this->type->convertToDatabaseValue(5.5, $this->platform)); } public function testFloatNullConvertToDatabaseValue() diff --git a/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php index 978cfd50fb7..b35670405d4 100644 --- a/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php @@ -15,7 +15,7 @@ class GuidTypeTest extends DbalTestCase /** @var Type */ private $type; - protected function setUp() + protected function setUp() : void { $this->platform = new MockPlatform(); $this->type = Type::getType('guid'); @@ -23,8 +23,8 @@ protected function setUp() public function testConvertToPHPValue() { - self::assertInternalType('string', $this->type->convertToPHPValue('foo', $this->platform)); - self::assertInternalType('string', $this->type->convertToPHPValue('', $this->platform)); + self::assertIsString($this->type->convertToPHPValue('foo', $this->platform)); + self::assertIsString($this->type->convertToPHPValue('', $this->platform)); } public function testNullConversion() diff --git a/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php b/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php index 848ff05dfc8..11e0f91c5fe 100644 --- a/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php @@ -14,7 +14,7 @@ class IntegerTest extends DbalTestCase /** @var Type */ private $type; - protected function setUp() + protected function setUp() : void { $this->platform = new MockPlatform(); $this->type = Type::getType('integer'); @@ -22,8 +22,8 @@ protected function setUp() public function testIntegerConvertsToPHPValue() { - self::assertInternalType('integer', $this->type->convertToPHPValue('1', $this->platform)); - self::assertInternalType('integer', $this->type->convertToPHPValue('0', $this->platform)); + self::assertIsInt($this->type->convertToPHPValue('1', $this->platform)); + self::assertIsInt($this->type->convertToPHPValue('0', $this->platform)); } public function testIntegerNullConvertsToPHPValue() diff --git a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php index 564371a30b3..8bc0ed1d8f8 100644 --- a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php @@ -22,7 +22,7 @@ class JsonArrayTest extends DbalTestCase /** * {@inheritdoc} */ - protected function setUp() + protected function setUp() : void { $this->platform = new MockPlatform(); $this->type = Type::getType('json_array'); diff --git a/tests/Doctrine/Tests/DBAL/Types/JsonTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php index 4f204a8baec..e36c84a33d4 100644 --- a/tests/Doctrine/Tests/DBAL/Types/JsonTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php @@ -23,7 +23,7 @@ class JsonTest extends DbalTestCase /** * {@inheritdoc} */ - protected function setUp() + protected function setUp() : void { $this->platform = new MockPlatform(); $this->type = Type::getType('json'); diff --git a/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php b/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php index 858004b73f4..0176f35a295 100644 --- a/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php @@ -17,7 +17,7 @@ class ObjectTest extends DbalTestCase /** @var Type */ private $type; - protected function setUp() + protected function setUp() : void { $this->platform = new MockPlatform(); $this->type = Type::getType('object'); @@ -25,12 +25,12 @@ protected function setUp() public function testObjectConvertsToDatabaseValue() { - self::assertInternalType('string', $this->type->convertToDatabaseValue(new stdClass(), $this->platform)); + self::assertIsString($this->type->convertToDatabaseValue(new stdClass(), $this->platform)); } public function testObjectConvertsToPHPValue() { - self::assertInternalType('object', $this->type->convertToPHPValue(serialize(new stdClass()), $this->platform)); + self::assertIsObject($this->type->convertToPHPValue(serialize(new stdClass()), $this->platform)); } public function testConversionFailure() diff --git a/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php b/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php index 4a453421b36..d7c98caad4a 100644 --- a/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php @@ -14,7 +14,7 @@ class SmallIntTest extends DbalTestCase /** @var Type */ private $type; - protected function setUp() + protected function setUp() : void { $this->platform = new MockPlatform(); $this->type = Type::getType('smallint'); @@ -22,8 +22,8 @@ protected function setUp() public function testSmallIntConvertsToPHPValue() { - self::assertInternalType('integer', $this->type->convertToPHPValue('1', $this->platform)); - self::assertInternalType('integer', $this->type->convertToPHPValue('0', $this->platform)); + self::assertIsInt($this->type->convertToPHPValue('1', $this->platform)); + self::assertIsInt($this->type->convertToPHPValue('0', $this->platform)); } public function testSmallIntNullConvertsToPHPValue() diff --git a/tests/Doctrine/Tests/DBAL/Types/StringTest.php b/tests/Doctrine/Tests/DBAL/Types/StringTest.php index 74716e4f23c..651058811f2 100644 --- a/tests/Doctrine/Tests/DBAL/Types/StringTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/StringTest.php @@ -14,7 +14,7 @@ class StringTest extends DbalTestCase /** @var Type */ private $type; - protected function setUp() + protected function setUp() : void { $this->platform = new MockPlatform(); $this->type = Type::getType('string'); @@ -32,8 +32,8 @@ public function testReturnsDefaultLengthFromPlatformVarchar() public function testConvertToPHPValue() { - self::assertInternalType('string', $this->type->convertToPHPValue('foo', $this->platform)); - self::assertInternalType('string', $this->type->convertToPHPValue('', $this->platform)); + self::assertIsString($this->type->convertToPHPValue('foo', $this->platform)); + self::assertIsString($this->type->convertToPHPValue('', $this->platform)); } public function testNullConversion() diff --git a/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php index 0f7427df3ed..a374cf1015f 100644 --- a/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php @@ -21,7 +21,7 @@ class TimeImmutableTypeTest extends TestCase /** @var TimeImmutableType */ private $type; - protected function setUp() + protected function setUp() : void { $this->type = Type::getType('time_immutable'); $this->platform = $this->prophesize(AbstractPlatform::class); diff --git a/tests/Doctrine/Tests/DBAL/Types/TimeTest.php b/tests/Doctrine/Tests/DBAL/Types/TimeTest.php index c2cd766b1c3..1b254730092 100644 --- a/tests/Doctrine/Tests/DBAL/Types/TimeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/TimeTest.php @@ -10,7 +10,7 @@ class TimeTest extends BaseDateTypeTestCase /** * {@inheritDoc} */ - protected function setUp() + protected function setUp() : void { $this->type = Type::getType('time'); diff --git a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php index 870bb23cc98..b948f22af77 100644 --- a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php @@ -20,7 +20,7 @@ class VarDateTimeImmutableTypeTest extends TestCase /** @var VarDateTimeImmutableType */ private $type; - protected function setUp() + protected function setUp() : void { if (! Type::hasType('vardatetime_immutable')) { Type::addType('vardatetime_immutable', VarDateTimeImmutableType::class); diff --git a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php index 2322aa474fe..516f42836b4 100644 --- a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php @@ -17,7 +17,7 @@ class VarDateTimeTest extends DbalTestCase /** @var Type */ private $type; - protected function setUp() + protected function setUp() : void { $this->platform = new MockPlatform(); if (! Type::hasType('vardatetime')) { diff --git a/tests/Doctrine/Tests/DbalFunctionalTestCase.php b/tests/Doctrine/Tests/DbalFunctionalTestCase.php index 77cfd8d6900..149db8bf998 100644 --- a/tests/Doctrine/Tests/DbalFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DbalFunctionalTestCase.php @@ -43,7 +43,7 @@ protected function resetSharedConn() self::$sharedConnection = null; } - protected function setUp() + protected function setUp() : void { if (! isset(self::$sharedConnection)) { self::$sharedConnection = TestUtil::getConnection(); @@ -54,14 +54,14 @@ protected function setUp() $this->connection->getConfiguration()->setSQLLogger($this->sqlLoggerStack); } - protected function tearDown() + protected function tearDown() : void { while ($this->connection->isTransactionActive()) { $this->connection->rollBack(); } } - protected function onNotSuccessfulTest(Throwable $t) + protected function onNotSuccessfulTest(Throwable $t) : void { if ($t instanceof AssertionFailedError) { throw $t; diff --git a/tests/Doctrine/Tests/DbalPerformanceTestCase.php b/tests/Doctrine/Tests/DbalPerformanceTestCase.php index bfc60201bef..0001431454a 100644 --- a/tests/Doctrine/Tests/DbalPerformanceTestCase.php +++ b/tests/Doctrine/Tests/DbalPerformanceTestCase.php @@ -30,7 +30,7 @@ class DbalPerformanceTestCase extends DbalFunctionalTestCase /** * {@inheritdoc} */ - protected function assertPostConditions() + protected function assertPostConditions() : void { // If a perf test doesn't start or stop, it fails. self::assertNotNull($this->startTime, 'Test timing was started');