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'); |
|
|
|
|
62
|
|
|
$this->mapper->populate($restoredProjectDescriptor); |
63
|
|
|
|
64
|
|
|
$this->assertTrue($restoredProjectDescriptor->getSettings()->shouldIncludeSource()); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.