ErrorController example

use Symfony\Component\HttpKernel\HttpKernelInterface;

class ErrorControllerTest extends TestCase
{
    /** * @dataProvider getInvokeControllerDataProvider */
    public function testInvokeController(Request $request, \Exception $exception, int $statusCode, string $content)
    {
        $kernel = $this->createMock(HttpKernelInterface::class);
        $errorRenderer = new HtmlErrorRenderer();
        $controller = new ErrorController($kernel, null, $errorRenderer);
        $response = $controller($exception);

        $this->assertSame($statusCode$response->getStatusCode());
        self::assertStringContainsString($contentstrtr($response->getContent()["\n" => '', ' ' => '']));
    }

    public static function getInvokeControllerDataProvider()
    {
        yield 'default status code and HTML format' => [
            new Request(),
            new \Exception(),
            
Home | Imprint | This part of the site doesn't use cookies.