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
Fix build issues #8573
Fix build issues #8573
Conversation
Decorated text used to be wrapped too early in SymfonyStyle->block() See symfony/symfony#40348 The fix was not contributed to version 3, which means we have to rewrite the test so that it passes for both the correct and the buggy version.
Symfony v3 is in security-fixes mode only, that's why the bugfix wasn't contributed to v3 |
The remaining failures looks like it might happen every month, or every year, but will not happen tomorrow. |
but-why.gif |
Hello, it might be naive and maybe I am the 47th person talking about it, but have you considered wrapping time behind an interface so you control it, and use PHP DateTime as an implementation of this interface? https://www.matheus.ro/2017/09/25/unit-test-time-dependency/ |
@matks that would work for the PHP part, the trouble is, the other thing we are getting a date from is the RDBMS under test. Consider sending a PR in case you know how to fix that. |
😅 I'm afraid that the RDBMS is indeed a much bigger issue to handle. I will try to look at it but I doubt my experience will be enough. |
I guess all we have to do is see how UPD: easier said than done because of all the magic but in the end I think it boils down to being aware of how many days each months has, which thankfully, does not need to be hardcoded: |
There seems to be at least 2 camps in the software world when it comes to the question "What's today minus one month", today being at the end of march. While PHP and SQLite agree that that would be the 2nd of March, other RDBMS than SQLite and humans will tell you that it's the last day of February. This patch ensures that we check one logic for SQLite, and the other logic for other platforms.
I pushed what I think is a solution but maybe it's not a great solution, since it shows the behavior is not portable, and enforces that non-portability. Maybe a better solution would be to do a rougher assertion… after all, what do we even want to test here? The exact result of
'month' => ['month', 1, 3 * $secondsInDay] ?
|
It seems to be a pragmatic solution. Moreover, if tomorrow SQLite behavior changes or MariaDB behavior changes, you might need to enforce even more not-portability. You are constrained by the RDBMS, so I dont think you need to give much thought to this topic. The test path is messy, but it's not because it's a bad test. It's because it represents a messy real-life situation 😅 . |
@greg0ire alternatively you can use a fixed date/time instead of relying on the current db date. That should make things more stable. |
@lcobucci I love that solution, why didn't I think of that? That way, if we really feel we want to enforce a specific behavior for |
1cd5c3a
to
c3393fa
Compare
Well now Postgresql is unhappy with this :(
UPD: because But then why was it happy with |
Reverting to the original solution, but do advise if you know how to use a fixed date in a way that will work with all platforms (so as a string with most, but with |
Not a great solution. Abstraction layer is supposed to attempt to abstract away these database differences. This test demonstrates it's not doing its job. Instead of hiding this fact in test case, solution could be to make sure all databases return same result given same parameters. This can be done perhaps on DateSubFunction level or in DBAL. But I realize I ask for too much here, so I have different proposition how to avoid this problem every march. Stop testing CURRENT_TIMESTAMP() function, that's not the goal of this testscase and is already covered in multitude of the other tests. In this test case, always use value for first day of current month as a basis for DATE_SUB. Or if you don't like that much, random day in range of 1-28 of current month. Not the current date. |
@ostrolucky that's kinda what @lcobucci proposed, and I tried implementing it, but failed because of #8573 (comment) . Do you know of a workaround for that? |
@greg0ire I'd say that it reveals an issue on DBAL, the method that returns the date_* function should cast the string into a timestamp when that's necessary: https://www.db-fiddle.com/f/4jyoMCicNSZpjMt4jFYoz5/1471 |
Yeah. Workaround might be to have entry with hardcoded date in CompanyManager, then you can use something like |
Ok well, let's go with the ugly solution that works then. |
This is a follow-up from doctrine/orm#8573
This is a follow-up from doctrine/orm#8573. It's supposed to demonstrate that DBAL doesn't handle date literals for PGSQL correctly
This is a follow-up from doctrine/orm#8573. It's supposed to demonstrate that DBAL doesn't handle date literals for PGSQL correctly
This is a follow-up from doctrine/orm#8573. It's supposed to demonstrate that DBAL doesn't handle date literals for PGSQL correctly
Decorated text used to be wrapped too early in SymfonyStyle->block()
See symfony/symfony#40348