-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Clock Mocking doesn't work from v3.12.0 #2700
Comments
I didn't check the clock mocking features from symfony/phpunit-bridge. Limiting the syntax in the codebase based on the limitations of this implementation is something I'd like to avoid. BTW, in case we consider this as a bug, we must provide the required test cases to avoid regressions in the future. |
Hi @phansys ! After upgrading DoctrineExtensions some of our tests also started failing.
I looked at the library you linked slope-it/clock-mock, but it requires a PHP extension. A quick win for DoctrineExtensions would be to replace the If you want to allow this change I could provide a PR including a test to ensure interoperability with |
The future-proof way would be to support injecting a PSR-20 clock in the listener and using it to get the current time. |
@rasstislav Can this be closed as completed (see linked PR)? |
@Chris53897 my tests are still not working due to DateTime as @boedah also mentioned. |
@boedah, can you please test it as well? |
What tests specifically? Without a specific use case, it's hard to know what it is that's causing your issue. The last release supports injecting a PSR-20 where practical, with the only places using still using |
@rasstislav I can confirm it works now. Unfortunately, Symfony\Component\HttpFoundation\Session\Storage\MetadataBag (also in This is what I have done in a Symfony 5.4 app:
clock:
class: Symfony\Component\Clock\Clock
autowire: false
autoconfigure: false
Symfony\Component\Clock\ClockInterface: '@clock'
Psr\Clock\ClockInterface: '@clock'
Hope this helps :) |
Hello,
this commit broke Clock mocking.
Is it possible to fix it?
Thanks
The text was updated successfully, but these errors were encountered: