From 1d2a3035183f8b09cf6c2a98d730c0dd24eff1e3 Mon Sep 17 00:00:00 2001 From: Tom H Anderson Date: Mon, 28 Oct 2024 17:36:56 -0600 Subject: [PATCH] Upgraded to phpunit 11.4 --- composer.json | 2 +- tests/Assets/Extensions/ExtensionMock.php | 2 +- tests/Assets/MyDoctrineExtender.php | 2 +- .../Cache/ApcCacheProviderTest.php | 2 +- .../Cache/ArrayCacheProviderTest.php | 2 +- ...acheProviderTest.php => CacheProvider.php} | 2 +- .../Cache/FileCacheProviderTest.php | 2 +- .../Cache/MemcachedCacheProviderTest.php | 2 +- .../Cache/PhpFileCacheProviderTest.php | 2 +- .../Cache/RedisCacheProviderTest.php | 2 +- .../PrimaryReadReplicaConnectionTest.php | 80 +++++++++---------- tests/Feature/EntityManagerFactoryTest.php | 16 ++-- 12 files changed, 58 insertions(+), 58 deletions(-) rename tests/Feature/Configuration/Cache/{CacheProviderTest.php => CacheProvider.php} (91%) diff --git a/composer.json b/composer.json index e8df54b5..e4cbf369 100644 --- a/composer.json +++ b/composer.json @@ -44,7 +44,7 @@ "php-parallel-lint/php-parallel-lint": "^1.4", "phpstan/phpstan": "^1.9", "phpstan/phpstan-deprecation-rules": "^1.1", - "phpunit/phpunit": "^9.3", + "phpunit/phpunit": "^11.4", "fakerphp/faker": "^1.23", "laravel/framework": "^10.0 || ^11.0" }, diff --git a/tests/Assets/Extensions/ExtensionMock.php b/tests/Assets/Extensions/ExtensionMock.php index c84350de..358fdd85 100644 --- a/tests/Assets/Extensions/ExtensionMock.php +++ b/tests/Assets/Extensions/ExtensionMock.php @@ -14,7 +14,7 @@ class ExtensionMock implements Extension public function addSubscribers(EventManager $manager, EntityManagerInterface $em): void { // Confirm it gets called - (new ExtensionManagerTest())->assertTrue(true); + (new ExtensionManagerTest('test'))->assertTrue(true); } /** @return mixed[] */ diff --git a/tests/Assets/MyDoctrineExtender.php b/tests/Assets/MyDoctrineExtender.php index 5da39a47..1833d9ba 100644 --- a/tests/Assets/MyDoctrineExtender.php +++ b/tests/Assets/MyDoctrineExtender.php @@ -14,6 +14,6 @@ class MyDoctrineExtender implements DoctrineExtender { public function extend(Configuration $configuration, Connection $connection, EventManager $eventManager): void { - (new DoctrineManagerTest())->assertExtendedCorrectly($configuration, $connection, $eventManager); + (new DoctrineManagerTest('test'))->assertExtendedCorrectly($configuration, $connection, $eventManager); } } diff --git a/tests/Feature/Configuration/Cache/ApcCacheProviderTest.php b/tests/Feature/Configuration/Cache/ApcCacheProviderTest.php index f093f740..58273b72 100644 --- a/tests/Feature/Configuration/Cache/ApcCacheProviderTest.php +++ b/tests/Feature/Configuration/Cache/ApcCacheProviderTest.php @@ -10,7 +10,7 @@ use Mockery as m; use Psr\Cache\CacheItemPoolInterface; -class ApcCacheProviderTest extends CacheProviderTest +class ApcCacheProviderTest extends CacheProvider { public function getProvider(): mixed { diff --git a/tests/Feature/Configuration/Cache/ArrayCacheProviderTest.php b/tests/Feature/Configuration/Cache/ArrayCacheProviderTest.php index 2b15cfcd..51a8f364 100644 --- a/tests/Feature/Configuration/Cache/ArrayCacheProviderTest.php +++ b/tests/Feature/Configuration/Cache/ArrayCacheProviderTest.php @@ -7,7 +7,7 @@ use LaravelDoctrine\ORM\Configuration\Cache\ArrayCacheProvider; use Symfony\Component\Cache\Adapter\ArrayAdapter; -class ArrayCacheProviderTest extends CacheProviderTest +class ArrayCacheProviderTest extends CacheProvider { public function getProvider(): mixed { diff --git a/tests/Feature/Configuration/Cache/CacheProviderTest.php b/tests/Feature/Configuration/Cache/CacheProvider.php similarity index 91% rename from tests/Feature/Configuration/Cache/CacheProviderTest.php rename to tests/Feature/Configuration/Cache/CacheProvider.php index d3763c14..98d7e841 100644 --- a/tests/Feature/Configuration/Cache/CacheProviderTest.php +++ b/tests/Feature/Configuration/Cache/CacheProvider.php @@ -7,7 +7,7 @@ use LaravelDoctrineTest\ORM\TestCase; use Mockery; -abstract class CacheProviderTest extends TestCase +abstract class CacheProvider extends TestCase { abstract public function getProvider(): mixed; diff --git a/tests/Feature/Configuration/Cache/FileCacheProviderTest.php b/tests/Feature/Configuration/Cache/FileCacheProviderTest.php index 9bc16e20..248a9706 100644 --- a/tests/Feature/Configuration/Cache/FileCacheProviderTest.php +++ b/tests/Feature/Configuration/Cache/FileCacheProviderTest.php @@ -9,7 +9,7 @@ use Mockery as m; use Symfony\Component\Cache\Adapter\FilesystemAdapter; -class FileCacheProviderTest extends CacheProviderTest +class FileCacheProviderTest extends CacheProvider { public function getProvider(): mixed { diff --git a/tests/Feature/Configuration/Cache/MemcachedCacheProviderTest.php b/tests/Feature/Configuration/Cache/MemcachedCacheProviderTest.php index c130b09e..7ef640a0 100644 --- a/tests/Feature/Configuration/Cache/MemcachedCacheProviderTest.php +++ b/tests/Feature/Configuration/Cache/MemcachedCacheProviderTest.php @@ -10,7 +10,7 @@ use Mockery as m; use Psr\Cache\CacheItemPoolInterface; -class MemcachedCacheProviderTest extends CacheProviderTest +class MemcachedCacheProviderTest extends CacheProvider { public function getProvider(): mixed { diff --git a/tests/Feature/Configuration/Cache/PhpFileCacheProviderTest.php b/tests/Feature/Configuration/Cache/PhpFileCacheProviderTest.php index 7fbce6c3..ba0a0a65 100644 --- a/tests/Feature/Configuration/Cache/PhpFileCacheProviderTest.php +++ b/tests/Feature/Configuration/Cache/PhpFileCacheProviderTest.php @@ -9,7 +9,7 @@ use Mockery as m; use Symfony\Component\Cache\Adapter\PhpFilesAdapter; -class PhpFileCacheProviderTest extends CacheProviderTest +class PhpFileCacheProviderTest extends CacheProvider { public function getProvider(): mixed { diff --git a/tests/Feature/Configuration/Cache/RedisCacheProviderTest.php b/tests/Feature/Configuration/Cache/RedisCacheProviderTest.php index a2a8fa03..fed819f0 100644 --- a/tests/Feature/Configuration/Cache/RedisCacheProviderTest.php +++ b/tests/Feature/Configuration/Cache/RedisCacheProviderTest.php @@ -10,7 +10,7 @@ use Mockery as m; use Psr\Cache\CacheItemPoolInterface; -class RedisCacheProviderTest extends CacheProviderTest +class RedisCacheProviderTest extends CacheProvider { public function getProvider(): mixed { diff --git a/tests/Feature/Configuration/Connections/PrimaryReadReplicaConnectionTest.php b/tests/Feature/Configuration/Connections/PrimaryReadReplicaConnectionTest.php index 074f42c8..2d69dd17 100644 --- a/tests/Feature/Configuration/Connections/PrimaryReadReplicaConnectionTest.php +++ b/tests/Feature/Configuration/Connections/PrimaryReadReplicaConnectionTest.php @@ -31,57 +31,57 @@ protected function setUp(): void * * @return mixed[] */ - public function getPrimaryReplicaConnectionData(): array + public static function getPrimaryReplicaConnectionData(): array { $out = []; // Case #0. Simple valid configuration with mysql base settings. $out[] = [ - $this->getResolvedMysqlConfig(), - $this->getInputConfigwithArrayOfReplicasInReadKey(), - $this->getExpectedConfig(), + self::getResolvedMysqlConfig(), + self::getInputConfigwithArrayOfReplicasInReadKey(), + self::getExpectedConfig(), ]; // Case #1. Configuration is only set in the read/write nodes. $out[] = [ ['driver' => 'pdo_mysql'], - $this->getNodesInputConfig(), - $this->getNodesExpectedConfig(), + self::getNodesInputConfig(), + self::getNodesExpectedConfig(), ]; // Case #2. Simple valid configuration with oracle base settings. $out[] = [ - $this->getResolvedOracleConfig(), - $this->getInputConfigwithArrayOfReplicasInReadKey(), - $this->getOracleExpectedConfig(), + self::getResolvedOracleConfig(), + self::getInputConfigwithArrayOfReplicasInReadKey(), + self::getOracleExpectedConfig(), ]; // Case #3. Simple valid configuration with pgqsql base settings. $out[] = [ - $this->getResolvedPgqsqlConfig(), - $this->getInputConfigwithArrayOfReplicasInReadKey(), - $this->getPgsqlExpectedConfig(), + self::getResolvedPgqsqlConfig(), + self::getInputConfigwithArrayOfReplicasInReadKey(), + self::getPgsqlExpectedConfig(), ]; // Case #4. Simple valid configuration with sqlite base settings. $out[] = [ - $this->getResolvedSqliteConfig(), - $this->getSqliteInputConfig(), - $this->getSqliteExpectedConfig(), + self::getResolvedSqliteConfig(), + self::getSqliteInputConfig(), + self::getSqliteExpectedConfig(), ]; // Case #5. Valid configuration as with 1 replica 'read' entry and plain-text host $out[] = [ - $this->getResolvedMysqlConfig(), - $this->getInputConfigWithPlainTextHostValue(), - $this->getExpectedConfigForCase5(), + self::getResolvedMysqlConfig(), + self::getInputConfigWithPlainTextHostValue(), + self::getExpectedConfigForCase5(), ]; // Case #6. Valid configuration as with 1 replica config 'read' entry and array of hosts in 'host' key $out[] = [ - $this->getResolvedMysqlConfig(), - $this->getInputConfigWithArrayAsHostValue(), - $this->getExpectedConfigForCase6(), + self::getResolvedMysqlConfig(), + self::getInputConfigWithArrayAsHostValue(), + self::getExpectedConfigForCase6(), ]; return $out; @@ -109,7 +109,7 @@ public function testPrimaryReplicaConnection(array $resolvedBaseSettings, array * * @return mixed[] */ - private function getInputConfigwithArrayOfReplicasInReadKey(): array + private static function getInputConfigwithArrayOfReplicasInReadKey(): array { return [ 'driver' => 'mysql', @@ -147,7 +147,7 @@ private function getInputConfigwithArrayOfReplicasInReadKey(): array } /** @return mixed[] */ - private function getInputConfigWithPlainTextHostValue(): array + private static function getInputConfigWithPlainTextHostValue(): array { return [ 'driver' => 'mysql', @@ -180,7 +180,7 @@ private function getInputConfigWithPlainTextHostValue(): array } /** @return mixed[] */ - private function getInputConfigWithArrayAsHostValue(): array + private static function getInputConfigWithArrayAsHostValue(): array { return [ 'driver' => 'mysql', @@ -217,7 +217,7 @@ private function getInputConfigWithArrayAsHostValue(): array * * @return mixed[] */ - private function getExpectedConfig(): array + private static function getExpectedConfig(): array { return [ 'wrapperClass' => PrimaryReadReplicaDoctrineWrapper::class, @@ -267,7 +267,7 @@ private function getExpectedConfig(): array * * @return mixed[] */ - private function getExpectedConfigForCase5(): array + private static function getExpectedConfigForCase5(): array { return [ 'wrapperClass' => PrimaryReadReplicaDoctrineWrapper::class, @@ -307,7 +307,7 @@ private function getExpectedConfigForCase5(): array * * @return mixed[] */ - private function getExpectedConfigForCase6(): array + private static function getExpectedConfigForCase6(): array { return [ 'wrapperClass' => PrimaryReadReplicaDoctrineWrapper::class, @@ -357,7 +357,7 @@ private function getExpectedConfigForCase6(): array * * @return mixed[] */ - private function getNodesInputConfig(): array + private static function getNodesInputConfig(): array { return [ 'write' => [ @@ -391,7 +391,7 @@ private function getNodesInputConfig(): array * * @return mixed[] */ - private function getNodesExpectedConfig(): array + private static function getNodesExpectedConfig(): array { return [ 'wrapperClass' => PrimaryReadReplicaDoctrineWrapper::class, @@ -427,9 +427,9 @@ private function getNodesExpectedConfig(): array * * @return mixed[] */ - private function getOracleExpectedConfig(): array + private static function getOracleExpectedConfig(): array { - $expectedConfigOracle = $this->getNodesExpectedConfig(); + $expectedConfigOracle = self::getNodesExpectedConfig(); $expectedConfigOracle['driver'] = 'oci8'; $expectedConfigOracle['primary']['user'] = 'homestead1'; $expectedConfigOracle['serverVersion'] = '5.8'; @@ -447,9 +447,9 @@ private function getOracleExpectedConfig(): array * * @return mixed[] */ - private function getPgsqlExpectedConfig(): array + private static function getPgsqlExpectedConfig(): array { - $expectedConfigPgsql = $this->getNodesExpectedConfig(); + $expectedConfigPgsql = self::getNodesExpectedConfig(); $expectedConfigPgsql['driver'] = 'pgsql'; $expectedConfigPgsql['primary']['user'] = 'homestead1'; $expectedConfigPgsql['primary']['sslmode'] = 'sslmode'; @@ -470,7 +470,7 @@ private function getPgsqlExpectedConfig(): array * * @return mixed[] */ - private function getSqliteExpectedConfig(): array + private static function getSqliteExpectedConfig(): array { return [ 'wrapperClass' => PrimaryReadReplicaDoctrineWrapper::class, @@ -512,9 +512,9 @@ private function getSqliteExpectedConfig(): array * * @return mixed[] */ - private function getSqliteInputConfig(): array + private static function getSqliteInputConfig(): array { - $inputConfigSqlite = $this->getInputConfigwithArrayOfReplicasInReadKey(); + $inputConfigSqlite = self::getInputConfigwithArrayOfReplicasInReadKey(); unset($inputConfigSqlite['read'][0]['database']); unset($inputConfigSqlite['read'][1]['database']); unset($inputConfigSqlite['write']['database']); @@ -527,7 +527,7 @@ private function getSqliteInputConfig(): array * * @return mixed[] */ - private function getResolvedMysqlConfig(): array + private static function getResolvedMysqlConfig(): array { return [ 'driver' => 'pdo_mysql', @@ -547,7 +547,7 @@ private function getResolvedMysqlConfig(): array * * @return mixed[] */ - private function getResolvedOracleConfig(): array + private static function getResolvedOracleConfig(): array { return [ 'driver' => 'oci8', @@ -564,7 +564,7 @@ private function getResolvedOracleConfig(): array * * @return mixed[] */ - private function getResolvedSqliteConfig(): array + private static function getResolvedSqliteConfig(): array { return [ 'driver' => 'pdo_sqlite', @@ -580,7 +580,7 @@ private function getResolvedSqliteConfig(): array * * @return mixed[] */ - private function getResolvedPgqsqlConfig(): array + private static function getResolvedPgqsqlConfig(): array { return [ 'driver' => 'pgsql', diff --git a/tests/Feature/EntityManagerFactoryTest.php b/tests/Feature/EntityManagerFactoryTest.php index b26ec66d..bd2d65e5 100644 --- a/tests/Feature/EntityManagerFactoryTest.php +++ b/tests/Feature/EntityManagerFactoryTest.php @@ -1008,15 +1008,15 @@ protected function enableLaravelNamingStrategy(): void * * @return mixed[] */ - public function getTestPrimaryReadReplicaConnectionData(): array + public static function getTestPrimaryReadReplicaConnectionData(): array { $out = []; // Case #0. Simple valid configuration, everything should go well. - $out[] = [$this->getDummyBaseInputConfig()]; + $out[] = [self::getDummyBaseInputConfig()]; //Case #1. No read DBs set. - $inputConfig = $this->getDummyBaseInputConfig(); + $inputConfig = self::getDummyBaseInputConfig(); unset($inputConfig['read']); $out[] = [ @@ -1026,7 +1026,7 @@ public function getTestPrimaryReadReplicaConnectionData(): array ]; //Case #2. 'read' isn't an array - $inputConfig = $this->getDummyBaseInputConfig(); + $inputConfig = self::getDummyBaseInputConfig(); $inputConfig['read'] = 'test'; $out[] = [ @@ -1036,7 +1036,7 @@ public function getTestPrimaryReadReplicaConnectionData(): array ]; //Case #3. 'read' has non array entries. - $inputConfig = $this->getDummyBaseInputConfig(); + $inputConfig = self::getDummyBaseInputConfig(); $inputConfig['read'][] = 'test'; $out[] = [ @@ -1046,7 +1046,7 @@ public function getTestPrimaryReadReplicaConnectionData(): array ]; //Case #4. 'read' has empty entries. - $inputConfig = $this->getDummyBaseInputConfig(); + $inputConfig = self::getDummyBaseInputConfig(); $inputConfig['read'][] = []; $out[] = [ @@ -1056,7 +1056,7 @@ public function getTestPrimaryReadReplicaConnectionData(): array ]; //Case #5. 'read' has empty first entry. (reported by maxbrokman.) - $inputConfig = $this->getDummyBaseInputConfig(); + $inputConfig = self::getDummyBaseInputConfig(); $inputConfig['read'][0] = []; $out[] = [ @@ -1134,7 +1134,7 @@ protected function tearDown(): void * * @return mixed[] */ - private function getDummyBaseInputConfig(): array + private static function getDummyBaseInputConfig(): array { return [ 'driver' => 'mysql',