{% for item in list %}
  • {{ item }}
  • {% endfor %} "; return $this->prepareResponse([ 'list' => [ 1, 2, 3 ]], $template); } }; $app = $this->getAppInstance(); $app->get('/test', $asyncHtmlHandler); $request = $this->createRequest('GET', '/test', [ 'Accept' => 'text/html' ]); $response = $app->handle($request); $this->assertStringContainsString('
  • 1
  • ', $response->getBody()); $this->assertEquals("text/html", $response->getHeader('Content-Type')[0]); $request = $this->createRequest('GET', '/test', [ 'Accept' => 'application/json']); $response = $app->handle($request); $this->assertEquals('{"list":[1,2,3]}', $response->getBody()); $this->assertEquals("application/json", $response->getHeader('Content-Type')[0]); } }