Repository navigation
Expand file tree
/
Copy pathSuiteSubscriber.php
More file actions
82 lines (67 loc) · 2.21 KB
/
Copy pathSuiteSubscriber.php
File metadata and controls
82 lines (67 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
namespace Codeception\Coverage;
use Codeception\Configuration;
use Codeception\Coverage\Subscriber\Printer;
use Codeception\Coverage\DummyCodeCoverage;
use Codeception\Subscriber\Shared\StaticEvents;
use Codeception\Lib\Interfaces\Remote;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
abstract class SuiteSubscriber implements EventSubscriberInterface {
use StaticEvents;
protected $defaultSettings = [
'enabled' => true,
'remote' => false,
'local' => false,
'xdebug_session' => 'codeception',
'remote_config' => null
];
protected $settings = [];
protected $coverage;
protected $logDir;
protected $options;
static $events = [];
abstract protected function isEnabled();
function __construct($options = [])
{
$this->options = $options;
$this->logDir = Configuration::logDir();
}
protected function applySettings($settings)
{
if (!function_exists('xdebug_is_enabled')) {
throw new \Exception('XDebug is required to collect CodeCoverage. Please install xdebug extension and enable it in php.ini');
}
$this->coverage = new \PHP_CodeCoverage();
$this->settings = $this->defaultSettings;
$keys = array_keys($this->defaultSettings);
foreach ($keys as $key) {
if (isset($settings['coverage'][$key])) {
$this->settings[$key] = $settings['coverage'][$key];
}
}
}
/**
* @return \Codeception\Lib\Interfaces\Remote|null
*/
protected function getServerConnectionModule()
{
foreach (\Codeception\SuiteManager::$modules as $module) {
if ($module instanceof Remote) {
return $module;
}
}
return null;
}
public function applyFilter(\PHPUnit_Framework_TestResult $result)
{
$result->setCodeCoverage(new DummyCodeCoverage());
Filter::setup($this->coverage)
->whiteList($this->settings)
->blackList($this->settings);
$result->setCodeCoverage($this->coverage);
}
protected function mergeToPrint($coverage)
{
Printer::$coverage->merge($coverage);
}
}