1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the DoyoUserBundle 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
|
|
|
/* |
15
|
|
|
* This file is part of the doyo/behat-code-coverage project. |
16
|
|
|
* |
17
|
|
|
* (c) Anthonius Munthi <[email protected]> |
18
|
|
|
* |
19
|
|
|
* For the full copyright and license information, please view the LICENSE |
20
|
|
|
* file that was distributed with this source code. |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
namespace Doyo\Behat\Coverage\Controller\Cli; |
24
|
|
|
|
25
|
|
|
use Behat\Testwork\Cli\Controller; |
26
|
|
|
use Doyo\Behat\Coverage\Event\ReportEvent; |
27
|
|
|
use Symfony\Component\Console\Command\Command; |
28
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
29
|
|
|
use Symfony\Component\Console\Input\InputOption; |
30
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
31
|
|
|
use Symfony\Component\Console\Style\StyleInterface; |
32
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Code Coverage Cli Controller. |
36
|
|
|
* |
37
|
|
|
* @author Anthonius Munthi <[email protected]> |
38
|
|
|
*/ |
39
|
|
|
class CoverageController implements Controller, EventSubscriberInterface |
40
|
|
|
{ |
41
|
|
|
/** |
42
|
|
|
* @var StyleInterface|null |
43
|
|
|
*/ |
44
|
|
|
private $style; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* CoverageController constructor. |
48
|
|
|
* |
49
|
|
|
* @param StyleInterface|null $style |
50
|
|
|
*/ |
51
|
4 |
|
public function __construct(StyleInterface $style) |
52
|
|
|
{ |
53
|
4 |
|
$this->style = $style; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritdoc} |
58
|
|
|
*/ |
59
|
|
|
public function configure(Command $command) |
60
|
|
|
{ |
61
|
|
|
$command->addOption('coverage', null, InputOption::VALUE_NONE, 'Collecting code coverage'); |
62
|
|
|
} |
63
|
|
|
|
64
|
2 |
|
public static function getSubscribedEvents() |
65
|
|
|
{ |
66
|
|
|
return [ |
67
|
2 |
|
ReportEvent::BEFORE_PROCESS => 'onBeforeReportProcess', |
68
|
|
|
ReportEvent::AFTER_PROCESS => 'onAfterReportProcess', |
69
|
|
|
]; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* {@inheritdoc} |
74
|
|
|
*/ |
75
|
|
|
public function execute(InputInterface $input, OutputInterface $output) |
76
|
|
|
{ |
77
|
|
|
if ($input->hasParameterOption(['--coverage'])) { |
78
|
|
|
$this->style->note('Running with code coverage'); |
|
|
|
|
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
1 |
|
public function onBeforeReportProcess(ReportEvent $event) |
83
|
|
|
{ |
84
|
1 |
|
$io = $this->style; |
85
|
1 |
|
$io->section('behat coverage reports process started'); |
|
|
|
|
86
|
1 |
|
$event->setIO($io); |
|
|
|
|
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function onAfterReportProcess(ReportEvent $event) |
90
|
|
|
{ |
91
|
|
|
$exceptions = $event->getExceptions(); |
92
|
|
|
$io = $event->getIO(); |
93
|
|
|
if(0 === count($exceptions)){ |
94
|
|
|
$this->style->success('behat coverage reports process completed'); |
95
|
|
|
return; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
$io->newLine(2); |
99
|
|
|
$io->section('behat coverage reports process failed'); |
100
|
|
|
foreach($exceptions as $exception){ |
101
|
|
|
$io->error($exception->getMessage()); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.