Comments (6)
after a lot a of digging, I've just figured out that the main reason of why we've introduced this whole "error handlers resetting" stuff is because when the kernel is booted in a "before class" hook, the deprecation won't bubble up in PHPUnit (because Symfony registers its error handler before PHPUnit, and then PHPUnit won't register its own error handler if one already exists. see both here and here
So we had to find a way to prevent this when using ResetDatabase
. But it is not needed to reset the error handler in a setup()
hook (aka #[Before]
), and it is where the problem Test code or tested code removed error handlers other than its own
comes from. At then end, the solution would be to not only reset error handlers in ResetDatabase::_resetDatabase()
which is the only place where Foundry boots the kernel in a "before class" hook.
from foundry.
I've released v1.38.2
& v2.0.3
. I'm closing the issue, feel free to reopen it if you still have problems with this
from foundry.
Just tested with 1.38.2 and it fixed my issue. Thanks
from foundry.
Hi @mmarton
this is a complex topic, the main problem with the workardound set_exception_handler([new ErrorHandler(), 'handleException']);
added in boostrap.php
is that Symfony exception handler does not let deprecation warnings bubble up to PHPUnit's one...
Still, I do understand that the chosen solution is unfortunate as well. more over the problem is between Symfony and PHPUnit, and Foundry has nothing to deal with it.. But for the migration between foundry v1 and v2, the ability to display deprecation is kinda super helpful.
The problem occurs because methods marked as #[BeforeClass]
in the traits occur before TestCase::setUpBeforeClass()
and then Symfony's exception handler is not removed afterwards if the kernel is booted there.
I think our hands are tied here 😞
(I've been thinking about introducing a PHPUnit Extension for Foundry for a long time, maybe that would be a way to mitigate this problem. But we would still need to mess around with Symfony's exception handler, which is not Foundry's responsibility, I admit)
@kbond any thoughts?
from foundry.
@mmarton, to confirm, are you using phpunit 10+?
from foundry.
@mmarton, to confirm, are you using phpunit 10+?
Yes, the latest 11.2 version
from foundry.
Related Issues (20)
- Migration Guide to version 2 HOT 3
- V2 and phpstan HOT 5
- Upgrade from 1.37 to 1.38 introduce a memory leak HOT 16
- H
- [2.x] ArgumentCountError thrown when passing $attributes array to closure in event HOT 9
- Creation of dynamic property App\Entity\MyEntity::$_autoRefresh is deprecated HOT 6
- Issue with Proxy Entities in Version 2 HOT 14
- Zenstruck\Foundry\Factory::$class must not be accessed before initialization HOT 6
- Find functions do not refresh entity HOT 2
- Attribute wrapped in a Foundry Proxy is not compatible with `Symfony\Component\VarExporter\LazyProxyTrait` HOT 6
- Global state relationships and flush_after HOT 13
- How to fix deprecation notices HOT 7
- [2.0] Problem with inversed `OneToOne` relationships HOT 4
- [2.0] No autocompletion for Proxy objects HOT 2
- [2.0] ResetDatabase with DamaDoctrineTestBundle and symfony/doctrine-messenger library
- [2.0] Re-add `assertPersisted()` & `assertNotPersisted()` HOT 6
- [2.0] Customize Faker's locale HOT 6
- Foundry 2 with PHPUnit changes the error handler of Symfony HOT 4
- createMany does not work with references to third entities
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from foundry.