Completed
Push — develop ( f937fe...60406c )
by Mike
14s
created

testThatTheCacheDriverCanBeRetrieved()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace phpDocumentor\Descriptor\Cache;
4
5
use phpDocumentor\Descriptor\ProjectDescriptor;
6
use PHPUnit\Framework\TestCase;
7
use Zend\Cache\Storage\Adapter\Memory;
8
use Zend\Cache\Storage\StorageInterface;
9
use Mockery as m;
10
11
/**
12
 * @coversDefaultClass \phpDocumentor\Descriptor\Cache\ProjectDescriptorMapper
13
 * @covers ::__construct
14
 */
15
final class ProjectDescriptorMapperTest extends TestCase
16
{
17
    /** @var ProjectDescriptorMapper */
18
    private $mapper;
19
20
    /** @var StorageInterface */
21
    private $cacheDriver;
22
23
    public function setUp()
24
    {
25
        $this->cacheDriver = new Memory();
26
        $this->mapper = new ProjectDescriptorMapper($this->cacheDriver);
27
    }
28
29
    /**
30
     * @covers ::getCache
31
     */
32
    public function testThatTheCacheDriverCanBeRetrieved()
33
    {
34
        $this->assertSame($this->cacheDriver, $this->mapper->getCache());
35
    }
36
37
    /**
38
     * @covers ::getCache
39
     */
40
    public function testThatACacheDriverMustBeAZendStorageInterface()
41
    {
42
        $this->expectException(\InvalidArgumentException::class);
43
44
        $this->mapper = new ProjectDescriptorMapper(m::mock(StorageInterface::class));
45
    }
46
47
    /**
48
     * @covers ::save
49
     * @covers ::populate
50
     */
51
    public function testThatATheSettingsForAProjectDescriptorArePersistedAndCanBeRetrievedFromCache()
52
    {
53
        $projectDescriptor = new ProjectDescriptor('project');
54
55
        $this->assertFalse($projectDescriptor->getSettings()->shouldIncludeSource());
56
        $projectDescriptor->getSettings()->includeSource();
57
        $this->assertTrue($projectDescriptor->getSettings()->shouldIncludeSource());
58
59
        $this->mapper->save($projectDescriptor);
60
61
        $restoredProjectDescriptor = new ProjectDescriptor('project2');
0 ignored issues
show
Comprehensibility Naming introduced by Mike van Riel
The variable name $restoredProjectDescriptor exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
62
        $this->mapper->populate($restoredProjectDescriptor);
63
64
        $this->assertTrue($restoredProjectDescriptor->getSettings()->shouldIncludeSource());
65
    }
66
}
67