100% of 414OPs |
100% of 56Lines |
89% of 19Branches |
92% of 12Paths |
Method | OPs | OPs % | Lines | Line % | Branches | Branches % | Paths | Path % |
---|---|---|---|---|---|---|---|---|
mageekguy\atoum\report\fields\runner\result\cli::__construct() | 22 | 100% | 6 | 100% | 1 | 0% | 1 | 100% |
mageekguy\atoum\report\fields\runner\result\cli::__toString() | 300 | 100% | 34 | 100% | 8 | 100% | 3 | 100% |
mageekguy\atoum\report\fields\runner\result\cli::setPrompt() | 16 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\report\fields\runner\result\cli::getPrompt() | 6 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\report\fields\runner\result\cli::setSuccessColorizer() | 16 | 100% | 3 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\report\fields\runner\result\cli::getSuccessColorizer() | 6 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\report\fields\runner\result\cli::setFailureColorizer() | 16 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\report\fields\runner\result\cli::getFailureColorizer() | 6 | 100% | 2 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\report\fields\runner\result\cli::handleEvent() | 26 | 96% | 5 | 100% | 4 | 75% | 2 | 50% |
# | |
---|---|
1 |
<?php |
2 |
|
3 |
namespace mageekguy\atoum\report\fields\runner\result; |
4 |
|
5 |
use |
6 |
mageekguy\atoum, |
7 |
mageekguy\atoum\cli\prompt, |
8 |
mageekguy\atoum\cli\colorizer, |
9 |
mageekguy\atoum\report\fields, |
10 |
mageekguy\atoum\observable |
11 |
; |
12 |
|
13 |
class cli extends fields\runner\result |
14 |
{ |
15 |
protected $observable = null; |
16 |
protected $prompt = null; |
17 |
protected $successColorizer = null; |
18 |
protected $failureColorizer = null; |
19 |
|
20 |
public function __construct()100% |
21 |
{ |
22 |
parent::__construct(); |
23 |
|
24 |
$this |
25 |
->setPrompt() |
26 |
->setSuccessColorizer() |
27 |
->setFailureColorizer() |
28 |
; |
29 |
} |
30 |
|
31 |
public function __toString()100% |
32 |
{ |
33 |
$string = $this->prompt; |
34 |
|
35 |
if ($this->testNumber === null) |
36 |
{ |
37 |
$string .= $this->locale->_('No test running.'); |
38 |
} |
39 |
else if ($this->success) |
40 |
{ |
41 |
$string .= $this->successColorizer->colorize( |
42 |
sprintf( |
43 |
$this->locale->_('Success (%s, %s, %s, %s, %s)!'), |
44 |
sprintf($this->locale->__('%s test', '%s tests', $this->testNumber), $this->testNumber), |
45 |
sprintf($this->locale->__('%s/%s method', '%s/%s methods', $this->testMethodNumber), $this->testMethodNumber - $this->voidMethodNumber - $this->skippedMethodNumber, $this->testMethodNumber), |
46 |
sprintf($this->locale->__('%s void method', '%s void methods', $this->voidMethodNumber), $this->voidMethodNumber), |
47 |
sprintf($this->locale->__('%s skipped method', '%s skipped methods', $this->skippedMethodNumber), $this->skippedMethodNumber), |
48 |
sprintf($this->locale->__('%s assertion', '%s assertions', $this->assertionNumber), $this->assertionNumber) |
49 |
) |
50 |
) |
51 |
; |
52 |
} |
53 |
else |
54 |
{ |
55 |
$string .= $this->failureColorizer->colorize( |
56 |
sprintf( |
57 |
$this->locale->_('Failure (%s, %s, %s, %s, %s, %s, %s, %s)!'), |
58 |
sprintf($this->locale->__('%s test', '%s tests', $this->testNumber), $this->testNumber), |
59 |
sprintf($this->locale->__('%s/%s method', '%s/%s methods', $this->testMethodNumber), $this->testMethodNumber - $this->voidMethodNumber - $this->skippedMethodNumber - $this->uncompletedMethodNumber, $this->testMethodNumber), |
60 |
sprintf($this->locale->__('%s void method', '%s void methods', $this->voidMethodNumber), $this->voidMethodNumber), |
61 |
sprintf($this->locale->__('%s skipped method', '%s skipped methods', $this->skippedMethodNumber), $this->skippedMethodNumber), |
62 |
sprintf($this->locale->__('%s uncompleted method', '%s uncompleted methods', $this->uncompletedMethodNumber), $this->uncompletedMethodNumber), |
63 |
sprintf($this->locale->__('%s failure', '%s failures', $this->failNumber), $this->failNumber), |
64 |
sprintf($this->locale->__('%s error', '%s errors', $this->errorNumber), $this->errorNumber), |
65 |
sprintf($this->locale->__('%s exception', '%s exceptions', $this->exceptionNumber), $this->exceptionNumber) |
66 |
) |
67 |
) |
68 |
; |
69 |
} |
70 |
|
71 |
return $string . PHP_EOL; |
72 |
} |
73 |
|
74 |
public function setPrompt(prompt $prompt = null)100% |
75 |
{ |
76 |
$this->prompt = $prompt ?: new prompt(); |
77 |
|
78 |
return $this; |
79 |
} |
80 |
|
81 |
public function getPrompt()100% |
82 |
{ |
83 |
return $this->prompt; |
84 |
} |
85 |
|
86 |
public function setSuccessColorizer(colorizer $colorizer = null)100% |
87 |
{ |
88 |
$this->successColorizer = $colorizer ?: new colorizer(); |
89 |
|
90 |
return $this; |
91 |
} |
92 |
|
93 |
public function getSuccessColorizer()100% |
94 |
{ |
95 |
return $this->successColorizer; |
96 |
} |
97 |
|
98 |
public function setFailureColorizer(colorizer $colorizer = null)100% |
99 |
{ |
100 |
$this->failureColorizer = $colorizer ?: new colorizer(); |
101 |
|
102 |
return $this; |
103 |
} |
104 |
|
105 |
public function getFailureColorizer()100% |
106 |
{ |
107 |
return $this->failureColorizer; |
108 |
} |
109 |
|
110 |
public function handleEvent($event, observable $observable)100% |
111 |
{ |
112 |
if (parent::handleEvent($event, $observable) === false) |
113 |
{ |
114 |
return false; |
115 |
} |
116 |
|
117 |
$this->observable = $observable; |
118 |
|
119 |
return true; |
120 |
} |
121 |
} |