|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Paraunit\Lifecycle; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
6
|
|
|
use Symfony\Component\EventDispatcher\Event; |
|
7
|
|
|
|
|
8
|
|
|
/*** |
|
9
|
|
|
* Class EngineEvent |
|
10
|
|
|
* @package Paraunit\Lifecycle |
|
11
|
|
|
*/ |
|
12
|
|
|
class EngineEvent extends Event |
|
13
|
|
|
{ |
|
14
|
|
|
// This Event will be triggered before the whole paraunit engine is started |
|
15
|
|
|
const BEFORE_START = 'engine_event.before_start'; |
|
16
|
|
|
|
|
17
|
|
|
// This Event will be triggered when paraunit finished building the process stack |
|
18
|
|
|
const START = 'engine_event.start'; |
|
19
|
|
|
|
|
20
|
|
|
// This Event will be triggered when paraunit finished all test execution |
|
21
|
|
|
const END = 'engine_event.end'; |
|
22
|
|
|
|
|
23
|
|
|
/** @var OutputInterface */ |
|
24
|
|
|
protected $outputInterface; |
|
25
|
|
|
|
|
26
|
|
|
/** @var array */ |
|
27
|
|
|
protected $context; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @param OutputInterface $outputInterface |
|
31
|
|
|
* @param array $context |
|
32
|
|
|
*/ |
|
33
|
9 |
|
public function __construct(OutputInterface $outputInterface, $context = array()) |
|
34
|
|
|
{ |
|
35
|
9 |
|
$this->outputInterface = $outputInterface; |
|
36
|
9 |
|
$this->context = $context; |
|
37
|
9 |
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @return OutputInterface |
|
41
|
|
|
*/ |
|
42
|
9 |
|
public function getOutputInterface() |
|
43
|
|
|
{ |
|
44
|
9 |
|
return $this->outputInterface; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @param $contextParameterName |
|
49
|
|
|
* |
|
50
|
|
|
* @return bool |
|
51
|
|
|
*/ |
|
52
|
9 |
|
public function has($contextParameterName) |
|
53
|
|
|
{ |
|
54
|
9 |
|
return isset($this->context[$contextParameterName]); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param $contextParameterName |
|
59
|
|
|
* |
|
60
|
|
|
* @return mixed |
|
61
|
|
|
*/ |
|
62
|
9 |
|
public function get($contextParameterName) |
|
63
|
|
|
{ |
|
64
|
9 |
|
if (!$this->has($contextParameterName)) { |
|
65
|
|
|
throw new \LogicException('Cannot find parameter: '.$contextParameterName); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
9 |
|
return $this->context[$contextParameterName]; |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|