Skip to content
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

PhpUnit now throws warnings: Test code or tested code removed exception handlers other than its own #50951

Closed
elb98rm opened this issue Apr 7, 2024 · 11 comments

Comments

@elb98rm
Copy link

elb98rm commented Apr 7, 2024

Laravel Version

11.2.0

PHP Version

8.3

Database Driver & Version

MySql 8

Description

As per issue: #49502

When running tests, the vast majority produce the warning: "Test code or tested code removed exception handlers other than its own"

This seems to have been a short lived change in PhpUnit that was reverted... I think it's back now!

Steps To Reproduce

.. use any repo with existing tests OR:
Install L11.
Run a test on a view using something like $response->assertStatus(200);

@crynobone
Copy link
Member

Hey there, thanks for reporting this issue.

We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as one separate commit on the main/master branch and share the repository here?

Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.

laravel new bug-report --github="--public"

Do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue.

Thanks!

@elb98rm
Copy link
Author

elb98rm commented Apr 7, 2024

I'm sorry - I don't have time. However, the previous post offered these commands.

laravel new laravel
cd laravel
./vendor/bin/phpunit

@driesvints
Copy link
Member

Just works for me:

Screenshot 2024-04-08 at 10 23 58

@elb98rm
Copy link
Author

elb98rm commented Apr 8, 2024

image

Doesn't for me. Unfortunately due to a work deadline, I can't spend time on the bug. Hopefully someone else will be able to help.
As I've mentioned, this is a duplicate that looks like it's been re-introduced by PHPUnit, and other people have also seen it.

Hope it gets resolved.

@AdrienPoupa
Copy link

I am also getting this on a new Laravel 11 project

@pps1
Copy link

pps1 commented Apr 9, 2024

This also happens on Symfony 7.0.3 controller tests

@elb98rm
Copy link
Author

elb98rm commented Apr 17, 2024

@driesvints is this being looked at? It's not a closed issue.

@driesvints
Copy link
Member

I need a way to reproduce this.

@elb98rm
Copy link
Author

elb98rm commented Apr 17, 2024

Ok, Ill look at trying to make a suitble test later today.

@crishoj
Copy link
Contributor

crishoj commented Apr 18, 2024

If $this->createApplication() is called in the test constructor, the warnings appear.

(The call to createApplication() is a workaround for A facade root has not been set when interacting with the framework in PHPUnit 11 static @dataProvider. I would be happy to learn about a better workaround.)

@crynobone
Copy link
Member

@crishoj

CleanShot 2024-04-18 at 14 31 32

Read the Caveat section from https://tighten.com/insights/tidying-up-your-phpunit-tests-with-data-providers/

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

6 participants