renderer = $this->prophesize(TemplateRendererInterface::class); $this->delegate = new NotFoundHandler($this->renderer->reveal()); } /** * @test * @dataProvider provideResponses */ public function properResponseTypeIsReturned(string $expectedResponse, string $accept, int $renderCalls): void { $request = (new ServerRequest())->withHeader('Accept', $accept); $render = $this->renderer->render(Argument::cetera())->willReturn(''); $resp = $this->delegate->handle($request); $this->assertInstanceOf($expectedResponse, $resp); $render->shouldHaveBeenCalledTimes($renderCalls); } public function provideResponses(): iterable { yield 'application/json' => [Response\JsonResponse::class, 'application/json', 0]; yield 'text/json' => [Response\JsonResponse::class, 'text/json', 0]; yield 'application/x-json' => [Response\JsonResponse::class, 'application/x-json', 0]; yield 'text/html' => [Response\HtmlResponse::class, 'text/html', 1]; } }