96% of 919OPs |
98% of 165Lines |
94% of 47Branches |
13% of 214Paths |
# | |
---|---|
1 |
<?php |
2 | |
3 |
namespace mageekguy\atoum\reports\realtime; |
4 | |
5 |
use |
6 |
mageekguy\atoum, |
7 |
mageekguy\atoum\cli\prompt, |
8 |
mageekguy\atoum\cli\colorizer, |
9 |
mageekguy\atoum\reports\realtime, |
10 |
mageekguy\atoum\report\fields\test, |
11 |
mageekguy\atoum\report\fields\runner |
12 |
; |
13 | |
14 |
class phing extends realtime |
15 |
{ |
16 |
protected $showProgress = true; |
17 |
protected $showMissingCodeCoverage = true; |
18 |
protected $showDuration = true; |
19 |
protected $showMemory = true; |
20 |
protected $showCodeCoverage = true; |
21 |
protected $codeCoverageReportPath = null; |
22 |
protected $codeCoverageReportUrl = null; |
23 |
protected $codeCoverageReportProjectName = null; |
24 | |
25 |
public function __construct()100% |
26 |
{ |
27 |
parent::__construct(); |
28 | |
29 |
$this->build(); |
30 |
} |
31 | |
32 |
public function showProgress()100% |
33 |
{ |
34 |
$this->showProgress = true; |
35 | |
36 |
return $this->build(); |
37 |
} |
38 | |
39 |
public function hideProgress()100% |
40 |
{ |
41 |
$this->showProgress = false; |
42 | |
43 |
return $this->build(); |
44 |
} |
45 | |
46 |
public function progressIsShowed()100% |
47 |
{ |
48 |
return $this->showProgress; |
49 |
} |
50 | |
51 |
public function showCodeCoverage()100% |
52 |
{ |
53 |
$this->showCodeCoverage = true; |
54 | |
55 |
return $this->build(); |
56 |
} |
57 | |
58 |
public function hideCodeCoverage()100% |
59 |
{ |
60 |
$this->showCodeCoverage = false; |
61 | |
62 |
return $this->build(); |
63 |
} |
64 | |
65 |
public function codeCoverageIsShowed()100% |
66 |
{ |
67 |
return $this->showCodeCoverage; |
68 |
} |
69 | |
70 |
public function showMissingCodeCoverage()100% |
71 |
{ |
72 |
$this->showMissingCodeCoverage = true; |
73 | |
74 |
return $this->build(); |
75 |
} |
76 | |
77 |
public function hideMissingCodeCoverage()100% |
78 |
{ |
79 |
$this->showMissingCodeCoverage = false; |
80 | |
81 |
return $this->build(); |
82 |
} |
83 | |
84 |
public function missingCodeCoverageIsShowed()100% |
85 |
{ |
86 |
return $this->showMissingCodeCoverage; |
87 |
} |
88 | |
89 |
public function showDuration()100% |
90 |
{ |
91 |
$this->showDuration = true; |
92 | |
93 |
return $this->build(); |
94 |
} |
95 | |
96 |
public function hideDuration()100% |
97 |
{ |
98 |
$this->showDuration = false; |
99 | |
100 |
return $this->build(); |
101 |
} |
102 | |
103 |
public function durationIsShowed()100% |
104 |
{ |
105 |
return $this->showDuration; |
106 |
} |
107 | |
108 |
public function showMemory()100% |
109 |
{ |
110 |
$this->showMemory = true; |
111 | |
112 |
return $this->build(); |
113 |
} |
114 | |
115 |
public function hideMemory()100% |
116 |
{ |
117 |
$this->showMemory = false; |
118 | |
119 |
return $this->build(); |
120 |
} |
121 | |
122 |
public function memoryIsShowed()100% |
123 |
{ |
124 |
return $this->showMemory; |
125 |
} |
126 | |
127 |
public function setCodeCoverageReportPath($path = null)100% |
128 |
{ |
129 |
$this->codeCoverageReportPath = $path; |
130 | |
131 |
return $this; |
132 |
} |
133 | |
134 |
public function getCodeCoverageReportPath()100% |
135 |
{ |
136 |
return $this->codeCoverageReportPath; |
137 |
} |
138 | |
139 |
public function setCodeCoverageReportProjectName($url = null)100% |
140 |
{ |
141 |
$this->codeCoverageReportProjectName = $url; |
142 | |
143 |
return $this; |
144 |
} |
145 | |
146 |
public function getCodeCoverageReportProjectName()100% |
147 |
{ |
148 |
return $this->codeCoverageReportProjectName; |
149 |
} |
150 | |
151 |
public function setCodeCoverageReportUrl($url = null)100% |
152 |
{ |
153 |
$this->codeCoverageReportUrl = $url; |
154 | |
155 |
return $this; |
156 |
} |
157 | |
158 |
public function getCodeCoverageReportUrl()100% |
159 |
{ |
160 |
return $this->codeCoverageReportUrl; |
161 |
} |
162 | |
163 |
protected function build()97% |
164 |
{ |
165 |
$this->resetFields(); |
166 | |
167 |
$firstLevelPrompt = new prompt(PHP_EOL); |
168 |
$firstLevelColorizer = new colorizer('1;36'); |
169 | |
170 |
$secondLevelPrompt = new prompt(' ', $firstLevelColorizer); |
171 | |
172 |
$failureColorizer = new colorizer('0;31'); |
173 |
$failurePrompt = clone $secondLevelPrompt; |
174 |
$failurePrompt->setColorizer($failureColorizer); |
175 | |
176 |
$errorColorizer = new colorizer('0;33'); |
177 |
$errorPrompt = clone $secondLevelPrompt; |
178 |
$errorPrompt->setColorizer($errorColorizer); |
179 | |
180 |
$exceptionColorizer = new colorizer('0;35'); |
181 |
$exceptionPrompt = clone $secondLevelPrompt; |
182 |
$exceptionPrompt->setColorizer($exceptionColorizer); |
183 |
|
184 |
$uncompletedTestColorizer = new colorizer('0;37'); |
185 |
$uncompletedTestMethodPrompt = clone $secondLevelPrompt; |
186 |
$uncompletedTestMethodPrompt->setColorizer($uncompletedTestColorizer); |
187 |
$uncompletedTestOutputPrompt = new prompt(' ', $uncompletedTestColorizer); |
188 |
|
189 |
$voidTestColorizer = new colorizer('0;34'); |
190 |
$voidTestMethodPrompt = clone $secondLevelPrompt; |
191 |
$voidTestMethodPrompt->setColorizer($voidTestColorizer); |
192 | |
193 |
$skippedTestColorizer = new colorizer('0;90'); |
194 |
$skippedTestMethodPrompt = clone $secondLevelPrompt; |
195 |
$skippedTestMethodPrompt->setColorizer($skippedTestColorizer); |
196 | |
197 | |
198 |
$phpPathField = new runner\php\path\cli(); |
199 |
$phpPathField |
200 |
->setPrompt($firstLevelPrompt) |
201 |
->setTitleColorizer($firstLevelColorizer) |
202 |
; |
203 | |
204 |
$this->addField($phpPathField); |
205 | |
206 |
$phpVersionField = new runner\php\version\cli(); |
207 |
$phpVersionField |
208 |
->setTitlePrompt($firstLevelPrompt) |
209 |
->setTitleColorizer($firstLevelColorizer) |
210 |
->setVersionPrompt($secondLevelPrompt) |
211 |
; |
212 | |
213 |
$this->addField($phpVersionField); |
214 | |
215 |
if ($this->showDuration === true) |
216 |
{ |
217 |
$runnerDurationField = new runner\duration\cli(); |
218 |
$runnerDurationField |
219 |
->setPrompt($firstLevelPrompt) |
220 |
->setTitleColorizer($firstLevelColorizer) |
221 |
; |
222 | |
223 |
$this->addField($runnerDurationField); |
224 |
} |
225 | |
226 |
if ($this->showMemory === true) |
227 |
{ |
228 |
$runnerTestsMemoryField = new runner\tests\memory\phing(); |
229 |
$runnerTestsMemoryField |
230 |
->setPrompt($firstLevelPrompt) |
231 |
->setTitleColorizer($firstLevelColorizer) |
232 |
; |
233 | |
234 |
$this->addField($runnerTestsMemoryField); |
235 |
} |
236 | |
237 |
if ($this->showCodeCoverage === true) |
238 |
{ |
239 |
$runnerTestsCoverageField = new runner\tests\coverage\phing(); |
240 |
$runnerTestsCoverageField |
241 |
->setTitlePrompt($firstLevelPrompt) |
242 |
->setClassPrompt($secondLevelPrompt) |
243 |
->setMethodPrompt(new prompt(' ', $firstLevelColorizer)) |
244 |
->setTitleColorizer($firstLevelColorizer) |
245 |
; |
246 | |
247 |
if ($this->showMissingCodeCoverage === false) |
248 |
{ |
249 |
$runnerTestsCoverageField->hideMissingCodeCoverage(); |
250 |
} |
251 | |
252 |
$this->addField($runnerTestsCoverageField); |
253 |
} |
254 | |
255 |
$resultField = new runner\result\cli(); |
256 |
$resultField |
257 |
->setPrompt($firstLevelPrompt) |
258 |
->setSuccessColorizer(new colorizer('0;37', '42')) |
259 |
->setFailureColorizer(new colorizer('0;37', '41')) |
260 |
; |
261 | |
262 |
$this->addField($resultField); |
263 | |
264 |
$failuresField = new runner\failures\cli(); |
265 |
$failuresField |
266 |
->setTitlePrompt($firstLevelPrompt) |
267 |
->setTitleColorizer($failureColorizer) |
268 |
->setMethodPrompt($failurePrompt) |
269 |
; |
270 | |
271 |
$this->addField($failuresField); |
272 | |
273 |
$outputsField = new runner\outputs\cli(); |
274 |
$outputsField |
275 |
->setTitlePrompt($firstLevelPrompt) |
276 |
->setTitleColorizer($firstLevelColorizer) |
277 |
->setMethodPrompt($secondLevelPrompt) |
278 |
; |
279 | |
280 |
$this->addField($outputsField); |
281 | |
282 |
$errorsField = new runner\errors\cli(); |
283 |
$errorsField |
284 |
->setTitlePrompt($firstLevelPrompt) |
285 |
->setTitleColorizer($errorColorizer) |
286 |
->setMethodPrompt($errorPrompt) |
287 |
; |
288 | |
289 |
$this->addField($errorsField); |
290 | |
291 |
$exceptionsField = new runner\exceptions\cli(); |
292 |
$exceptionsField |
293 |
->setTitlePrompt($firstLevelPrompt) |
294 |
->setTitleColorizer($exceptionColorizer) |
295 |
->setMethodPrompt($exceptionPrompt) |
296 |
; |
297 | |
298 |
$this->addField($exceptionsField); |
299 | |
300 |
$runnerUncompletedField = new runner\tests\uncompleted\cli(); |
301 |
$runnerUncompletedField |
302 |
->setTitlePrompt($firstLevelPrompt) |
303 |
->setTitleColorizer($uncompletedTestColorizer) |
304 |
->setMethodPrompt($uncompletedTestMethodPrompt) |
305 |
->setOutputPrompt($uncompletedTestOutputPrompt) |
306 |
; |
307 | |
308 |
$this->addField($runnerUncompletedField); |
309 | |
310 |
$runnerVoidField = new runner\tests\void\cli(); |
311 |
$runnerVoidField |
312 |
->setTitlePrompt($firstLevelPrompt) |
313 |
->setTitleColorizer($voidTestColorizer) |
314 |
->setMethodPrompt($voidTestMethodPrompt) |
315 |
; |
316 | |
317 |
$this->addField($runnerVoidField); |
318 |
|
319 |
$runnerSkippedField = new runner\tests\skipped\cli(); |
320 |
$runnerSkippedField |
321 |
->setTitlePrompt($firstLevelPrompt) |
322 |
->setTitleColorizer($skippedTestColorizer) |
323 |
->setMethodPrompt($skippedTestMethodPrompt) |
324 |
; |
325 |
|
326 |
$this->addField($runnerSkippedField); |
327 | |
328 |
if ($this->showProgress === true) |
329 |
{ |
330 |
$runField = new test\run\phing(); |
331 |
$runField |
332 |
->setPrompt($firstLevelPrompt) |
333 |
->setColorizer($firstLevelColorizer) |
334 |
; |
335 | |
336 |
$this |
337 |
->addField($runField) |
338 |
->addField(new test\event\phing()) |
339 |
; |
340 |
} |
341 | |
342 |
if ($this->showDuration === true) |
343 |
{ |
344 |
$durationField = new test\duration\phing(); |
345 |
$durationField |
346 |
->setPrompt($secondLevelPrompt) |
347 |
; |
348 | |
349 |
$this->addField($durationField); |
350 |
} |
351 | |
352 |
if ($this->showMemory === true) |
353 |
{ |
354 |
$memoryField = new test\memory\phing(); |
355 |
$memoryField |
356 |
->setPrompt($secondLevelPrompt) |
357 |
; |
358 | |
359 |
$this->addField($memoryField); |
360 |
} |
361 | |
362 |
if ($this->codeCoverageReportPath !== null) |
363 |
{ |
364 |
$coverageField = new atoum\report\fields\runner\coverage\html($this->codeCoverageReportProjectName ?: '', $this->codeCoverageReportPath); |
365 |
$coverageField->setRootUrl($this->codeCoverageReportUrl ?: 'file:////' . realpath($this->codeCoverageReportPath)); |
366 | |
367 |
$this->addField($coverageField); |
368 |
} |
369 | |
370 |
return $this; |
371 |
} |
372 |
} |