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
<?php
namespace Codeception\Coverage\Subscriber;
use Codeception\Coverage\SuiteSubscriber;
use Codeception\Event\SuiteEvent;
use Codeception\Events;
use Codeception\Lib\Interfaces\Remote;
/**
* Collects code coverage from unit and functional tests.
* Results from all suites are merged.
*/
class Local extends SuiteSubscriber
{
public static $events = [
Events::SUITE_BEFORE => 'beforeSuite',
Events::SUITE_AFTER => 'afterSuite',
];
/**
* @var Remote
*/
protected $module;
protected function isEnabled()
{
return $this->module === null and $this->settings['enabled'];
}
public function beforeSuite(SuiteEvent $e)
{
$this->applySettings($e->getSettings());
$this->module = $this->getServerConnectionModule($e->getSuite()->getModules());
if (!$this->isEnabled()) {
return;
}
$this->applyFilter($e->getResult());
}
public function afterSuite(SuiteEvent $e)
{
if (!$this->isEnabled()) {
return;
}
$this->mergeToPrint($e->getResult()->getCodeCoverage());
}
}