Beispiel #1
0
 public function testJsonOutputIsJsonEncoded()
 {
     $content = ['one' => true];
     $this->expectOutputString(json_encode($content));
     $this->res->setContentType(Response::JSON);
     $this->res->setContent($content);
     $this->res->sendContent();
 }
Beispiel #2
0
 /**
  * check a route's format property and updates the response's content type
  * @param Response & $res
  * @param string $format
  */
 private function setResponseContentType(Response &$res, $format)
 {
     switch ($format) {
         case 'txt':
             $res->setContentType(Response::TEXT);
             break;
         case 'json':
             $res->setContentType(Response::JSON);
             break;
         case 'html':
         default:
             $res->setContentType(Response::HTML);
             break;
     }
 }