76% of 331OPs |
100% of 57Lines |
77% of 30Branches |
75% of 20Paths |
# | |
---|---|
1 |
<?php |
2 |
|
3 |
namespace mageekguy\atoum\report\fields\runner\tests\uncompleted; |
4 |
|
5 |
use |
6 |
mageekguy\atoum, |
7 |
mageekguy\atoum\report, |
8 |
mageekguy\atoum\cli\prompt, |
9 |
mageekguy\atoum\cli\colorizer |
10 |
; |
11 |
|
12 |
class cli extends report\fields\runner\tests\uncompleted |
13 |
{ |
14 |
protected $titlePrompt = null; |
15 |
protected $titleColorizer = null; |
16 |
protected $methodPrompt = null; |
17 |
protected $methodColorizer = null; |
18 |
protected $outputPrompt = null; |
19 |
protected $outputColorizer = null; |
20 |
|
21 |
public function __construct()100% |
22 |
{ |
23 |
parent::__construct(); |
24 |
|
25 |
$this |
26 |
->setTitlePrompt() |
27 |
->setTitleColorizer() |
28 |
->setMethodPrompt() |
29 |
->setMethodColorizer() |
30 |
->setOutputPrompt() |
31 |
->setOutputColorizer() |
32 |
; |
33 |
} |
34 |
|
35 |
public function __toString()100% |
36 |
{ |
37 |
$string = ''; |
38 |
|
39 |
if ($this->runner !== null) |
40 |
{ |
41 |
$uncompletedMethods = $this->runner->getScore()->getUncompletedMethods(); |
42 |
|
43 |
$sizeOfUncompletedMethod = sizeof($uncompletedMethods); |
44 |
|
45 |
if ($sizeOfUncompletedMethod > 0) |
46 |
{ |
47 |
$string .= |
48 |
$this->titlePrompt . |
49 |
sprintf( |
50 |
$this->locale->_('%s:'), |
51 |
$this->titleColorizer->colorize(sprintf($this->locale->__('There is %d uncompleted method', 'There are %d uncompleted methods', $sizeOfUncompletedMethod), $sizeOfUncompletedMethod)) |
52 |
) . |
53 |
PHP_EOL |
54 |
; |
55 |
|
56 |
foreach ($uncompletedMethods as $uncompletedMethod) |
57 |
{ |
58 |
$string .= |
59 |
$this->methodPrompt . |
60 |
sprintf( |
61 |
$this->locale->_('%s:'), |
62 |
$this->methodColorizer->colorize(sprintf('%s::%s() with exit code %d', $uncompletedMethod['class'], $uncompletedMethod['method'], $uncompletedMethod['exitCode'])) |
63 |
) . |
64 |
PHP_EOL |
65 |
; |
66 |
|
67 |
$lines = explode(PHP_EOL, trim($uncompletedMethod['output'])); |
68 |
|
69 |
$string .= $this->outputPrompt . 'output(' . strlen($uncompletedMethod['output']) . ') "' . array_shift($lines); |
70 |
|
71 |
foreach ($lines as $line) |
72 |
{ |
73 |
$string .= PHP_EOL . $this->outputPrompt . $line; |
74 |
} |
75 |
|
76 |
$string .= '"' . PHP_EOL; |
77 |
} |
78 |
} |
79 |
} |
80 |
|
81 |
return $string; |
82 |
} |
83 |
|
84 |
public function setTitlePrompt(prompt $prompt = null)100% |
85 |
{ |
86 |
$this->titlePrompt = $prompt ?: new prompt(); |
87 |
|
88 |
return $this; |
89 |
} |
90 |
|
91 |
public function getTitlePrompt()100% |
92 |
{ |
93 |
return $this->titlePrompt; |
94 |
} |
95 |
|
96 |
public function setTitleColorizer(colorizer $colorizer = null)100% |
97 |
{ |
98 |
$this->titleColorizer = $colorizer ?: new colorizer(); |
99 |
|
100 |
return $this; |
101 |
} |
102 |
|
103 |
public function getTitleColorizer()100% |
104 |
{ |
105 |
return $this->titleColorizer; |
106 |
} |
107 |
|
108 |
public function setMethodPrompt(prompt $prompt = null)100% |
109 |
{ |
110 |
$this->methodPrompt = $prompt ?: new prompt(); |
111 |
|
112 |
return $this; |
113 |
} |
114 |
|
115 |
public function getMethodPrompt()100% |
116 |
{ |
117 |
return $this->methodPrompt; |
118 |
} |
119 |
|
120 |
public function setMethodColorizer(colorizer $colorizer = null)100% |
121 |
{ |
122 |
$this->methodColorizer = $colorizer ?: new colorizer(); |
123 |
|
124 |
return $this; |
125 |
} |
126 |
|
127 |
public function getMethodColorizer()100% |
128 |
{ |
129 |
return $this->methodColorizer; |
130 |
} |
131 |
|
132 |
public function setOutputPrompt(prompt $prompt = null)100% |
133 |
{ |
134 |
$this->outputPrompt = $prompt ?: new prompt(); |
135 |
|
136 |
return $this; |
137 |
} |
138 |
|
139 |
public function getOutputPrompt()100% |
140 |
{ |
141 |
return $this->outputPrompt; |
142 |
} |
143 |
|
144 |
public function setOutputColorizer(colorizer $colorizer = null)100% |
145 |
{ |
146 |
$this->outputColorizer = $colorizer ?: new colorizer(); |
147 |
|
148 |
return $this; |
149 |
} |
150 |
|
151 |
public function getOutputColorizer()100% |
152 |
{ |
153 |
return $this->outputColorizer; |
154 |
} |
155 |
} |