ConfigureCacheTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
dl 0
loc 49
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testInvokeWithCachePath() 0 24 1
A cacheDirProvider() 0 17 1
1
<?php
2
/**
3
 *  This file is part of phpDocumentor.
4
 *
5
 *  For the full copyright and license information, please view the LICENSE
6
 *  file that was distributed with this source code.
7
 *
8
 *  @copyright 2010-2018 Mike van Riel<[email protected]>
9
 *  @license   http://www.opensource.org/licenses/mit-license.php MIT
10
 *  @link      http://phpdoc.org
11
 */
12
13
namespace phpDocumentor\Application\Stage\Cache;
14
15
use \Mockery as m;
16
use Mockery\Adapter\Phpunit\MockeryTestCase;
17
use phpDocumentor\Application\Stage\Payload;
18
use phpDocumentor\Descriptor\ProjectDescriptorBuilder;
19
use phpDocumentor\Path;
20
use Stash\Pool;
21
22
class ConfigureCacheTest extends MockeryTestCase
23
{
24
    /**
25
     * @dataProvider cacheDirProvider
26
     * @throws \Exception
27
     */
28
    public function testInvokeWithCachePath($configuredPath)
29
    {
30
        $configuration = [
31
            'phpdocumentor' => [
32
                'paths' => [
33
                    'cache' => $configuredPath,
34
                ],
35
            ],
36
        ];
37
38
        $cacheStorage = m::mock(Pool::class);
39
        $cacheStorage->shouldReceive('setDriver')
40
            ->with(m::type(\Stash\Driver\FileSystem::class))
41
            ->once();
42
43
        $stage = new ConfigureCache($cacheStorage);
44
45
        $payload = new Payload($configuration, m::mock(ProjectDescriptorBuilder::class));
46
47
        self::assertSame(
48
            $payload,
49
            $stage($payload)
50
        );
51
    }
52
53
    public function cacheDirProvider()
54
    {
55
        return [
56
            [
57
                '/tmp/cache',
58
            ],
59
            [
60
                'cache/relative',
61
            ],
62
            [
63
                new Path('/tmp/cache'),
64
            ],
65
            [
66
                new Path('cache/relative'),
67
            ],
68
        ];
69
    }
70
}
71