1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace phpDocumentor\Configuration; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @coversDefaultClass \phpDocumentor\Configuration\ApiSpecification |
11
|
|
|
*/ |
12
|
|
|
final class ApiSpecificationTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @dataProvider visibilityProvider |
16
|
|
|
* @covers ::offsetSet |
17
|
|
|
* @covers ::isVisibilityAllowed |
18
|
|
|
*/ |
19
|
|
|
public function testVisibility(array $settings, array $expected) |
20
|
|
|
{ |
21
|
|
|
$apiSpec = ApiSpecification::createDefault(); |
22
|
|
|
$apiSpec['visibility'] = $settings; |
23
|
|
|
|
24
|
|
|
foreach ($expected as $visiblity => $result) { |
25
|
|
|
self::assertSame($result, $apiSpec->isVisibilityAllowed($visiblity)); |
26
|
|
|
} |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @return array<array<string[], int>> |
|
|
|
|
31
|
|
|
*/ |
32
|
|
|
public function visibilityProvider() : array |
33
|
|
|
{ |
34
|
|
|
return [ |
35
|
|
|
[ |
36
|
|
|
'settings' => ['public'], |
37
|
|
|
'expected' => [ |
38
|
|
|
ApiSpecification::VISIBILITY_PUBLIC => true, |
39
|
|
|
ApiSpecification::VISIBILITY_PROTECTED => false, |
40
|
|
|
ApiSpecification::VISIBILITY_PRIVATE => false, |
41
|
|
|
ApiSpecification::VISIBILITY_INTERNAL => false, |
42
|
|
|
], |
43
|
|
|
], |
44
|
|
|
[ |
45
|
|
|
'settings' => ['protected'], |
46
|
|
|
'expected' => [ |
47
|
|
|
ApiSpecification::VISIBILITY_PUBLIC => false, |
48
|
|
|
ApiSpecification::VISIBILITY_PROTECTED => true, |
49
|
|
|
ApiSpecification::VISIBILITY_PRIVATE => false, |
50
|
|
|
ApiSpecification::VISIBILITY_INTERNAL => false, |
51
|
|
|
], |
52
|
|
|
], |
53
|
|
|
[ |
54
|
|
|
'settings' => ['private'], |
55
|
|
|
'expected' => [ |
56
|
|
|
ApiSpecification::VISIBILITY_PUBLIC => false, |
57
|
|
|
ApiSpecification::VISIBILITY_PROTECTED => false, |
58
|
|
|
ApiSpecification::VISIBILITY_PRIVATE => true, |
59
|
|
|
ApiSpecification::VISIBILITY_INTERNAL => false, |
60
|
|
|
], |
61
|
|
|
], |
62
|
|
|
[ |
63
|
|
|
'settings' => ['public', 'private'], |
64
|
|
|
'expected' => [ |
65
|
|
|
ApiSpecification::VISIBILITY_PUBLIC => true, |
66
|
|
|
ApiSpecification::VISIBILITY_PROTECTED => false, |
67
|
|
|
ApiSpecification::VISIBILITY_PRIVATE => true, |
68
|
|
|
ApiSpecification::VISIBILITY_INTERNAL => false, |
69
|
|
|
], |
70
|
|
|
], |
71
|
|
|
[ |
72
|
|
|
'settings' => ['public', 'internal'], |
73
|
|
|
'expected' => [ |
74
|
|
|
ApiSpecification::VISIBILITY_PUBLIC => true, |
75
|
|
|
ApiSpecification::VISIBILITY_PROTECTED => false, |
76
|
|
|
ApiSpecification::VISIBILITY_PRIVATE => false, |
77
|
|
|
ApiSpecification::VISIBILITY_INTERNAL => true, |
78
|
|
|
], |
79
|
|
|
], |
80
|
|
|
[ |
81
|
|
|
'settings' => ['internal'], |
82
|
|
|
'expected' => [ |
83
|
|
|
ApiSpecification::VISIBILITY_PUBLIC => true, |
84
|
|
|
ApiSpecification::VISIBILITY_PROTECTED => true, |
85
|
|
|
ApiSpecification::VISIBILITY_PRIVATE => true, |
86
|
|
|
ApiSpecification::VISIBILITY_INTERNAL => true, |
87
|
|
|
], |
88
|
|
|
], |
89
|
|
|
]; |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.