Skip to content

Commit 4f8a0e2

Browse files
Reorganize test fixture
1 parent d62c45a commit 4f8a0e2

File tree

3 files changed

+73
-59
lines changed

3 files changed

+73
-59
lines changed

tests/_files/CoveredClass.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,6 @@
99
*/
1010
namespace PHPUnit\TestFixture;
1111

12-
class CoveredParentClass
13-
{
14-
public function publicMethod(): void
15-
{
16-
$this->protectedMethod();
17-
}
18-
19-
protected function protectedMethod(): void
20-
{
21-
$this->privateMethod();
22-
}
23-
24-
private function privateMethod(): void
25-
{
26-
}
27-
}
28-
2912
final class CoveredClass extends CoveredParentClass
3013
{
3114
public function publicMethod(): void

tests/_files/CoveredParentClass.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture;
11+
12+
class CoveredParentClass
13+
{
14+
public function publicMethod(): void
15+
{
16+
$this->protectedMethod();
17+
}
18+
19+
protected function protectedMethod(): void
20+
{
21+
$this->privateMethod();
22+
}
23+
24+
private function privateMethod(): void
25+
{
26+
}
27+
}

tests/unit/Metadata/Api/CodeCoverageTest.php

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -65,73 +65,83 @@ public static function linesToBeCoveredProvider(): array
6565

6666
[
6767
[
68-
TEST_FILES_PATH . 'CoveredClass.php' => array_merge(range(12, 27), range(29, 46)),
68+
TEST_FILES_PATH . 'CoveredClass.php' => array_merge(range(12, 29)),
69+
TEST_FILES_PATH . 'CoveredParentClass.php' => array_merge(range(12, 27)),
6970
],
7071
CoverageClassTest::class,
7172
'testSomething',
7273
],
7374

7475
[
7576
[
76-
TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35),
77+
TEST_FILES_PATH . 'CoveredClass.php' => range(14, 18),
7778
],
7879
CoverageMethodTest::class,
7980
'testSomething',
8081
],
8182

8283
[
8384
[
84-
TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35),
85+
TEST_FILES_PATH . 'CoveredClass.php' => range(14, 18),
8586
],
8687
CoverageMethodAnnotationTest::class,
8788
'testSomething',
8889
],
8990

9091
[
9192
[
92-
TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35),
93+
TEST_FILES_PATH . 'CoveredClass.php' => range(14, 18),
9394
],
9495
CoverageMethodOneLineAnnotationTest::class,
9596
'testSomething',
9697
],
9798

9899
[
99100
[
100-
TEST_FILES_PATH . 'CoveredFunction.php' => range(10, 12),
101+
TEST_FILES_PATH . 'CoveredClass.php' => range(12, 29),
101102
],
102-
CoverageFunctionTest::class,
103+
NamespaceCoverageClassTest::class,
103104
'testSomething',
104105
],
105106

106107
[
107108
[
108-
TEST_FILES_PATH . 'CoveredClass.php' => range(29, 46),
109+
TEST_FILES_PATH . 'CoveredClass.php' => range(14, 18),
109110
],
110-
NamespaceCoverageClassTest::class,
111+
NamespaceCoverageMethodTest::class,
111112
'testSomething',
112113
],
113114

114115
[
115116
[
116-
TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35),
117+
TEST_FILES_PATH . 'CoveredClass.php' => array_merge(range(14, 18), range(20, 24), range(26, 28)),
118+
TEST_FILES_PATH . 'CoveredParentClass.php' => array_merge(range(14, 17), range(19, 22), range(24, 26)),
117119
],
118-
NamespaceCoverageMethodTest::class,
120+
NamespaceCoverageCoversClassTest::class,
119121
'testSomething',
120122
],
121123

122124
[
123125
[
124-
TEST_FILES_PATH . 'CoveredClass.php' => array_merge(range(43, 45), range(37, 41), range(31, 35), range(24, 26), range(19, 22), range(14, 17)),
126+
TEST_FILES_PATH . 'CoveredClass.php' => range(14, 18),
125127
],
126-
NamespaceCoverageCoversClassTest::class,
128+
NamespaceCoverageCoversClassPublicTest::class,
127129
'testSomething',
128130
],
129131

130132
[
131133
[
132-
TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35),
134+
TEST_FILES_PATH . 'CoveredClass.php' => range(14, 18),
133135
],
134-
NamespaceCoverageCoversClassPublicTest::class,
136+
CoverageMethodParenthesesTest::class,
137+
'testSomething',
138+
],
139+
140+
[
141+
[
142+
TEST_FILES_PATH . 'CoveredClass.php' => range(14, 18),
143+
],
144+
CoverageMethodParenthesesWhitespaceTest::class,
135145
'testSomething',
136146
],
137147

@@ -149,7 +159,7 @@ public static function linesToBeCoveredProvider(): array
149159

