|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OckCyp\CoversValidator\Model; |
|
4
|
|
|
|
|
5
|
|
|
use PHPUnit\Runner\Version; |
|
6
|
|
|
use PHPUnit\Util\Configuration as PHPUnit8Configuration; |
|
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
class TestCollection implements \Iterator |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @var \Iterator |
|
12
|
|
|
*/ |
|
13
|
|
|
private $iterator; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @var \Iterator |
|
17
|
|
|
*/ |
|
18
|
|
|
private $iteratorIterator; |
|
19
|
|
|
|
|
20
|
|
|
public function __construct(ConfigurationHolder $configurationHolder) |
|
21
|
|
|
{ |
|
22
|
|
|
$configuration = $configurationHolder->getConfiguration(); |
|
23
|
|
|
|
|
24
|
|
|
// @codeCoverageIgnoreStart |
|
25
|
|
|
if ((int) Version::series() < 10) { |
|
26
|
|
|
if ($configuration instanceof PHPUnit8Configuration) { |
|
27
|
|
|
$this->iterator = $configuration->getTestSuiteConfiguration(); |
|
|
|
|
|
|
28
|
|
|
} elseif (class_exists('PHPUnit\TextUI\Configuration\TestSuiteMapper')) { |
|
29
|
|
|
// PHPUnit < 9.3 |
|
30
|
|
|
$testSuiteMapper = new \PHPUnit\TextUI\Configuration\TestSuiteMapper(); |
|
|
|
|
|
|
31
|
|
|
$this->iterator = $testSuiteMapper->map($configuration->testSuite(), ''); |
|
32
|
|
|
} elseif (class_exists('PHPUnit\TextUI\XmlConfiguration\TestSuiteMapper')) { |
|
33
|
|
|
// PHPUnit 9.3, 9.4 |
|
34
|
|
|
$testSuiteMapper = new \PHPUnit\TextUI\XmlConfiguration\TestSuiteMapper(); |
|
|
|
|
|
|
35
|
|
|
$this->iterator = $testSuiteMapper->map($configuration->testSuite(), ''); |
|
36
|
|
|
} elseif (class_exists('PHPUnit\TextUI\TestSuiteMapper')) { |
|
37
|
|
|
// PHPUnit 9.5, 9.6 |
|
38
|
|
|
$testSuiteMapper = new \PHPUnit\TextUI\TestSuiteMapper(); |
|
39
|
|
|
$this->iterator = $testSuiteMapper->map($configuration->testSuite(), ''); |
|
|
|
|
|
|
40
|
|
|
} |
|
41
|
|
|
// @codeCoverageIgnoreEnd |
|
42
|
|
|
} else { |
|
43
|
|
|
// PHPUnit >= 10.0: same name as PHPUnit 9.3, but map() takes different args. |
|
44
|
|
|
if (class_exists('PHPUnit\TextUI\XmlConfiguration\TestSuiteMapper')) { |
|
45
|
|
|
$testSuiteMapper = new \PHPUnit\TextUI\XmlConfiguration\TestSuiteMapper(); |
|
46
|
|
|
|
|
47
|
|
|
// TestSuiteMapper eventually calls TestBuilder->configureTestCase, |
|
48
|
|
|
// which requires the ConfigurationRegistry singleton to be populated. |
|
49
|
|
|
\PHPUnit\TextUI\Configuration\Registry::init( |
|
|
|
|
|
|
50
|
|
|
(new \PHPUnit\TextUI\CliArguments\Builder())->fromParameters([]), |
|
|
|
|
|
|
51
|
|
|
$configuration |
|
52
|
|
|
); |
|
53
|
|
|
$this->iterator = $testSuiteMapper->map($configurationHolder->getFilename(), $configuration->testSuite(), '', ''); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
if (!$this->iterator) { |
|
58
|
|
|
throw new \RuntimeException('Could not find PHPUnit TestSuiteMapper class'); // @codeCoverageIgnore |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
$this->iteratorIterator = new \RecursiveIteratorIterator($this->iterator); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
#[\ReturnTypeWillChange] |
|
65
|
|
|
public function current() |
|
66
|
|
|
{ |
|
67
|
|
|
return $this->iteratorIterator->current(); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
#[\ReturnTypeWillChange] |
|
71
|
|
|
public function key() |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->iteratorIterator->key(); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function next(): void |
|
77
|
|
|
{ |
|
78
|
|
|
$this->iteratorIterator->next(); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function rewind(): void |
|
82
|
|
|
{ |
|
83
|
|
|
$this->iteratorIterator->rewind(); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function valid(): bool |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->iteratorIterator->valid(); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
public function isEmpty(): bool |
|
92
|
|
|
{ |
|
93
|
|
|
return !\count($this->iterator); |
|
|
|
|
|
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths