Git Product home page Git Product logo

Comments (6)

nikophil avatar nikophil commented on July 22, 2024 1

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.

nikophil avatar nikophil commented on July 22, 2024 1

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.

mmarton avatar mmarton commented on July 22, 2024 1

Just tested with 1.38.2 and it fixed my issue. Thanks

from foundry.

nikophil avatar nikophil commented on July 22, 2024

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.

kbond avatar kbond commented on July 22, 2024

@mmarton, to confirm, are you using phpunit 10+?

from foundry.

mmarton avatar mmarton commented on July 22, 2024

@mmarton, to confirm, are you using phpunit 10+?

Yes, the latest 11.2 version

from foundry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.