FileCacheTests::createCache()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Cubiche/Metadata component.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Core\Metadata\Tests\Units\Cache;
13
14
use Cubiche\Core\Metadata\Cache\FileCache;
15
16
/**
17
 * FileCacheTests class.
18
 *
19
 * Generated by TestGenerator on 2017-05-16 at 13:17:21.
20
 */
21
class FileCacheTests extends CacheTestCase
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    protected function createCache()
27
    {
28
        return new FileCache($this->cacheDirectory);
29
    }
30
31
    /**
32
     * Test create.
33
     */
34
    public function testCreate()
35
    {
36
        $this
37
            ->given($invalidCacheDir = __DIR__.'/Invalid')
38
            ->given($nonWritableCacheDir = '/root')
39
            ->then()
40
                ->exception(function () use ($nonWritableCacheDir) {
41
                    new FileCache($nonWritableCacheDir);
42
                })->isInstanceOf(\InvalidArgumentException::class)
43
                ->boolean(is_dir($invalidCacheDir))
44
                    ->isFalse()
45
                ->and()
46
                ->when(new FileCache($invalidCacheDir))
47
                ->then()
48
                    ->boolean(is_dir($invalidCacheDir))
49
                        ->isTrue()
50
                    ->and()
51
                    ->when($this->rmdir($invalidCacheDir))
52
                    ->then()
53
                        ->boolean(is_dir($invalidCacheDir))
54
                            ->isFalse()
55
        ;
56
    }
57
}
58