|
14 | 14 | use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
15 | 15 | use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass;
|
16 | 16 | use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
|
| 17 | +use Symfony\Component\Cache\Adapter\AdapterInterface; |
17 | 18 | use Symfony\Component\Cache\Adapter\ApcuAdapter;
|
| 19 | +use Symfony\Component\Cache\Adapter\ArrayAdapter; |
18 | 20 | use Symfony\Component\Cache\Adapter\ChainAdapter;
|
19 | 21 | use Symfony\Component\Cache\Adapter\DoctrineAdapter;
|
20 | 22 | use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
|
25 | 27 | use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
|
26 | 28 | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
27 | 29 | use Symfony\Component\DependencyInjection\Reference;
|
| 30 | +use Symfony\Component\PropertyAccess\PropertyAccessor; |
28 | 31 | use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory;
|
29 | 32 | use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader;
|
30 | 33 | use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader;
|
@@ -67,6 +70,32 @@ public function testPropertyAccessWithOverriddenValues()
|
67 | 70 | $this->assertTrue($def->getArgument(1));
|
68 | 71 | }
|
69 | 72 |
|
| 73 | + public function testPropertyAccessCache() |
| 74 | + { |
| 75 | + $container = $this->createContainerFromFile('property_accessor'); |
| 76 | + |
| 77 | + if (!method_exists(PropertyAccessor::class, 'createCache')) { |
| 78 | + return $this->assertFalse($container->hasDefinition('cache.property_access')); |
| 79 | + } |
| 80 | + |
| 81 | + $cache = $container->getDefinition('cache.property_access'); |
| 82 | + $this->assertSame(array(PropertyAccessor::class, 'createCache'), $cache->getFactory(), 'PropertyAccessor::createCache() should be used in non-debug mode'); |
| 83 | + $this->assertSame(AdapterInterface::class, $cache->getClass()); |
| 84 | + } |
| 85 | + |
| 86 | + public function testPropertyAccessCacheWithDebug() |
| 87 | + { |
| 88 | + $container = $this->createContainerFromFile('property_accessor', array('kernel.debug' => true)); |
| 89 | + |
| 90 | + if (!method_exists(PropertyAccessor::class, 'createCache')) { |
| 91 | + return $this->assertFalse($container->hasDefinition('cache.property_access')); |
| 92 | + } |
| 93 | + |
| 94 | + $cache = $container->getDefinition('cache.property_access'); |
| 95 | + $this->assertNull($cache->getFactory()); |
| 96 | + $this->assertSame(ArrayAdapter::class, $cache->getClass(), 'ArrayAdapter should be used in debug mode'); |
| 97 | + } |
| 98 | + |
70 | 99 | /**
|
71 | 100 | * @expectedException \LogicException
|
72 | 101 | * @expectedExceptionMessage CSRF protection needs sessions to be enabled.
|
|
0 commit comments