Completed
Push — master ( 7c8813...b0bb77 )
by Alejandro
21s queued 11s
created

CacheFactoryTest::tearDownAfterClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace ShlinkioTest\Shlink\Common\Cache;
5
6
use Doctrine\Common\Cache\ApcuCache;
7
use Doctrine\Common\Cache\ArrayCache;
8
use PHPUnit\Framework\TestCase;
9
use Shlinkio\Shlink\Common\Cache\CacheFactory;
10
use Shlinkio\Shlink\Core\Options\AppOptions;
11
use Zend\ServiceManager\ServiceManager;
12
13
use function putenv;
14
15
class CacheFactoryTest extends TestCase
16
{
17
    /** @var CacheFactory */
18
    private $factory;
19
    /** @var ServiceManager */
20
    private $sm;
21
22
    public function setUp(): void
23
    {
24
        $this->factory = new CacheFactory();
25
        $this->sm = new ServiceManager(['services' => [
26
            AppOptions::class => new AppOptions(),
27
        ]]);
28
    }
29
30
    public static function tearDownAfterClass(): void
31
    {
32
        putenv('APP_ENV');
33
    }
34
35
    /** @test */
36
    public function productionReturnsApcAdapter(): void
37
    {
38
        putenv('APP_ENV=pro');
39
        $instance = ($this->factory)($this->sm, '');
40
        $this->assertInstanceOf(ApcuCache::class, $instance);
41
    }
42
43
    /** @test */
44
    public function developmentReturnsArrayAdapter(): void
45
    {
46
        putenv('APP_ENV=dev');
47
        $instance = ($this->factory)($this->sm, '');
48
        $this->assertInstanceOf(ArrayCache::class, $instance);
49
    }
50
}
51