Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Spin-off from #1364784: Monthly Interval varies by a few days.
SimpleNewsSchedulerNodeCreationTest test fails if I set my user timezone to UTC in the real site: this is because of a strtotime() in the test I think.
Comment | File | Size | Author |
---|---|---|---|
#6 | just_the_fix.patch | 1.21 KB | Berdir |
#5 | does_this_fix_it.patch | 1.61 KB | Berdir |
#2 | let_the_debugging_begin.patch | 1.29 KB | Berdir |
Comments
Comment #1
joachim CreditAttribution: joachim commentedIt's more likely something funny with timezones going on here:
'@date' => format_date($date->getTimestamp()))))
Comment #2
BerdirEnable the assertion and added some debug calls.
Let's see what the testbot is actually doing there.
Comment #3
BerdirComment #5
BerdirAh, I think this might actually be easier than I thought.
You're calling variable_set('date_default_timezone', 'Europe/Kiev')) in setUp(). This does *not* affect the code within the test, because that relies on the the date_default_timezone_get(), which returns whatever is set in PHP, not Drupal.
However, when we do a page request then we are going through the session handling, which sets the PHP timezone based on that variable.
So, doing that as well in setUp() should probably fix this. I'm not sure if we should do this by default, though but instead only in the test classes we want it and are doing timezone-specific assertions.
Comment #6
BerdirYep, that works.
Now without debug().
Comment #7
joachim CreditAttribution: joachim commented> You're calling variable_set('date_default_timezone', 'Europe/Kiev')) in setUp(). This does *not* affect the code within the test, because that relies on the the date_default_timezone_get(), which returns whatever is set in PHP, not Drupal.
I was expecting the setting of PHP's default in session.inc to have happened by then, but I admit that was an assumption rather than based on any knowledge of what gets set up during a test run!
Thanks for the fix!
- #1528586 by Berdir: Fixed node creation test submitted time failing due to timezone.
Comment #8
joachim CreditAttribution: joachim commentedBetter title for posterity :)