@@ 245-279 (lines=35) @@ | ||
242 | $this->assertSame($expectedOutput['echoed'], $this->klein_app->response()->body()); |
|
243 | } |
|
244 | ||
245 | public function testDispatchOutputPrepended() |
|
246 | { |
|
247 | $expectedOutput = array( |
|
248 | 'echoed' => 'yup', |
|
249 | 'returned' => 'nope', |
|
250 | 'echoed2' => 'sure', |
|
251 | ); |
|
252 | ||
253 | $this->klein_app->respond( |
|
254 | function () use ($expectedOutput) { |
|
255 | echo $expectedOutput['echoed']; |
|
256 | } |
|
257 | ); |
|
258 | $this->klein_app->respond( |
|
259 | function () use ($expectedOutput) { |
|
260 | return $expectedOutput['returned']; |
|
261 | } |
|
262 | ); |
|
263 | $this->klein_app->respond( |
|
264 | function () use ($expectedOutput) { |
|
265 | echo $expectedOutput['echoed2']; |
|
266 | } |
|
267 | ); |
|
268 | ||
269 | $this->klein_app->dispatch(null, null, false, Klein::DISPATCH_CAPTURE_AND_PREPEND); |
|
270 | ||
271 | // Make sure nothing actually printed to the screen |
|
272 | $this->expectOutputString(''); |
|
273 | ||
274 | // Make sure our response body matches what we echoed |
|
275 | $this->assertSame( |
|
276 | $expectedOutput['echoed'] . $expectedOutput['echoed2'] . $expectedOutput['returned'], |
|
277 | $this->klein_app->response()->body() |
|
278 | ); |
|
279 | } |
|
280 | ||
281 | public function testDispatchOutputAppended() |
|
282 | { |
|
@@ 281-315 (lines=35) @@ | ||
278 | ); |
|
279 | } |
|
280 | ||
281 | public function testDispatchOutputAppended() |
|
282 | { |
|
283 | $expectedOutput = array( |
|
284 | 'echoed' => 'yup', |
|
285 | 'returned' => 'nope', |
|
286 | 'echoed2' => 'sure', |
|
287 | ); |
|
288 | ||
289 | $this->klein_app->respond( |
|
290 | function () use ($expectedOutput) { |
|
291 | echo $expectedOutput['echoed']; |
|
292 | } |
|
293 | ); |
|
294 | $this->klein_app->respond( |
|
295 | function () use ($expectedOutput) { |
|
296 | return $expectedOutput['returned']; |
|
297 | } |
|
298 | ); |
|
299 | $this->klein_app->respond( |
|
300 | function () use ($expectedOutput) { |
|
301 | echo $expectedOutput['echoed2']; |
|
302 | } |
|
303 | ); |
|
304 | ||
305 | $this->klein_app->dispatch(null, null, false, Klein::DISPATCH_CAPTURE_AND_APPEND); |
|
306 | ||
307 | // Make sure nothing actually printed to the screen |
|
308 | $this->expectOutputString(''); |
|
309 | ||
310 | // Make sure our response body matches what we echoed |
|
311 | $this->assertSame( |
|
312 | $expectedOutput['returned'] . $expectedOutput['echoed'] . $expectedOutput['echoed2'], |
|
313 | $this->klein_app->response()->body() |
|
314 | ); |
|
315 | } |
|
316 | ||
317 | public function testDispatchResponseReplaced() |
|
318 | { |