1 | <?php |
||
18 | class Module extends Framework |
||
19 | { |
||
20 | /** |
||
21 | * Required configuration fields |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $requiredFields = ['container']; |
||
25 | |||
26 | /** |
||
27 | * @var ContainerInterface |
||
28 | */ |
||
29 | public $container; |
||
30 | |||
31 | /** |
||
32 | * @var ServerRequestInterface |
||
33 | */ |
||
34 | public $baseRequest; |
||
35 | |||
36 | /** |
||
37 | * @var ResponseInterface |
||
38 | */ |
||
39 | public $baseResponse; |
||
40 | |||
41 | |||
42 | /** |
||
43 | * Load the container by including the file. |
||
44 | * @codeCoverageIgnore |
||
45 | * |
||
46 | * @param string $file |
||
47 | * @return ContainerInterface |
||
48 | */ |
||
49 | protected function loadContainer($file) |
||
53 | |||
54 | /** |
||
55 | * Get the container. |
||
56 | * |
||
57 | * @return ContainerInterface |
||
58 | */ |
||
59 | 3 | protected function initContainer() |
|
69 | |||
70 | /** |
||
71 | * Check if the response writes to the output buffer |
||
72 | * |
||
73 | * @return boolean |
||
74 | */ |
||
75 | 7 | protected function usesOutputBuffer() |
|
79 | |||
80 | /** |
||
81 | * Enable output buffering |
||
82 | * |
||
83 | * @throws \RuntimeException |
||
84 | */ |
||
85 | 2 | protected function startOutputBuffering() |
|
86 | { |
||
87 | 2 | if ($this->obGetLevel() === 0) { |
|
88 | 2 | $this->obStart(); |
|
89 | 2 | } |
|
90 | |||
91 | 2 | if ($this->obGetLevel() < 1) { |
|
92 | 1 | throw new \RuntimeException("Failed to start output buffering"); |
|
93 | } |
||
94 | 1 | } |
|
95 | |||
96 | /** |
||
97 | * Disable output buffering |
||
98 | */ |
||
99 | 1 | protected function stopOutputBuffering() |
|
103 | |||
104 | /** |
||
105 | * Initialize the module |
||
106 | */ |
||
107 | public function init() |
||
119 | 2 | ||
120 | /** |
||
121 | * Call before suite |
||
122 | * |
||
123 | * @param array $settings |
||
124 | */ |
||
125 | public function _beforeSuite($settings = []) |
||
133 | 3 | ||
134 | /** |
||
135 | * Call after suite |
||
136 | */ |
||
137 | public function _afterSuite() |
||
145 | 3 | ||
146 | /** |
||
147 | * Before each test |
||
148 | * |
||
149 | * @param TestInterface $test |
||
150 | */ |
||
151 | public function _before(TestInterface $test) |
||
168 | |||
169 | /** |
||
170 | * After each test |
||
171 | * |
||
172 | * @param TestInterface $test |
||
173 | */ |
||
174 | 3 | public function _after(TestInterface $test) |
|
194 | 3 | ||
195 | /** |
||
196 | * Called when test fails |
||
197 | * |
||
198 | * @param TestInterface $test |
||
199 | * @param mixed $fail |
||
200 | */ |
||
201 | public function _failed(TestInterface $test, $fail) |
||
214 | 1 | ||
215 | |||
216 | /** |
||
217 | * Wrapper around `ob_start()` |
||
218 | * @codeCoverageIgnore |
||
219 | */ |
||
220 | protected function obStart() |
||
224 | |||
225 | /** |
||
226 | * Wrapper around `ob_get_level()` |
||
227 | * @codeCoverageIgnore |
||
228 | * |
||
229 | * @return int |
||
230 | */ |
||
231 | protected function obGetLevel() |
||
235 | |||
236 | /** |
||
237 | * Wrapper around `ob_clean()` |
||
238 | * @codeCoverageIgnore |
||
239 | */ |
||
240 | protected function obClean() |
||
244 | |||
245 | /** |
||
246 | * Wrapper around `session_status()` |
||
247 | * @codeCoverageIgnore |
||
248 | * |
||
249 | * @return int |
||
250 | */ |
||
251 | protected function sessionStatus() |
||
255 | |||
256 | /** |
||
257 | * Wrapper around `session_unset()` and `session_destroy()` |
||
258 | * @codeCoverageIgnore |
||
259 | */ |
||
260 | protected function sessionDestroy() |
||
265 | } |
||
266 |