From eb70e8f87eb6c15fcfb0e3fe3173689bce3e1825 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Fri, 3 Sep 2021 09:28:41 +0200 Subject: [PATCH] MDL-72478 calendar: Fix PHPUnit failure with offset Before PHP 8.0.10, the time is lost when datetime->modify() is used with weekdays. However, with PHP 8.0.10, the time is kept. In consequence, the test_yearly_every_20th_monday_forever method started failing. For fixing it, the offset has been removed and the time has been set to 00:00, so the behaviour will be the same regardless the PHP version. --- calendar/tests/rrule_manager_test.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/calendar/tests/rrule_manager_test.php b/calendar/tests/rrule_manager_test.php index 9fbf46c6c9d..449a9fcbbb5 100644 --- a/calendar/tests/rrule_manager_test.php +++ b/calendar/tests/rrule_manager_test.php @@ -2154,11 +2154,7 @@ class core_calendar_rrule_manager_testcase extends advanced_testcase { // Change our event's date to the 20th Monday of the current year. $twentiethmonday = new DateTime(date('Y-01-01')); $twentiethmonday->modify('+20 Monday'); - $startdatetime = $this->change_event_startdate($twentiethmonday->format('Ymd\T090000'), 'US/Eastern'); - - $startdate = new DateTime($startdatetime->format('Y-m-d')); - - $offset = $startdatetime->diff($startdate, true); + $startdatetime = $this->change_event_startdate($twentiethmonday->format('Ymd\T000000'), 'US/Eastern'); $interval = new DateInterval('P1Y'); @@ -2183,7 +2179,6 @@ class core_calendar_rrule_manager_testcase extends advanced_testcase { $expecteddate->modify('January 1'); $expecteddate->add($interval); $expecteddate->modify("+20 Monday"); - $expecteddate->add($offset); } }