@@ -30,6 +30,8 @@ Toolkit::test(function (): void {
3030 Assert::type (PhpFileCache::class, $ em ->getConfiguration ()->getMetadataCacheImpl ());
3131 Assert::type (PhpFileCache::class, $ em ->getConfiguration ()->getQueryCacheImpl ());
3232 Assert::type (PhpFileCache::class, $ em ->getConfiguration ()->getResultCacheImpl ());
33+ Assert::true ($ em ->getConfiguration ()->isSecondLevelCacheEnabled ());
34+ Assert::notNull ($ em ->getConfiguration ()->getSecondLevelCacheConfiguration ());
3335});
3436
3537// Provide cache drivers
@@ -57,4 +59,31 @@ Toolkit::test(function (): void {
5759 Assert::type (ArrayCache::class, $ em ->getConfiguration ()->getMetadataCacheImpl ());
5860 Assert::type (ApcuCache::class, $ em ->getConfiguration ()->getQueryCacheImpl ());
5961 Assert::type (ArrayCache::class, $ em ->getConfiguration ()->getResultCacheImpl ());
62+ Assert::true ($ em ->getConfiguration ()->isSecondLevelCacheEnabled ());
63+ Assert::notNull ($ em ->getConfiguration ()->getSecondLevelCacheConfiguration ());
64+ });
65+
66+ // Turn off second level cache
67+ Toolkit::test (function (): void {
68+ $ container = Container::of ()
69+ ->withDefaults ()
70+ ->withCompiler (function (Compiler $ compiler ): void {
71+ $ compiler ->addExtension ('nettrine.orm.cache ' , new OrmCacheExtension ());
72+ $ compiler ->addConfig ([
73+ 'nettrine.orm.cache ' => [
74+ 'secondLevelCache ' => false ,
75+ ],
76+ ]);
77+ })
78+ ->build ();
79+
80+ /** @var EntityManagerDecorator $em */
81+ $ em = $ container ->getByType (EntityManagerDecorator::class);
82+
83+ Assert::false ($ em ->getConfiguration ()->isSecondLevelCacheEnabled ());
84+ Assert::null ($ em ->getConfiguration ()->getSecondLevelCacheConfiguration ());
85+ Assert::type (PhpFileCache::class, $ em ->getConfiguration ()->getHydrationCacheImpl ());
86+ Assert::type (PhpFileCache::class, $ em ->getConfiguration ()->getMetadataCacheImpl ());
87+ Assert::type (PhpFileCache::class, $ em ->getConfiguration ()->getQueryCacheImpl ());
88+ Assert::type (PhpFileCache::class, $ em ->getConfiguration ()->getResultCacheImpl ());
6089});
0 commit comments