|
13 | 13 | use function range; |
14 | 14 | use function realpath; |
15 | 15 | use PHPUnit\Framework\Attributes\CoversClass; |
| 16 | +use PHPUnit\Framework\Attributes\DataProvider; |
16 | 17 | use PHPUnit\Framework\Attributes\Small; |
17 | 18 | use PHPUnit\Framework\TestCase; |
18 | 19 | use SebastianBergmann\CodeCoverage\Filter; |
|
25 | 26 | #[Small] |
26 | 27 | final class MapBuilderTest extends TestCase |
27 | 28 | { |
28 | | - public function testBuildsMap(): void |
| 29 | + /** |
| 30 | + * @return non-empty-list<array{0: TargetMap, 1: non-empty-list<non-empty-string>}> |
| 31 | + */ |
| 32 | + public static function provider(): array |
29 | 33 | { |
30 | 34 | $file = realpath(__DIR__ . '/../../_files/source_with_interfaces_classes_traits_functions.php'); |
31 | 35 |
|
32 | | - $this->assertSame( |
| 36 | + return [ |
33 | 37 | [ |
34 | | - 'namespaces' => [ |
35 | | - 'SebastianBergmann' => [ |
36 | | - $file => array_merge( |
37 | | - range(19, 24), |
38 | | - range(26, 31), |
39 | | - range(33, 52), |
40 | | - range(54, 56), |
41 | | - ), |
42 | | - ], |
43 | | - 'SebastianBergmann\\CodeCoverage' => [ |
44 | | - $file => array_merge( |
45 | | - range(19, 24), |
46 | | - range(26, 31), |
47 | | - range(33, 52), |
48 | | - range(54, 56), |
49 | | - ), |
50 | | - ], |
51 | | - 'SebastianBergmann\\CodeCoverage\\StaticAnalysis' => [ |
52 | | - $file => array_merge( |
53 | | - range(19, 24), |
54 | | - range(26, 31), |
55 | | - range(33, 52), |
56 | | - range(54, 56), |
57 | | - ), |
58 | | - ], |
59 | | - ], |
60 | | - 'traits' => [ |
61 | | - 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\T' => [ |
62 | | - $file => range(19, 24), |
63 | | - ], |
64 | | - ], |
65 | | - 'classes' => [ |
66 | | - 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ParentClass' => [ |
67 | | - $file => range(26, 31), |
68 | | - ], |
69 | | - 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ChildClass' => [ |
70 | | - $file => array_merge( |
71 | | - range(33, 52), |
72 | | - range(19, 24), |
73 | | - ), |
74 | | - ], |
75 | | - ], |
76 | | - 'classesThatExtendClass' => [ |
77 | | - 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ParentClass' => [ |
78 | | - $file => range(33, 52), |
79 | | - ], |
80 | | - ], |
81 | | - 'classesThatImplementInterface' => [ |
82 | | - 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\A' => [ |
83 | | - $file => range(33, 52), |
84 | | - ], |
85 | | - 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\B' => [ |
86 | | - $file => range(33, 52), |
| 38 | + [ |
| 39 | + 'namespaces' => [ |
| 40 | + 'SebastianBergmann' => [ |
| 41 | + $file => array_merge( |
| 42 | + range(19, 24), |
| 43 | + range(26, 31), |
| 44 | + range(33, 52), |
| 45 | + range(54, 56), |
| 46 | + ), |
| 47 | + ], |
| 48 | + 'SebastianBergmann\\CodeCoverage' => [ |
| 49 | + $file => array_merge( |
| 50 | + range(19, 24), |
| 51 | + range(26, 31), |
| 52 | + range(33, 52), |
| 53 | + range(54, 56), |
| 54 | + ), |
| 55 | + ], |
| 56 | + 'SebastianBergmann\\CodeCoverage\\StaticAnalysis' => [ |
| 57 | + $file => array_merge( |
| 58 | + range(19, 24), |
| 59 | + range(26, 31), |
| 60 | + range(33, 52), |
| 61 | + range(54, 56), |
| 62 | + ), |
| 63 | + ], |
| 64 | + ], |
| 65 | + 'traits' => [ |
| 66 | + 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\T' => [ |
| 67 | + $file => range(19, 24), |
| 68 | + ], |
| 69 | + ], |
| 70 | + 'classes' => [ |
| 71 | + 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ParentClass' => [ |
| 72 | + $file => range(26, 31), |
| 73 | + ], |
| 74 | + 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ChildClass' => [ |
| 75 | + $file => array_merge( |
| 76 | + range(33, 52), |
| 77 | + range(19, 24), |
| 78 | + ), |
| 79 | + ], |
| 80 | + ], |
| 81 | + 'classesThatExtendClass' => [ |
| 82 | + 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ParentClass' => [ |
| 83 | + $file => range(33, 52), |
| 84 | + ], |
| 85 | + ], |
| 86 | + 'classesThatImplementInterface' => [ |
| 87 | + 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\A' => [ |
| 88 | + $file => range(33, 52), |
| 89 | + ], |
| 90 | + 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\B' => [ |
| 91 | + $file => range(33, 52), |
| 92 | + ], |
| 93 | + 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\C' => [ |
| 94 | + $file => range(26, 31), |
| 95 | + ], |
| 96 | + ], |
| 97 | + 'methods' => [ |
| 98 | + 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\T::four' => [ |
| 99 | + $file => range(21, 23), |
| 100 | + ], |
| 101 | + 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ParentClass::five' => [ |
| 102 | + $file => range(28, 30), |
| 103 | + ], |
| 104 | + 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ChildClass::six' => [ |
| 105 | + $file => range(37, 39), |
| 106 | + ], |
| 107 | + 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ChildClass::one' => [ |
| 108 | + $file => range(41, 43), |
| 109 | + ], |
| 110 | + 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ChildClass::two' => [ |
| 111 | + $file => range(45, 47), |
| 112 | + ], |
| 113 | + 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ChildClass::three' => [ |
| 114 | + $file => range(49, 51), |
| 115 | + ], |
| 116 | + ], |
| 117 | + 'functions' => [ |
| 118 | + 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\f' => [ |
| 119 | + $file => range(54, 56), |
| 120 | + ], |
| 121 | + ], |
| 122 | + 'reverseLookup' => [ |
| 123 | + $file . ':21' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\T::four', |
| 124 | + $file . ':22' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\T::four', |
| 125 | + $file . ':23' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\T::four', |
| 126 | + $file . ':28' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ParentClass::five', |
| 127 | + $file . ':29' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ParentClass::five', |
| 128 | + $file . ':30' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ParentClass::five', |
| 129 | + $file . ':37' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::six', |
| 130 | + $file . ':38' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::six', |
| 131 | + $file . ':39' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::six', |
| 132 | + $file . ':41' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::one', |
| 133 | + $file . ':42' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::one', |
| 134 | + $file . ':43' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::one', |
| 135 | + $file . ':45' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::two', |
| 136 | + $file . ':46' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::two', |
| 137 | + $file . ':47' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::two', |
| 138 | + $file . ':49' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::three', |
| 139 | + $file . ':50' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::three', |
| 140 | + $file . ':51' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::three', |
| 141 | + $file . ':54' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\f', |
| 142 | + $file . ':55' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\f', |
| 143 | + $file . ':56' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\f', |
87 | 144 | ], |
88 | | - 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\C' => [ |
89 | | - $file => range(26, 31), |
90 | | - ], |
91 | | - ], |
92 | | - 'methods' => [ |
93 | | - 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\T::four' => [ |
94 | | - $file => range(21, 23), |
95 | | - ], |
96 | | - 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ParentClass::five' => [ |
97 | | - $file => range(28, 30), |
98 | | - ], |
99 | | - 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ChildClass::six' => [ |
100 | | - $file => range(37, 39), |
101 | | - ], |
102 | | - 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ChildClass::one' => [ |
103 | | - $file => range(41, 43), |
104 | | - ], |
105 | | - 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ChildClass::two' => [ |
106 | | - $file => range(45, 47), |
107 | | - ], |
108 | | - 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\ChildClass::three' => [ |
109 | | - $file => range(49, 51), |
110 | | - ], |
111 | | - ], |
112 | | - 'functions' => [ |
113 | | - 'SebastianBergmann\\CodeCoverage\\StaticAnalysis\\f' => [ |
114 | | - $file => range(54, 56), |
115 | | - ], |
116 | | - ], |
117 | | - 'reverseLookup' => [ |
118 | | - $file . ':21' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\T::four', |
119 | | - $file . ':22' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\T::four', |
120 | | - $file . ':23' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\T::four', |
121 | | - $file . ':28' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ParentClass::five', |
122 | | - $file . ':29' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ParentClass::five', |
123 | | - $file . ':30' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ParentClass::five', |
124 | | - $file . ':37' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::six', |
125 | | - $file . ':38' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::six', |
126 | | - $file . ':39' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::six', |
127 | | - $file . ':41' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::one', |
128 | | - $file . ':42' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::one', |
129 | | - $file . ':43' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::one', |
130 | | - $file . ':45' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::two', |
131 | | - $file . ':46' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::two', |
132 | | - $file . ':47' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::two', |
133 | | - $file . ':49' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::three', |
134 | | - $file . ':50' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::three', |
135 | | - $file . ':51' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\ChildClass::three', |
136 | | - $file . ':54' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\f', |
137 | | - $file . ':55' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\f', |
138 | | - $file . ':56' => 'SebastianBergmann\CodeCoverage\StaticAnalysis\f', |
139 | 145 | ], |
| 146 | + [$file], |
140 | 147 | ], |
141 | | - $this->map([__DIR__ . '/../../_files/source_with_interfaces_classes_traits_functions.php']), |
142 | | - ); |
| 148 | + ]; |
| 149 | + } |
| 150 | + |
| 151 | + #[DataProvider('provider')] |
| 152 | + public function testBuildsMap(array $expected, array $files): void |
| 153 | + { |
| 154 | + $this->assertSame($expected, $this->map($files)); |
143 | 155 | } |
144 | 156 |
|
145 | 157 | /** |
|
0 commit comments