Skip to content

Commit

Permalink
Upgraded to phpunit 11.4
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHAnderson committed Oct 28, 2024
1 parent dab04b8 commit 1d2a303
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/Assets/Extensions/ExtensionMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[] */
Expand Down
2 changes: 1 addition & 1 deletion tests/Assets/MyDoctrineExtender.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion tests/Feature/Configuration/Cache/ApcCacheProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Mockery as m;
use Psr\Cache\CacheItemPoolInterface;

class ApcCacheProviderTest extends CacheProviderTest
class ApcCacheProviderTest extends CacheProvider
{
public function getProvider(): mixed
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Mockery as m;
use Psr\Cache\CacheItemPoolInterface;

class MemcachedCacheProviderTest extends CacheProviderTest
class MemcachedCacheProviderTest extends CacheProvider
{
public function getProvider(): mixed
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Mockery as m;
use Psr\Cache\CacheItemPoolInterface;

class RedisCacheProviderTest extends CacheProviderTest
class RedisCacheProviderTest extends CacheProvider
{
public function getProvider(): mixed
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -109,7 +109,7 @@ public function testPrimaryReplicaConnection(array $resolvedBaseSettings, array
*
* @return mixed[]
*/
private function getInputConfigwithArrayOfReplicasInReadKey(): array
private static function getInputConfigwithArrayOfReplicasInReadKey(): array
{
return [
'driver' => 'mysql',
Expand Down Expand Up @@ -147,7 +147,7 @@ private function getInputConfigwithArrayOfReplicasInReadKey(): array
}

/** @return mixed[] */
private function getInputConfigWithPlainTextHostValue(): array
private static function getInputConfigWithPlainTextHostValue(): array
{
return [
'driver' => 'mysql',
Expand Down Expand Up @@ -180,7 +180,7 @@ private function getInputConfigWithPlainTextHostValue(): array
}

/** @return mixed[] */
private function getInputConfigWithArrayAsHostValue(): array
private static function getInputConfigWithArrayAsHostValue(): array
{
return [
'driver' => 'mysql',
Expand Down Expand Up @@ -217,7 +217,7 @@ private function getInputConfigWithArrayAsHostValue(): array
*
* @return mixed[]
*/
private function getExpectedConfig(): array
private static function getExpectedConfig(): array
{
return [
'wrapperClass' => PrimaryReadReplicaDoctrineWrapper::class,
Expand Down Expand Up @@ -267,7 +267,7 @@ private function getExpectedConfig(): array
*
* @return mixed[]
*/
private function getExpectedConfigForCase5(): array
private static function getExpectedConfigForCase5(): array
{
return [
'wrapperClass' => PrimaryReadReplicaDoctrineWrapper::class,
Expand Down Expand Up @@ -307,7 +307,7 @@ private function getExpectedConfigForCase5(): array
*
* @return mixed[]
*/
private function getExpectedConfigForCase6(): array
private static function getExpectedConfigForCase6(): array
{
return [
'wrapperClass' => PrimaryReadReplicaDoctrineWrapper::class,
Expand Down Expand Up @@ -357,7 +357,7 @@ private function getExpectedConfigForCase6(): array
*
* @return mixed[]
*/
private function getNodesInputConfig(): array
private static function getNodesInputConfig(): array
{
return [
'write' => [
Expand Down Expand Up @@ -391,7 +391,7 @@ private function getNodesInputConfig(): array
*
* @return mixed[]
*/
private function getNodesExpectedConfig(): array
private static function getNodesExpectedConfig(): array
{
return [
'wrapperClass' => PrimaryReadReplicaDoctrineWrapper::class,
Expand Down Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -470,7 +470,7 @@ private function getPgsqlExpectedConfig(): array
*
* @return mixed[]
*/
private function getSqliteExpectedConfig(): array
private static function getSqliteExpectedConfig(): array
{
return [
'wrapperClass' => PrimaryReadReplicaDoctrineWrapper::class,
Expand Down Expand Up @@ -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']);
Expand All @@ -527,7 +527,7 @@ private function getSqliteInputConfig(): array
*
* @return mixed[]
*/
private function getResolvedMysqlConfig(): array
private static function getResolvedMysqlConfig(): array
{
return [
'driver' => 'pdo_mysql',
Expand All @@ -547,7 +547,7 @@ private function getResolvedMysqlConfig(): array
*
* @return mixed[]
*/
private function getResolvedOracleConfig(): array
private static function getResolvedOracleConfig(): array
{
return [
'driver' => 'oci8',
Expand All @@ -564,7 +564,7 @@ private function getResolvedOracleConfig(): array
*
* @return mixed[]
*/
private function getResolvedSqliteConfig(): array
private static function getResolvedSqliteConfig(): array
{
return [
'driver' => 'pdo_sqlite',
Expand All @@ -580,7 +580,7 @@ private function getResolvedSqliteConfig(): array
*
* @return mixed[]
*/
private function getResolvedPgqsqlConfig(): array
private static function getResolvedPgqsqlConfig(): array
{
return [
'driver' => 'pgsql',
Expand Down
16 changes: 8 additions & 8 deletions tests/Feature/EntityManagerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand All @@ -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[] = [
Expand All @@ -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[] = [
Expand All @@ -1046,7 +1046,7 @@ public function getTestPrimaryReadReplicaConnectionData(): array
];

//Case #4. 'read' has empty entries.
$inputConfig = $this->getDummyBaseInputConfig();
$inputConfig = self::getDummyBaseInputConfig();
$inputConfig['read'][] = [];

$out[] = [
Expand All @@ -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[] = [
Expand Down Expand Up @@ -1134,7 +1134,7 @@ protected function tearDown(): void
*
* @return mixed[]
*/
private function getDummyBaseInputConfig(): array
private static function getDummyBaseInputConfig(): array
{
return [
'driver' => 'mysql',
Expand Down

0 comments on commit 1d2a303

Please sign in to comment.