Example #1
0
 public function testJsonResponseWithCustomStatusCode()
 {
     $container = new Container();
     $controller = new Controller($this->request, $this->response);
     $controller->setContainer($container);
     $response = $controller->jsonResponse(["status" => "error"], 400);
     $this->assertEquals(400, $response->getStatusCode());
     $this->assertContains("application/json", $response->getHeader("Content-Type"));
     $json = json_encode(["status" => "error"], JSON_UNESCAPED_UNICODE);
     $this->assertEquals($json, (string) $response->getBody());
 }