From 6ef95b639635434a877e0e4d89299e60bb479da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Wed, 14 Oct 2020 19:57:29 +0200 Subject: [PATCH] Minot CS improvement - use ::class for TestCase::expectException input --- .../DBAL/Platforms/AbstractPlatformTestCase.php | 3 ++- .../DBAL/Platforms/SQLAnywhere16PlatformTest.php | 3 ++- .../DBAL/Sharding/PoolingShardConnectionTest.php | 15 ++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php index aa51cd1e836..9ef99d6d416 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php @@ -17,6 +17,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\Types\CommentedType; +use InvalidArgumentException; use function get_class; use function implode; @@ -84,7 +85,7 @@ public static function getReturnsForeignKeyReferentialActionSQL(): iterable public function testGetInvalidForeignKeyReferentialActionSQL(): void { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->platform->getForeignKeyReferentialActionSQL('unknown'); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php index e0c4a24a21a..85ae95c4cc8 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\SQLAnywhere16Platform; use Doctrine\DBAL\Schema\Index; +use UnexpectedValueException; class SQLAnywhere16PlatformTest extends SQLAnywhere12PlatformTest { @@ -64,7 +65,7 @@ public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL(): void public function testThrowsExceptionOnInvalidWithNullsNotDistinctIndexOptions(): void { - $this->expectException('UnexpectedValueException'); + $this->expectException(UnexpectedValueException::class); $this->platform->getCreateIndexSQL( new Index( diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php index 1f0abe675f8..f1244541a50 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Sharding\PoolingShardConnection; use Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser; use Doctrine\DBAL\Sharding\ShardingException; +use InvalidArgumentException; use PHPUnit\Framework\TestCase; use stdClass; @@ -50,7 +51,7 @@ public function testConnect(): void public function testNoGlobalServerException(): void { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Connection Parameters require 'global' and 'shards' configurations."); DriverManager::getConnection([ @@ -66,7 +67,7 @@ public function testNoGlobalServerException(): void public function testNoShardsServersException(): void { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Connection Parameters require 'global' and 'shards' configurations."); DriverManager::getConnection([ @@ -79,7 +80,7 @@ public function testNoShardsServersException(): void public function testNoShardsChoserException(): void { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Missing Shard Choser configuration 'shardChoser'"); DriverManager::getConnection([ @@ -95,7 +96,7 @@ public function testNoShardsChoserException(): void public function testShardChoserWrongInstance(): void { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage( "The 'shardChoser' configuration is not a valid instance of Doctrine\DBAL\Sharding\ShardChoser\ShardChoser" ); @@ -114,7 +115,7 @@ public function testShardChoserWrongInstance(): void public function testShardNonNumericId(): void { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Shard Id has to be a non-negative number.'); DriverManager::getConnection([ @@ -130,7 +131,7 @@ public function testShardNonNumericId(): void public function testShardMissingId(): void { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage("Missing 'id' for one configured shard. Please specify a unique shard-id."); DriverManager::getConnection([ @@ -146,7 +147,7 @@ public function testShardMissingId(): void public function testDuplicateShardId(): void { - $this->expectException('InvalidArgumentException'); + $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Shard 1 is duplicated in the configuration.'); DriverManager::getConnection([