8000 @ParamConverter not found fails phpunit test with symfony/skeleton · Issue #33989 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

@ParamConverter not found fails phpunit test with symfony/skeleton #33989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
LaurentMarquet opened this issue Oct 15, 2019 · 8 comments
Closed

Comments

@LaurentMarquet
Copy link

Symfony version(s) affected: 4.3

Description
Not finding an Entity via @ParamConverter makes the phpunit test fail if project is created with symfony/skeleton.

How to reproduce
I have built 2 projects ParamConverterPass and ParamConverterFail to help reproduce the problem.

The problem is that if we use @ParamConverter to get a non-existing entity, with Doctrine, using data in url, it will make the phpunit test fail if the project is built with symfony/skeleton.

Even if both projects return 404, the one built with symfony/skeletonis not catched by phpunit and return "Sorry, the page you are looking for could not be found." while the one built with symfony/website-skeleton return "App\Entity\Player object not found by the @ParamConverter annotation."

Possible Solution
Haven't got time to investigate yet

Additional context

@stof
Copy link
Member
stof commented Oct 15, 2019

This is probably related to the fact that before Symfony 4.4 (where the ErrorRenderer component is introduced precisely to solve that), the handling of error pages is implemented by TwigBundle, and symfony/skeleton does not install it.

@LaurentMarquet
Copy link
Author
LaurentMarquet commented Oct 15, 2019

Yes, but my "main" problem is that the phpunit test fails, even if 404 is launched.
As it's for an API, Twig is not really required.
I have tried by requiring twig and I receive (in phpunit execution) "2019-10-15T15:19:38+02:00 [error] Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "App\Entity\Player object not found by the @ParamConverter annotation." at /.../vendor/sensio/framework-extra-bundle/Request/ParamConverter/DoctrineParamConverter.php line 107" but the test passes.

@dmaicher
Copy link
Contributor

Should this not be fixed since this PR?

#27519

@LaurentMarquet
Copy link
Author

It seems not.
I've tried by replacing the content of the files with the PR but I still have "Symfony\Component\HttpKernel\Exception\NotFoundHttpException: App\Entity\Player object not found by the @ParamConverter annotation." and "/home/.../vendor/sensio/framework-extra-bundle/Request/ParamConverter/DoctrineParamConverter.php:107".
SF 4.3.5 is used

@dmaicher
Copy link
Contributor

Ok this is indeed not working anymore. It was reverted in #31868

So on 4.3 you either add your own KernelExceptionListener that could turn this exception into a response or you need to install the twig-pack.

As @stof mentioned on 4.4 it will work out of the box 😊

@LaurentMarquet
Copy link
Author

Yes it works with Twig, but the test still return the error between the tests:

ParamConverterFail$ php bin/phpunit
PHPUnit 7.5.16 by Sebastian Bergmann and contributors.

Testing Project Test Suite
.2019-10-18T10:35:14+02:00 [erro
8000
r] Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "App\Entity\Player object not found by the @ParamConverter annotation." at /home/.../vendor/sensio/framework-extra-bundle/Request/ParamConverter/DoctrineParamConverter.php line 107
.                                                                  2 / 2 (100%)

Time: 226 ms, Memory: 16.00 MB

But let's close this issue as it's solved in 4.4
Thanks!

@dmaicher
Copy link
Contributor

You can get rid of the log output by adding a "real logger" like monolog. You can simply install symfony/monolog-bundle 😉

@LaurentMarquet
Copy link
Author

Yep it disappeared :) by using too much symfony/website-skeleton you forget what's "inside"...
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0