diff --git a/src/DI/OrmCacheExtension.php b/src/DI/OrmCacheExtension.php index 3ff0614..d8704ad 100644 --- a/src/DI/OrmCacheExtension.php +++ b/src/DI/OrmCacheExtension.php @@ -38,7 +38,7 @@ public function getConfigSchema(): Schema 'hydrationCache' => $this->getServiceSchema(), 'metadataCache' => $this->getServiceSchema(), 'resultCache' => $this->getServiceSchema(), - 'secondLevelCache' => Expect::array()->default(null), + 'secondLevelCache' => $this->getServiceSchema(), ]); } diff --git a/tests/cases/Unit/DI/OrmCacheExtensionTest.php b/tests/cases/Unit/DI/OrmCacheExtensionTest.php index aa855ea..57f3733 100644 --- a/tests/cases/Unit/DI/OrmCacheExtensionTest.php +++ b/tests/cases/Unit/DI/OrmCacheExtensionTest.php @@ -6,6 +6,7 @@ use Doctrine\Common\Cache\ArrayCache; use Doctrine\Common\Cache\PhpFileCache; use Doctrine\Common\Cache\VoidCache; +use Doctrine\ORM\Cache\CacheConfiguration; use Nette\DI\Compiler; use Nette\DI\Container; use Nette\DI\ContainerLoader; @@ -17,6 +18,7 @@ use Nettrine\ORM\DI\OrmCacheExtension; use Nettrine\ORM\DI\OrmExtension; use Nettrine\ORM\EntityManagerDecorator; +use Tests\Fixtures\DummyCacheConfigurationFactory; use Tests\Toolkit\TestCase; final class OrmCacheExtensionTest extends TestCase @@ -68,6 +70,7 @@ public function testProvidedCacheDrivers(): void 'hydrationCache' => VoidCache::class, 'metadataCache' => null, 'queryCache' => ApcuCache::class, + 'secondLevelCache' => [DummyCacheConfigurationFactory::class, 'create'], //'resultCache' => null, ], 'parameters' => [ @@ -87,6 +90,7 @@ public function testProvidedCacheDrivers(): void $this->assertInstanceOf(ArrayCache::class, $em->getConfiguration()->getMetadataCacheImpl()); $this->assertInstanceOf(ApcuCache::class, $em->getConfiguration()->getQueryCacheImpl()); $this->assertInstanceOf(ArrayCache::class, $em->getConfiguration()->getResultCacheImpl()); + $this->assertInstanceOf(CacheConfiguration::class, $em->getConfiguration()->getSecondLevelCacheConfiguration()); } public function testNoCacheDriver(): void diff --git a/tests/fixtures/DummyCacheConfigurationFactory.php b/tests/fixtures/DummyCacheConfigurationFactory.php new file mode 100644 index 0000000..34d871b --- /dev/null +++ b/tests/fixtures/DummyCacheConfigurationFactory.php @@ -0,0 +1,25 @@ +setCacheFactory($cacheFactory); + + return $cacheConfiguration; + } + +}