1
|
|
|
<?php declare(strict_types=1); |
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 PHPUnit\Framework\TestCase; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @coversDefaultClass \phpDocumentor\Parser\SpecificationFactory |
26
|
|
|
* @covers ::create |
27
|
|
|
* @covers ::<private> |
28
|
|
|
*/ |
29
|
|
|
final class SpecificationFactoryTest extends TestCase |
30
|
|
|
{ |
31
|
|
|
/** @var SpecificationFactory */ |
32
|
|
|
private $fixture; |
33
|
|
|
|
34
|
|
|
protected function setUp() |
35
|
|
|
{ |
36
|
|
|
$this->fixture = new SpecificationFactory(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testCreateIgnoreHidden() |
40
|
|
|
{ |
41
|
|
|
$specification = $this->fixture->create(['some/path', 'a/second/path'], ['hidden' => true], ['php', 'php3']); |
42
|
|
|
|
43
|
|
|
$this->assertEquals( |
44
|
|
|
new AndSpecification( |
45
|
|
|
new OrSpecification( |
46
|
|
|
new InPath(new Path('some/path')), |
47
|
|
|
new InPath(new Path('a/second/path')) |
48
|
|
|
), |
49
|
|
|
new AndSpecification( |
50
|
|
|
new HasExtension(['php', 'php3']), |
51
|
|
|
new NotSpecification( |
52
|
|
|
new IsHidden() |
53
|
|
|
) |
54
|
|
|
) |
55
|
|
|
), |
56
|
|
|
$specification |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function testCreateIgnorePath() |
61
|
|
|
{ |
62
|
|
|
$specification = $this->fixture->create(['src/'], ['paths' => ['src/some/path', 'src/some/other/path']], ['php']); |
63
|
|
|
|
64
|
|
|
$this->assertEquals( |
65
|
|
|
new AndSpecification( |
66
|
|
|
new InPath(new Path('src/')), |
67
|
|
|
new AndSpecification( |
68
|
|
|
new HasExtension(['php']), |
69
|
|
|
new NotSpecification( |
70
|
|
|
new OrSpecification( |
71
|
|
|
new InPath(new Path('src/some/path')), |
72
|
|
|
new InPath(new Path('src/some/other/path')) |
73
|
|
|
) |
74
|
|
|
) |
75
|
|
|
) |
76
|
|
|
), |
77
|
|
|
$specification |
78
|
|
|
); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function testNoPaths() |
82
|
|
|
{ |
83
|
|
|
$specification = $this->fixture->create([], ['paths' => ['src/some/path']], ['php']); |
84
|
|
|
|
85
|
|
|
$this->assertEquals( |
86
|
|
|
new AndSpecification( |
87
|
|
|
new HasExtension(['php']), |
88
|
|
|
new NotSpecification( |
89
|
|
|
new InPath(new Path('src/some/path')) |
90
|
|
|
) |
91
|
|
|
), |
92
|
|
|
$specification |
93
|
|
|
); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
public function testNoIgnore() |
97
|
|
|
{ |
98
|
|
|
$specification = $this->fixture->create(['src/'], ['paths' => []], ['php']); |
99
|
|
|
|
100
|
|
|
$this->assertEquals( |
101
|
|
|
new AndSpecification( |
102
|
|
|
new InPath(new Path('src/')), |
103
|
|
|
new HasExtension(['php']) |
104
|
|
|
), |
105
|
|
|
$specification |
106
|
|
|
); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|