[BUGFIX] Fix Typo3DbQueryParserTest for custom php timezones
authorBenjamin Franzke <bfr@qbus.de>
Thu, 13 May 2021 08:19:39 +0000 (10:19 +0200)
committerOliver Bartsch <bo@cedev.de>
Thu, 13 May 2021 22:15:28 +0000 (00:15 +0200)
The test setup used to initialize the DateAspect from a string,
that means the local php timezone has been taken into account,
and test verficiation fails with date offsets if the local
timezone is not UTC.

Adapt to initialize from a unix timestamp, as this ensures
the local timezone has no effect on the test. Note that the
real application does the same, as the DateAspect in initialized
from the timestamp in GLOBALS['EXEC_TIME'].

Releases: master, 10.4, 9.5
Resolves: #94135
Change-Id: I0494ac3e1911f34a3a79c3063caaabad1c0027b7
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69141
Tested-by: core-ci <typo3@b13.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbQueryParserTest.php

index f90a1eb..178eed2 100644 (file)
@@ -614,7 +614,7 @@ class Typo3DbQueryParserTest extends UnitTestCase
         // simulate time for backend enable fields
         $GLOBALS['SIM_ACCESS_TIME'] = 1451779200;
         // simulate time for frontend (PageRepository) enable fields
-        $dateAspect = new DateTimeAspect(new \DateTimeImmutable('3.1.2016'));
+        $dateAspect = new DateTimeAspect(new \DateTimeImmutable('@1451779200'));
         $context = new Context(['date' => $dateAspect]);
         GeneralUtility::setSingletonInstance(Context::class, $context);
 
@@ -682,7 +682,7 @@ class Typo3DbQueryParserTest extends UnitTestCase
         // simulate time for backend enable fields
         $GLOBALS['SIM_ACCESS_TIME'] = 1451779200;
         // simulate time for frontend (PageRepository) enable fields
-        $dateAspect = new DateTimeAspect(new \DateTimeImmutable('3.1.2016'));
+        $dateAspect = new DateTimeAspect(new \DateTimeImmutable('@1451779200'));
         $context = new Context(['date' => $dateAspect]);
         GeneralUtility::setSingletonInstance(Context::class, $context);