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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

It's more likely something funny with timezones going on here:

'@date' => format_date($date->getTimestamp()))))

Berdir’s picture

Enable the assertion and added some debug calls.

Let's see what the testbot is actually doing there.

Berdir’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, let_the_debugging_begin.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
1.61 KB

Ah, 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.

Berdir’s picture

FileSize
1.21 KB

Yep, that works.

Now without debug().

joachim’s picture

Status: Needs review » Fixed

> 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.

joachim’s picture

Title: don't use strtotime() in tests » node creation time test fails due to timezone

Better title for posterity :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.