/** * @inheritDoc */ public function run() { $this->dispatch('core.app.run.pre', $this); $this->response = $response = $this->handle($this->getRequest()); if ($response instanceof View) { $this->response = $response = new Response($response->fetch()); } $response->send(); $this->terminate(); }
/** * @covers \Core\Response\Response::send * @runInSeparateProcess */ public function testSendWithContentAsArray() { $arr = ['test1' => 'val1', 'test2' => 'val2']; $response = new Response($arr); $response->send(); $headersList = xdebug_get_headers(); $statusCode = http_response_code(); $this->assertEquals(200, $statusCode); $this->assertContains('Connection: close', $headersList); $this->assertContains('Content-Type: application/json', $headersList); $this->assertJson(json_encode($arr), $response->getContent()); $this->expectOutputString("{\"test1\":\"val1\",\"test2\":\"val2\"}"); }