150160
[
151161
[
152-
TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35),
162+
TEST_FILES_PATH . 'CoveredClass.php' => range(14, 18),
153163
],
154164
CoverageCoversOverridesCoversNothingTest::class,
155165
'testSomething',
@@ -165,31 +175,23 @@ public static function linesToBeCoveredProvider(): array
165175
[
166176
TEST_FILES_PATH . 'CoveredFunction.php' => range(10, 12),
167177
],
168-
CoverageFunctionParenthesesTest::class,
178+
CoverageFunctionTest::class,
169179
'testSomething',
170180
],
171181

172182
[
173183
[
174184
TEST_FILES_PATH . 'CoveredFunction.php' => range(10, 12),
175185
],
176-
CoverageFunctionParenthesesWhitespaceTest::class,
177-
'testSomething',
178-
],
179-
180-
[
181-
[
182-
TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35),
183-
],
184-
CoverageMethodParenthesesTest::class,
186+
CoverageFunctionParenthesesTest::class,
185187
'testSomething',
186188
],
187189

188190
[
189191
[
190-
TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35),
192+
TEST_FILES_PATH . 'CoveredFunction.php' => range(10, 12),
191193
],
192-
CoverageMethodParenthesesWhitespaceTest::class,
194+
CoverageFunctionParenthesesWhitespaceTest::class,
193195
'testSomething',
194196
],
195197

@@ -238,65 +240,67 @@ public static function linesToBeUsedProvider(): array
238240

239241
[
240242
[
241-
TEST_FILES_PATH . 'CoveredClass.php' => array_merge(range(12, 27), range(29, 46)),
243+
TEST_FILES_PATH . 'CoveredClass.php' => array_merge(range(12, 29)),
244+
TEST_FILES_PATH . 'CoveredParentClass.php' => array_merge(range(12, 27)),
242245
],
243246
CoverageClassTest::class,
244247
'testSomething',
245248
],
246249

247250
[
248251
[
249-
TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35),
252+
TEST_FILES_PATH . 'CoveredClass.php' => range(14, 18),
250253
],
251254
CoverageMethodTest::class,
252255
'testSomething',
253256
],
254257

255258
[
256259
[
257-
TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35),
260+
TEST_FILES_PATH . 'CoveredClass.php' => range(14, 18),
258261
],
259262
CoverageMethodAnnotationTest::class,
260263
'testSomething',
261264
],
262265

263266
[
264267
[
265-
TEST_FILES_PATH . 'CoveredFunction.php' => range(10, 12),
268+
TEST_FILES_PATH . 'CoveredClass.php' => range(12, 29),
266269
],
267-
CoverageFunctionTest::class,
270+
NamespaceCoverageClassTest::class,
268271
'testSomething',
269272
],
270273

271274
[
272275
[
273-
TEST_FILES_PATH . 'CoveredClass.php' => range(29, 46),
276+
TEST_FILES_PATH . 'CoveredClass.php' => range(14, 18),
274277
],
275-
NamespaceCoverageClassTest::class,
278+
NamespaceCoverageMethodTest::class,
276279
'testSomething',
277280
],
278281

279282
[
280283
[
281-
TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35),
284+
TEST_FILES_PATH . 'CoveredClass.php' => array_merge(range(14, 18), range(20, 24), range(26, 28)),
285+
TEST_FILES_PATH . 'CoveredParentClass.php' => array_merge(range(14, 17), range(19, 22), range(24, 26)),
282286
],
283-
NamespaceCoverageMethodTest::class,
287+
NamespaceCoverageCoversClassTest::class,
284288
'testSomething',
285289
],
286290

287291
[
288292
[
289-
TEST_FILES_PATH . 'CoveredClass.php' => array_merge(range(43, 45), range(37, 41), range(31, 35), range(24, 26), range(19, 22), range(14, 17)),
293+
TEST_FILES_PATH . 'CoveredClass.php' => range(14, 18),
290294
],
291-
NamespaceCoverageCoversClassTest::class,
295+
NamespaceCoverageCoversClassPublicTest::class,
292296
'testSomething',
293297
],
294298

295299
[
296300
[
297-
TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35),
301+
TEST_FILES_PATH . 'CoveredFunction.php' => range(10, 12),
298302
],
299-
NamespaceCoverageCoversClassPublicTest::class,
303+
CoverageFunctionTest::class,
300304
'testSomething',
301305
],
302306

@@ -318,15 +322,15 @@ public static function linesToBeUsedProvider(): array
318322

319323
[
320324
[
321-
TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35),
325+
TEST_FILES_PATH . 'CoveredClass.php' => range(14, 18),
322326
],
323327
CoverageMethodParenthesesTest::class,
324328
'testSomething',
325329
],
326330

327331
[
328332
[
329-
TEST_FILES_PATH . 'CoveredClass.php' => range(31, 35),
333+
TEST_FILES_PATH . 'CoveredClass.php' => range(14, 18),
330334
],
331335
CoverageMethodParenthesesWhitespaceTest::class,
332336
'testSomething',

0 commit comments

Comments
 (0)