Completed
Push — sf_cache ( 18214b...3b3329 )
by André
19:05
created

EnvTest::testVerifyCacheDriver()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 2
nop 0
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the EnvTest class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\API\Repository\Tests\Regression;
10
11
use eZ\Publish\API\Repository\Tests\BaseTest;
12
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
13
use Symfony\Component\Cache\Adapter\RedisAdapter;
14
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
15
16
/**
17
 * Test case to verify Integration tests are setup with the right instances.
18
 */
19
class EnvTest extends BaseTest
20
{
21
    /**
22
     * Verify Redis cache is setup if asked for, if not file system.
23
     */
24
    public function testVerifyCacheDriver()
25
    {
26
        $pool = $this->getSetupFactory()->getServiceContainer()->get('ezpublish.cache_pool');
27
28
        $this->assertInstanceOf(TagAwareAdapter::class, $pool);
29
30
        $reflectionPool = new \ReflectionProperty($pool, 'itemsAdapter');
31
        $reflectionPool->setAccessible(true);
32
        $innerPool = $reflectionPool->getValue($pool);
33
34
        if (getenv('CUSTOM_CACHE_POOL') === 'singleredis') {
35
            $this->assertInstanceOf(RedisAdapter::class, $innerPool);
36
        } else {
37
            $this->assertInstanceOf(FilesystemAdapter::class, $innerPool);
38
        }
39
    }
40
}
41