1 | <?php |
||
17 | class Module extends Framework |
||
18 | { |
||
19 | /** |
||
20 | * Required configuration fields |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $requiredFields = ['container']; |
||
24 | |||
25 | /** |
||
26 | * @var Router |
||
27 | */ |
||
28 | public $router; |
||
29 | |||
30 | /** |
||
31 | * @var ServerRequestInterface |
||
32 | */ |
||
33 | public $baseRequest; |
||
34 | |||
35 | /** |
||
36 | * @var ResponseInterface |
||
37 | */ |
||
38 | public $baseResponse; |
||
39 | |||
40 | |||
41 | /** |
||
42 | * Load the container by including the file. |
||
43 | * @codeCoverageIgnore |
||
44 | * |
||
45 | * @param string $file |
||
46 | * @return ContainerInterface |
||
47 | */ |
||
48 | protected function loadContainer($file) |
||
52 | |||
53 | /** |
||
54 | * Get the container. |
||
55 | * |
||
56 | * @return ContainerInterface |
||
57 | */ |
||
58 | 3 | protected function initContainer() |
|
68 | |||
69 | /** |
||
70 | * Check if the response writes to the output buffer |
||
71 | * |
||
72 | * @return boolean |
||
73 | */ |
||
74 | 7 | protected function usesOutputBuffer() |
|
78 | |||
79 | /** |
||
80 | * Enable output buffering |
||
81 | * |
||
82 | * @throws \RuntimeException |
||
83 | */ |
||
84 | 2 | protected function startOutputBuffering() |
|
94 | |||
95 | /** |
||
96 | * Disable output buffering |
||
97 | */ |
||
98 | 1 | protected function stopOutputBuffering() |
|
102 | |||
103 | |||
104 | /** |
||
105 | * Initialize the module |
||
106 | */ |
||
107 | 3 | public function _initialize() |
|
121 | |||
122 | /** |
||
123 | * Call before suite |
||
124 | * |
||
125 | * @param array $settings |
||
126 | */ |
||
127 | 4 | public function _beforeSuite($settings = []) |
|
135 | |||
136 | /** |
||
137 | * Call after suite |
||
138 | */ |
||
139 | 3 | public function _afterSuite() |
|
147 | |||
148 | /** |
||
149 | * Before each test |
||
150 | * |
||
151 | * @param TestInterface $test |
||
152 | */ |
||
153 | 4 | public function _before(TestInterface $test) |
|
168 | |||
169 | /** |
||
170 | * After each test |
||
171 | * |
||
172 | * @param TestInterface $test |
||
173 | */ |
||
174 | 3 | public function _after(TestInterface $test) |
|
175 | { |
||
176 | 3 | if ($this->sessionStatus() === PHP_SESSION_ACTIVE) { |
|
177 | 1 | $this->sessionAbort(); |
|
178 | 1 | } |
|
179 | |||
180 | 3 | if (isset($this->client) && $this->client instanceof Connector) { |
|
181 | 1 | $this->client->reset(); |
|
182 | |||
183 | 1 | if (isset($this->baseRequest)) { |
|
184 | 1 | $this->baseRequest = $this->client->getBaseRequest(); |
|
185 | 1 | } |
|
186 | |||
187 | 1 | if (isset($this->baseResponse)) { |
|
188 | 1 | $this->baseResponse = $this->client->getBaseResponse(); |
|
189 | 1 | } |
|
190 | 1 | } |
|
191 | |||
192 | |||
193 | 3 | parent::_after($test); |
|
194 | 3 | } |
|
195 | |||
196 | |||
197 | /** |
||
198 | * Wrapper around `ob_start()` |
||
199 | * @codeCoverageIgnore |
||
200 | */ |
||
201 | protected function obStart() |
||
205 | |||
206 | /** |
||
207 | * Wrapper around `ob_get_level()` |
||
208 | * @codeCoverageIgnore |
||
209 | * |
||
210 | * @return int |
||
211 | */ |
||
212 | protected function obGetLevel() |
||
216 | |||
217 | /** |
||
218 | * Wrapper around `ob_clean()` |
||
219 | * @codeCoverageIgnore |
||
220 | */ |
||
221 | protected function obClean() |
||
225 | |||
226 | /** |
||
227 | * Wrapper around `session_status()` |
||
228 | * @codeCoverageIgnore |
||
229 | * |
||
230 | * @return int |
||
231 | */ |
||
232 | protected function sessionStatus() |
||
236 | |||
237 | /** |
||
238 | * Wrapper around `session_abort()` |
||
239 | * @codeCoverageIgnore |
||
240 | */ |
||
241 | protected function sessionAbort() |
||
245 | } |
||
246 |