1 | <?php |
||
26 | abstract class AbstractSelfTest |
||
27 | { |
||
28 | /** |
||
29 | * The detailed message of the test result. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | private $message; |
||
34 | |||
35 | /** |
||
36 | * The optional message that might shed some light on any problem that occurred. |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | private $explain; |
||
41 | |||
42 | /** |
||
43 | * The test result state. |
||
44 | * |
||
45 | * @var string |
||
46 | * |
||
47 | * @see TestResult::STATE_SUCCESS, TestResult::STATE_FAIL, TestResult::STATE_SKIPPED. |
||
48 | */ |
||
49 | private $state; |
||
50 | |||
51 | /** |
||
52 | * The auto config the test shall write to. |
||
53 | * |
||
54 | * @var AutoConfig |
||
55 | */ |
||
56 | private $autoConfig; |
||
57 | |||
58 | /** |
||
59 | * Run the test and return the result. |
||
60 | * |
||
61 | * @param AutoConfig $autoConfig The auto config to write config values to. |
||
62 | * |
||
63 | * @return SelfTestResult |
||
64 | * |
||
65 | * @throws \RuntimeException When anything went wrong. |
||
66 | */ |
||
67 | public function perform(AutoConfig $autoConfig) |
||
84 | |||
85 | /** |
||
86 | * Retrieve autoConfig |
||
87 | * |
||
88 | * @return AutoConfig |
||
89 | */ |
||
90 | protected function getAutoConfig() |
||
94 | |||
95 | /** |
||
96 | * Any initialization code. |
||
97 | * |
||
98 | * @return void |
||
99 | */ |
||
100 | protected function prepare() |
||
104 | |||
105 | /** |
||
106 | * Any initialization code. |
||
107 | * |
||
108 | * @return void |
||
109 | */ |
||
110 | protected function finalize() |
||
114 | |||
115 | /** |
||
116 | * Run the test and return the result. |
||
117 | * |
||
118 | * @return void |
||
119 | */ |
||
120 | abstract protected function doTest(); |
||
121 | |||
122 | /** |
||
123 | * Mark this test as successful. |
||
124 | * |
||
125 | * @param string|null $explain An optional additional explanation. |
||
126 | * |
||
127 | * @return void |
||
128 | */ |
||
129 | protected function markSuccess($explain = null) |
||
136 | |||
137 | /** |
||
138 | * Mark this test as failing. |
||
139 | * |
||
140 | * @param string|null $explain An optional additional explanation. |
||
141 | * |
||
142 | * @return void |
||
143 | */ |
||
144 | protected function markFailed($explain = null) |
||
151 | |||
152 | /** |
||
153 | * Mark this test as skipped. |
||
154 | * |
||
155 | * @param string|null $explain An optional additional explanation. |
||
156 | * |
||
157 | * @return void |
||
158 | */ |
||
159 | protected function markSkipped($explain = null) |
||
166 | |||
167 | /** |
||
168 | * Mark this test as warning. |
||
169 | * |
||
170 | * @param string|null $explain An optional additional explanation. |
||
171 | * |
||
172 | * @return void |
||
173 | */ |
||
174 | protected function markWarning($explain = null) |
||
181 | |||
182 | /** |
||
183 | * Set the optional explanation. |
||
184 | * |
||
185 | * @param string $explain An optional additional explanation. |
||
186 | * |
||
187 | * @return void |
||
188 | */ |
||
189 | protected function setExplain($explain) |
||
193 | |||
194 | /** |
||
195 | * Set the description of the test. |
||
196 | * |
||
197 | * @param string $message The description message of this test. |
||
198 | * |
||
199 | * @return void |
||
200 | */ |
||
201 | protected function setMessage($message) |
||
205 | } |
||
206 |