|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OckCyp\CoversValidator\Loader; |
|
4
|
|
|
|
|
5
|
|
|
use OckCyp\CoversValidator\Model\ConfigurationHolder; |
|
6
|
|
|
use PHPUnit\Runner\Version; |
|
7
|
|
|
use PHPUnit\TextUI\Configuration\Loader as PHPUnit9ConfigurationLoader; |
|
|
|
|
|
|
8
|
|
|
use PHPUnit\TextUI\XmlConfiguration\Loader as PHPUnit10ConfigurationLoader; |
|
9
|
|
|
use PHPUnit\Util\Configuration as PHPUnit8Configuration; |
|
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
class ConfigLoader |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Load configuration from file |
|
15
|
|
|
*/ |
|
16
|
|
|
public static function loadConfig(string $fileName): ConfigurationHolder |
|
17
|
|
|
{ |
|
18
|
|
|
if ((int) Version::series() <= 8 && class_exists(PHPUnit8Configuration::class)) { |
|
19
|
|
|
// @codeCoverageIgnoreStart |
|
20
|
|
|
// PHPUnit 8.x |
|
21
|
|
|
$configuration = PHPUnit8Configuration::getInstance($fileName); |
|
22
|
|
|
$filename = $configuration->getFilename(); |
|
23
|
|
|
$phpunit = $configuration->getPHPUnitConfiguration(); |
|
24
|
|
|
$bootstrap = ''; |
|
25
|
|
|
if (isset($phpunit['bootstrap'])) { |
|
26
|
|
|
$bootstrap = $phpunit['bootstrap']; |
|
27
|
|
|
} |
|
28
|
|
|
} else { |
|
29
|
|
|
if (class_exists(PHPUnit9ConfigurationLoader::class)) { |
|
30
|
|
|
// PHPUnit < 9.3 |
|
31
|
|
|
$loader = new PHPUnit9ConfigurationLoader(); |
|
32
|
|
|
// @codeCoverageIgnoreEnd |
|
33
|
|
|
} elseif (class_exists(PHPUnit10ConfigurationLoader::class)) { |
|
34
|
|
|
// PHPUnit >= 9.3 |
|
35
|
|
|
$loader = new PHPUnit10ConfigurationLoader(); |
|
36
|
|
|
} else { |
|
37
|
|
|
throw new \RuntimeException('Could not find PHPUnit configuration loader class'); // @codeCoverageIgnore |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
$configuration = $loader->load($fileName); |
|
41
|
|
|
$filename = $configuration->filename(); |
|
42
|
|
|
$phpunit = $configuration->phpunit(); |
|
43
|
|
|
$bootstrap = $phpunit->hasBootstrap() ? $phpunit->bootstrap() : null; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
return new ConfigurationHolder($configuration, $filename, $bootstrap); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
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