The test \Drupal\Tests\feeds\Unit\Feeds\Target\DateTimeTest fails when the test is ran by the testbot. Strangely, I got no errors when running phpunit tests from the commandline this way:
cd modules/wip/feeds/feeds8
phpunit --group feeds
But there is a failure when running the test this way from the command line:
php core/scripts/run-tests.sh --file modules/wip/feeds/feeds8/tests/src/Unit/Feeds/Target/DateTimeTest.php
The fail happens on the following line:
$this->assertSame($values['value'], '2000-01-01T00:00:00');
When logging that $values['value']
value, it appears to be "1999-12-31T13:00:00" instead, so it looks the issue has something to do with timezones.
In \Drupal\feeds\Feeds\Target\DateTime::prepareValue() the year value is converted to "January 2000" which is then passed to strtotime()
. I think it makes sense to specify the timezone in this string (which should be "UTC" as that is what the value of the constant DATETIME_STORAGE_TIMEZONE
is).
Patch will follow.
Comment | File | Size | Author |
---|---|---|---|
#4 | 2595673.4.patch | 1.79 KB | alexpott |
| |||
#2 | feeds8-datetime-test-2595673-2.patch | 463 bytes | MegaChriz |
|
Comments
Comment #2
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedLet's see if this patch passes all tests.
Comment #3
MegaChriz CreditAttribution: MegaChriz as a volunteer commentedWhile the patch in #2 fixes the test failure, I don't think it is the right fix. I think the "fix" hides issues related to time zones. I hope to be more knowledgable about fixing this properly after I have dived into #722740: Feeds Date mapper converts imported dates to GMT unless in UNIX timestamp format.
Comment #4
alexpottIt think one issue is that
strtotime
will use the timezone that is set. The reason the test fails is that we've intentionally done...In the unit test bootstrap.
Comment #6
twistor CreditAttribution: twistor as a volunteer commentedGoing with this for now. Needs to be revisited with regard to #722740: Feeds Date mapper converts imported dates to GMT unless in UNIX timestamp format.