Passed
Pull Request — master (#16)
by Mihail
11:07 queued 02:40
created

RedisWithJsonSerializerTest::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 0
dl 0
loc 20
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace Koded\Caching;
4
5
use Koded\Caching\Client\CacheClientFactory;
6
use Koded\Caching\Configuration\ConfigFactory;
7
use Koded\Stdlib\Interfaces\Serializer;
8
use PHPUnit\Framework\TestCase;
9
10
class RedisWithJsonSerializerTest extends TestCase
11
{
12
    use SimpleCacheTestCaseTrait;
13
14
    public function test_should_return_redis_client()
15
    {
16
        $this->assertInstanceOf(\Redis::class, $this->cache->client());
17
    }
18
19
    protected function setUp(): void
20
    {
21
        putenv('CACHE_CLIENT=redis');
22
23
        if (false === extension_loaded('redis')) {
24
            $this->markTestSkipped('Redis extension is not loaded.');
25
        }
26
27
        $this->cache = (new CacheClientFactory(new ConfigFactory([
28
            'host' => getenv('REDIS_SERVER_HOST'),
29
            'port' => getenv('REDIS_SERVER_PORT'),
30
            'serializer' => Serializer::JSON,
31
32
            'options' => [
33
                'prefix' => 'test:'
34
            ],
35
36
        ])))->new();
37
38
        $this->cache->clear();
39
    }
40
}