|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the doyo/behat-coverage-extension project. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Anthonius Munthi <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace Doyo\Behat\Coverage\Bridge; |
|
15
|
|
|
|
|
16
|
|
|
use SebastianBergmann\CodeCoverage\CodeCoverage; |
|
17
|
|
|
use SebastianBergmann\CodeCoverage\Version; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Utility class to load driver by php-code-coverage version. |
|
21
|
|
|
*/ |
|
22
|
|
|
class Compat |
|
23
|
|
|
{ |
|
24
|
10 |
|
public static function getDriverClass($name) |
|
25
|
|
|
{ |
|
26
|
10 |
|
$namespace = 'Doyo\\Behat\\Coverage\\Bridge\\Driver\\'; |
|
27
|
10 |
|
if (version_compare(static::getVersion(), '6.0', '<')) { |
|
28
|
|
|
$namespace = $namespace.'Compat\\'; |
|
29
|
|
|
} |
|
30
|
10 |
|
$class = $namespace.$name; |
|
31
|
|
|
|
|
32
|
10 |
|
return $class; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
10 |
|
public static function getVersion() |
|
36
|
|
|
{ |
|
37
|
10 |
|
static $version; |
|
38
|
10 |
|
if (null === $version) { |
|
39
|
1 |
|
$version = Version::id(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
10 |
|
return $version; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public static function getCoverageValidConfigs() |
|
46
|
|
|
{ |
|
47
|
|
|
$r = new \ReflectionClass(CodeCoverage::class); |
|
48
|
|
|
$configs = []; |
|
49
|
|
|
$ignored = [ |
|
50
|
|
|
'data', |
|
51
|
|
|
'tests', |
|
52
|
|
|
'cachetokens', |
|
53
|
|
|
'maptestclassnametocoveredclassname', |
|
54
|
|
|
]; |
|
55
|
|
|
foreach ($r->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { |
|
56
|
|
|
$methodName = $method->getName(); |
|
57
|
|
|
if (false === strpos($methodName, 'set')) { |
|
58
|
|
|
continue; |
|
59
|
|
|
} |
|
60
|
|
|
$configName = substr($methodName, 3); |
|
61
|
|
|
$lower = strtolower($configName); |
|
62
|
|
|
if (\in_array($lower, $ignored, true)) { |
|
63
|
|
|
continue; |
|
64
|
|
|
} |
|
65
|
|
|
$defaults = $r->getDefaultProperties(); |
|
66
|
|
|
$configName = lcfirst($configName); |
|
67
|
|
|
$configs[$configName] = $defaults[$configName]; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
return $configs; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|