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\Parser; |
14
|
|
|
|
15
|
|
|
use Flyfinder\Path; |
16
|
|
|
use Flyfinder\Specification\AndSpecification; |
17
|
|
|
use Flyfinder\Specification\HasExtension; |
18
|
|
|
use Flyfinder\Specification\InPath; |
19
|
|
|
use Flyfinder\Specification\IsHidden; |
20
|
|
|
use Flyfinder\Specification\NotSpecification; |
21
|
|
|
use Flyfinder\Specification\OrSpecification; |
22
|
|
|
use phpDocumentor\Parser\SpecificationFactoryInterface; |
23
|
|
|
use PHPUnit\Framework\TestCase; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @coversDefaultClass \phpDocumentor\Parser\SpecificationFactory |
27
|
|
|
* @covers ::create |
28
|
|
|
* @covers ::<private> |
29
|
|
|
*/ |
30
|
|
|
class SpecificationFactoryTest extends TestCase |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* @var SpecificationFactory |
34
|
|
|
*/ |
35
|
|
|
private $fixture; |
36
|
|
|
|
37
|
|
|
protected function setUp() |
38
|
|
|
{ |
39
|
|
|
$this->fixture = new SpecificationFactory(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testCreateIgnoreHidden() |
43
|
|
|
{ |
44
|
|
|
$paths = [ |
45
|
|
|
'some/path', |
46
|
|
|
]; |
47
|
|
|
|
48
|
|
|
$ignore = [ |
49
|
|
|
'hidden' => true, |
50
|
|
|
]; |
51
|
|
|
|
52
|
|
|
$extensions = [ |
53
|
|
|
'php', |
54
|
|
|
]; |
55
|
|
|
|
56
|
|
|
$specification = $this->fixture->create($paths, $ignore, $extensions); |
57
|
|
|
|
58
|
|
|
$this->assertEquals( |
59
|
|
|
new AndSpecification( |
60
|
|
|
new InPath(new Path('some/path')), |
61
|
|
|
new AndSpecification( |
62
|
|
|
new HasExtension(['php']), |
63
|
|
|
new NotSpecification( |
64
|
|
|
new IsHidden() |
65
|
|
|
) |
66
|
|
|
) |
67
|
|
|
), |
68
|
|
|
$specification |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function testCreateIgnorePath() |
73
|
|
|
{ |
74
|
|
|
$paths = [ |
75
|
|
|
'src/', |
76
|
|
|
]; |
77
|
|
|
|
78
|
|
|
$ignore = [ |
79
|
|
|
'paths' => ['src/some/path', 'src/some/other/path'], |
80
|
|
|
]; |
81
|
|
|
|
82
|
|
|
$extensions = [ |
83
|
|
|
'php', |
84
|
|
|
]; |
85
|
|
|
|
86
|
|
|
$specification = $this->fixture->create($paths, $ignore, $extensions); |
87
|
|
|
|
88
|
|
|
$this->assertEquals( |
89
|
|
|
new AndSpecification( |
90
|
|
|
new InPath(new Path('src/')), |
91
|
|
|
new AndSpecification( |
92
|
|
|
new HasExtension(['php']), |
93
|
|
|
new NotSpecification( |
94
|
|
|
new OrSpecification( |
95
|
|
|
new InPath(new Path('src/some/path')), |
96
|
|
|
new InPath(new Path('src/some/other/path')) |
97
|
|
|
) |
98
|
|
|
) |
99
|
|
|
) |
100
|
|
|
), |
101
|
|
|
$specification |
102
|
|
|
); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function testNoIgnore() |
106
|
|
|
{ |
107
|
|
|
$paths = [ |
108
|
|
|
'src/', |
109
|
|
|
]; |
110
|
|
|
|
111
|
|
|
$ignore = [ |
112
|
|
|
'paths' => [], |
113
|
|
|
]; |
114
|
|
|
|
115
|
|
|
$extensions = [ |
116
|
|
|
'php', |
117
|
|
|
]; |
118
|
|
|
|
119
|
|
|
$specification = $this->fixture->create($paths, $ignore, $extensions); |
120
|
|
|
|
121
|
|
|
$this->assertEquals( |
122
|
|
|
new AndSpecification( |
123
|
|
|
new InPath(new Path('src/')), |
124
|
|
|
new HasExtension(['php']) |
125
|
|
|
), |
126
|
|
|
$specification |
127
|
|
|
); |
128
|
|
|
} |
129
|
|
|
} |
130
|
|
|
|