/**
  * If the stream in the Response cannot be rewound, then we need to replace
  * it with our own SimplePsrStream
  */
 public function testUseOurOwnStreamIfCurrentOneIsNotRewindable()
 {
     $data = ['items' => [['name' => 'Alex', 'is_admin' => true], ['name' => 'Robin', 'is_admin' => false]]];
     $request = (new Request())->withUri(new Uri('http://example.com'))->withAddedHeader('Accept', 'application/json');
     stream_wrapper_register("norewind", NonRewindableStream::class);
     $response = new Response();
     $response = $response->withBody(new Stream('norewind://temp', 'a'));
     $renderer = new Renderer();
     $response = $renderer->render($request, $response, $data);
     $this->assertSame('application/json', $response->getHeaderLine('Content-Type'));
     $this->assertSame(json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES), (string) $response->getBody());
     $this->assertInstanceOf('RKA\\ContentTypeRenderer\\SimplePsrStream', $response->getBody());
 }
 /**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
 {
     return $this->renderer->render($request, $response->withStatus($this->getCode()), $this->getData());
 }