1 | <?php |
||
8 | abstract class ParaunitProcessAbstract implements ParaunitProcessInterface, RetryAwareInterface, ProcessResultInterface |
||
9 | { |
||
10 | /** @var int */ |
||
11 | protected $retryCount = 0; |
||
12 | |||
13 | /** @var bool */ |
||
14 | protected $shouldBeRetried = false; |
||
15 | |||
16 | /** @var string */ |
||
17 | protected $uniqueId; |
||
18 | |||
19 | /** @var string */ |
||
20 | protected $filename; |
||
21 | |||
22 | /** @var string[] */ |
||
23 | protected $testResults; |
||
24 | |||
25 | /** @var bool */ |
||
26 | protected $abnormalTermination; |
||
27 | |||
28 | /** |
||
29 | * {@inheritdoc} |
||
30 | */ |
||
31 | 46 | public function __construct($commandLine, $uniqueId) |
|
32 | { |
||
33 | 46 | $this->uniqueId = $uniqueId; |
|
34 | |||
35 | 46 | $filename = array(); |
|
36 | 46 | if (preg_match('/[A-z]*\.php/', $commandLine, $filename) === 1) { |
|
37 | 8 | $this->filename = $filename[0]; |
|
38 | 8 | } |
|
39 | |||
40 | 46 | $this->testResults = array(); |
|
41 | 46 | $this->abnormalTermination = false; |
|
42 | 46 | } |
|
43 | |||
44 | /** |
||
45 | * @return string |
||
46 | */ |
||
47 | 17 | public function getUniqueId() |
|
48 | { |
||
49 | 17 | return $this->uniqueId; |
|
50 | } |
||
51 | |||
52 | /** |
||
53 | * @return int |
||
54 | */ |
||
55 | 8 | public function getRetryCount() |
|
56 | { |
||
57 | 8 | return $this->retryCount; |
|
58 | } |
||
59 | |||
60 | /** |
||
61 | */ |
||
62 | 4 | public function increaseRetryCount() |
|
63 | { |
||
64 | 4 | ++$this->retryCount; |
|
65 | 4 | } |
|
66 | |||
67 | /** |
||
68 | */ |
||
69 | 7 | public function markAsToBeRetried() |
|
70 | { |
||
71 | 7 | $this->shouldBeRetried = true; |
|
72 | 7 | } |
|
73 | |||
74 | /** |
||
75 | * @return bool |
||
76 | */ |
||
77 | 21 | public function isToBeRetried() |
|
78 | { |
||
79 | 21 | return $this->shouldBeRetried; |
|
80 | } |
||
81 | |||
82 | /** |
||
83 | * @return $this |
||
84 | */ |
||
85 | 3 | public function reset() |
|
86 | { |
||
87 | 3 | $this->shouldBeRetried = false; |
|
88 | 3 | } |
|
89 | |||
90 | /** |
||
91 | * @return string |
||
92 | */ |
||
93 | 19 | public function getFilename() |
|
94 | { |
||
95 | 19 | return $this->filename; |
|
96 | } |
||
97 | |||
98 | /** |
||
99 | * @return string[] |
||
100 | */ |
||
101 | 39 | public function getTestResults() |
|
102 | { |
||
103 | 39 | return $this->testResults; |
|
104 | } |
||
105 | |||
106 | /** |
||
107 | * @param string[] $testResults |
||
108 | */ |
||
109 | 6 | public function setTestResults(array $testResults) |
|
110 | { |
||
111 | 6 | $this->testResults = $testResults; |
|
112 | 6 | } |
|
113 | |||
114 | 25 | public function addTestResult($testResult) |
|
118 | |||
119 | /** |
||
120 | * @return bool |
||
121 | */ |
||
122 | 4 | public function hasAbnormalTermination() |
|
123 | { |
||
124 | 4 | return $this->abnormalTermination; |
|
125 | } |
||
126 | |||
127 | 6 | public function reportAbnormalTermination() |
|
128 | { |
||
129 | 6 | $this->abnormalTermination = true; |
|
131 | |||
132 | /** |
||
133 | * @return bool |
||
134 | * @deprecated |
||
135 | */ |
||
136 | public function isEmpty() |
||
140 | } |
||
141 |