|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eZ\Bundle\EzPublishCoreBundle\Tests\DependencyInjection\Compiler; |
|
4
|
|
|
|
|
5
|
|
|
use eZ\Bundle\EzPublishCoreBundle\Cache\Driver\Redis\RedisIgbinary; |
|
6
|
|
|
use eZ\Bundle\EzPublishCoreBundle\Cache\Driver\Redis\RedisIgbinaryLzf; |
|
7
|
|
|
use eZ\Bundle\EzPublishCoreBundle\Cache\Driver\Redis\RedisSerializeLzf; |
|
8
|
|
|
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\StashPass; |
|
9
|
|
|
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase; |
|
10
|
|
|
use Stash\Driver\Redis; |
|
11
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
12
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
13
|
|
|
|
|
14
|
|
|
class StashPassTest extends AbstractCompilerPassTestCase |
|
15
|
|
|
{ |
|
16
|
|
|
protected function registerCompilerPass(ContainerBuilder $container) |
|
17
|
|
|
{ |
|
18
|
|
|
$container->addCompilerPass(new StashPass()); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @dataProvider configureRedisProvider |
|
23
|
|
|
*/ |
|
24
|
|
|
public function testConfigureRedis($igbinary, $lzf, $expectedClass) |
|
25
|
|
|
{ |
|
26
|
|
|
$this->setDefinition('stash.driver', new Definition()); |
|
27
|
|
|
$this->setParameter('ezpublish.stash_cache.redis_driver.class', Redis::class); |
|
28
|
|
|
$this->setParameter('ezpublish.stash_cache.redis_driver.name', 'Redis'); |
|
29
|
|
|
$this->setParameter('ezpublish.stash_cache.igbinary', $igbinary); |
|
30
|
|
|
$this->setParameter('ezpublish.stash_cache.lzf', $lzf); |
|
31
|
|
|
$this->container->prependExtensionConfig('stash', |
|
32
|
|
|
[ |
|
33
|
|
|
'caches' => [ |
|
34
|
|
|
'test' => [ |
|
35
|
|
|
'drivers' => [ |
|
36
|
|
|
'Redis', |
|
37
|
|
|
], |
|
38
|
|
|
], |
|
39
|
|
|
], |
|
40
|
|
|
] |
|
41
|
|
|
); |
|
42
|
|
|
|
|
43
|
|
|
$this->compile(); |
|
44
|
|
|
|
|
45
|
|
|
$this->assertContainerBuilderHasParameter('ezpublish.stash_cache.redis_driver.class', $expectedClass); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function configureRedisProvider() |
|
49
|
|
|
{ |
|
50
|
|
|
return [ |
|
51
|
|
|
[false, false, Redis::class], |
|
52
|
|
|
[true, false, RedisIgbinary::class], |
|
53
|
|
|
[false, true, RedisSerializeLzf::class], |
|
54
|
|
|
[true, true, RedisIgbinaryLzf::class], |
|
55
|
|
|
]; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|