|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PhpGitHooks\Application\PhpUnit; |
|
4
|
|
|
|
|
5
|
|
|
use PhpGitHooks\Application\Message\MessageConfigData; |
|
6
|
|
|
use PhpGitHooks\Command\BadJobLogo; |
|
7
|
|
|
use PhpGitHooks\Command\OutputHandlerInterface; |
|
8
|
|
|
use PhpGitHooks\Infrastructure\Common\ProcessBuilderInterface; |
|
9
|
|
|
use PhpGitHooks\Infrastructure\Common\ToolHandler; |
|
10
|
|
|
use PhpGitHooks\Infrastructure\PhpUnit\PhpUnitProcessBuilder; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class PhpUnitHandler. |
|
14
|
|
|
*/ |
|
15
|
|
|
class PhpUnitHandler extends ToolHandler |
|
16
|
|
|
{ |
|
17
|
|
|
/** @var PhpUnitProcessBuilder */ |
|
18
|
|
|
private $phpUnitProcessBuilder; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @param OutputHandlerInterface $outputHandler |
|
22
|
|
|
* @param ProcessBuilderInterface $processBuilderInterface |
|
23
|
|
|
*/ |
|
24
|
4 |
|
public function __construct(OutputHandlerInterface $outputHandler, ProcessBuilderInterface $processBuilderInterface) |
|
25
|
|
|
{ |
|
26
|
4 |
|
parent::__construct($outputHandler); |
|
27
|
|
|
|
|
28
|
4 |
|
$this->phpUnitProcessBuilder = $processBuilderInterface; |
|
|
|
|
|
|
29
|
4 |
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param array $messages |
|
33
|
|
|
* |
|
34
|
|
|
* @throws UnitTestsException |
|
35
|
|
|
*/ |
|
36
|
3 |
|
public function run(array $messages) |
|
37
|
|
|
{ |
|
38
|
3 |
|
$this->setTitle(); |
|
39
|
|
|
|
|
40
|
3 |
|
$processBuilder = $this->phpUnitProcessBuilder->getProcessBuilder(); |
|
41
|
3 |
|
$processBuilder->setTimeout(3600); |
|
42
|
3 |
|
$phpunit = $processBuilder->getProcess(); |
|
43
|
3 |
|
$this->phpUnitProcessBuilder |
|
44
|
3 |
|
->executeProcess($phpunit, $this->output); |
|
45
|
|
|
|
|
46
|
3 |
|
if (!$phpunit->isSuccessful()) { |
|
47
|
1 |
|
$this->output->writeln(BadJobLogo::paint($messages[MessageConfigData::KEY_ERROR_MESSAGE])); |
|
48
|
1 |
|
throw new UnitTestsException(); |
|
49
|
|
|
} |
|
50
|
2 |
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param $suite |
|
54
|
|
|
*/ |
|
55
|
1 |
|
public function setSuite($suite) |
|
56
|
|
|
{ |
|
57
|
1 |
|
$this->phpUnitProcessBuilder->setSuite($suite); |
|
58
|
1 |
|
} |
|
59
|
|
|
|
|
60
|
3 |
|
private function setTitle() |
|
61
|
|
|
{ |
|
62
|
3 |
|
$this->outputHandler->setTitle('Running unit tests'); |
|
63
|
3 |
|
$this->output->write($this->outputHandler->getTitle()); |
|
64
|
3 |
|
$this->output->writeln($this->outputHandler->getSuccessfulStepMessage('Executing')); |
|
65
|
3 |
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.