From 80db33ce730a9edfa61609b8b795d67b852efaff Mon Sep 17 00:00:00 2001 From: David Maicher Date: Mon, 27 Nov 2023 22:38:25 +0100 Subject: [PATCH] drop doctrine/cache integration (#268) --- composer.json | 1 - .../DoctrineTestCompilerPass.php | 4 +- .../Doctrine/Cache/StaticArrayCache.php | 53 ------------------- .../DoctrineTestCompilerPassTest.php | 20 ------- tests/Functional/app/config.yml | 2 +- 5 files changed, 2 insertions(+), 78 deletions(-) delete mode 100644 src/DAMA/DoctrineTestBundle/Doctrine/Cache/StaticArrayCache.php diff --git a/composer.json b/composer.json index 5fac000..6c74648 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,6 @@ }, "require-dev": { "behat/behat": "^3.0", - "doctrine/cache": "^1.12", "friendsofphp/php-cs-fixer": "^3.27", "phpstan/phpstan": "^1.2", "phpunit/phpunit": "^8.0 || ^9.0 || ^10.0", diff --git a/src/DAMA/DoctrineTestBundle/DependencyInjection/DoctrineTestCompilerPass.php b/src/DAMA/DoctrineTestBundle/DependencyInjection/DoctrineTestCompilerPass.php index 936a0eb..ce631e6 100644 --- a/src/DAMA/DoctrineTestBundle/DependencyInjection/DoctrineTestCompilerPass.php +++ b/src/DAMA/DoctrineTestBundle/DependencyInjection/DoctrineTestCompilerPass.php @@ -3,7 +3,6 @@ namespace DAMA\DoctrineTestBundle\DependencyInjection; use DAMA\DoctrineTestBundle\Doctrine\Cache\Psr6StaticArrayCache; -use DAMA\DoctrineTestBundle\Doctrine\Cache\StaticArrayCache; use DAMA\DoctrineTestBundle\Doctrine\DBAL\Middleware; use Doctrine\Common\Cache\Cache; use Psr\Cache\CacheItemPoolInterface; @@ -128,8 +127,7 @@ private function registerStaticCache( $cache->setClass(Psr6StaticArrayCache::class); $cache->setArgument(0, $namespace); // make sure we have no key collisions } elseif (is_a($originalCacheServiceDefinition->getClass(), Cache::class, true)) { - $cache->setClass(StaticArrayCache::class); - $cache->addMethodCall('setNamespace', [$namespace]); // make sure we have no key collisions + throw new \InvalidArgumentException(sprintf('Configuring "%s" caches is not supported anymore. Upgrade to PSR-6 caches instead.', Cache::class)); } else { throw new \InvalidArgumentException(sprintf('Unsupported cache class "%s" found on service "%s".', $originalCacheServiceDefinition->getClass(), $cacheServiceId)); } diff --git a/src/DAMA/DoctrineTestBundle/Doctrine/Cache/StaticArrayCache.php b/src/DAMA/DoctrineTestBundle/Doctrine/Cache/StaticArrayCache.php deleted file mode 100644 index d722384..0000000 --- a/src/DAMA/DoctrineTestBundle/Doctrine/Cache/StaticArrayCache.php +++ /dev/null @@ -1,53 +0,0 @@ -doContains($id) ? self::$data[$id] : false; - } - - protected function doContains($id): bool - { - // isset() is required for performance optimizations, to avoid unnecessary function calls to array_key_exists. - return isset(self::$data[$id]) || array_key_exists($id, self::$data); - } - - protected function doSave($id, $data, $lifeTime = 0): bool - { - self::$data[$id] = $data; - - return true; - } - - protected function doDelete($id): bool - { - unset(self::$data[$id]); - - return true; - } - - protected function doFlush(): bool - { - self::$data = []; - - return true; - } - - protected function doGetStats(): ?array - { - return null; - } -} diff --git a/tests/DAMA/DoctrineTestBundle/DependencyInjection/DoctrineTestCompilerPassTest.php b/tests/DAMA/DoctrineTestBundle/DependencyInjection/DoctrineTestCompilerPassTest.php index 943fb26..aaa07ca 100644 --- a/tests/DAMA/DoctrineTestBundle/DependencyInjection/DoctrineTestCompilerPassTest.php +++ b/tests/DAMA/DoctrineTestBundle/DependencyInjection/DoctrineTestCompilerPassTest.php @@ -5,9 +5,7 @@ use DAMA\DoctrineTestBundle\DependencyInjection\DAMADoctrineTestExtension; use DAMA\DoctrineTestBundle\DependencyInjection\DoctrineTestCompilerPass; use DAMA\DoctrineTestBundle\Doctrine\Cache\Psr6StaticArrayCache; -use DAMA\DoctrineTestBundle\Doctrine\Cache\StaticArrayCache; use Doctrine\Bundle\DoctrineBundle\ConnectionFactory; -use Doctrine\Common\Cache\ArrayCache; use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Connection; use PHPUnit\Framework\TestCase; @@ -215,24 +213,6 @@ function (TestCase $testCase): void { }, ]; - yield 'legacy doctrine/cache ORM services' => [ - $defaultConfig, - function (ContainerBuilder $containerBuilder): void { - foreach (self::CACHE_SERVICE_IDS as $id) { - self::assertFalse($containerBuilder->hasAlias($id)); - self::assertEquals( - (new Definition(StaticArrayCache::class))->addMethodCall('setNamespace', [sha1($id)]), - $containerBuilder->getDefinition($id) - ); - } - }, - function (self $testCase, ContainerBuilder $containerBuilder): void { - foreach (self::CACHE_SERVICE_IDS as $id) { - $containerBuilder->register($id, ArrayCache::class); - } - }, - ]; - yield 'psr6 ORM cache services' => [ $defaultConfig, function (ContainerBuilder $containerBuilder): void { diff --git a/tests/Functional/app/config.yml b/tests/Functional/app/config.yml index b49b49c..9054cfa 100644 --- a/tests/Functional/app/config.yml +++ b/tests/Functional/app/config.yml @@ -13,7 +13,7 @@ doctrine: replica: url: '%database.url%' - server_version: 8.0 + server_version: 8.0.31 use_savepoints: true replicas: replica_one: