Skip to content

Functional tests fail when NotFoundHttpException is thrown #25311

Closed
@gjuric

Description

@gjuric
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 4.0.0

When I am running functional tests that extend WebTestCase and I request a controller action that throws a NotFoundHttpException it looks like the exception is not converted to u 404 response. (I am checking for a 404 response code in the test).

#!/usr/bin/env php
PHPUnit 6.5.2 by Sebastian Bergmann and contributors.

Testing Project Test Suite
E                                                                   1 / 1 (100%)

Time: 275 ms, Memory: 8.00MB

There was 1 error:

1) App\Tests\DefaultControllerTest::testSomething
Symfony\Component\HttpKernel\Exception\NotFoundHttpException: Not Found

...sf4/vendor/symfony/framework-bundle/Controller/ControllerTrait.php:282
...sf4/src/Controller/DefaultController.php:15
...sf4/vendor/symfony/http-kernel/HttpKernel.php:151
...sf4/vendor/symfony/http-kernel/HttpKernel.php:66
...sf4/vendor/symfony/http-kernel/Kernel.php:190
...sf4/vendor/symfony/http-kernel/Client.php:68
...sf4/vendor/symfony/framework-bundle/Client.php:131
...sf4/vendor/symfony/browser-kit/Client.php:312
...sf4/tests/DefaultControllerTest.php:12

If I return a response from the controller:

return new Response('Not found', Response::HTTP_NOT_FOUND)

then the tests pass.

I have create a minimal example here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions