Skip to content

Commit

Permalink
MDL-72478 calendar: Fix PHPUnit failure with offset
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sarjona committed Sep 3, 2021
1 parent 443a980 commit eb70e8f
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions calendar/tests/rrule_manager_test.php
Expand Up @@ -2154,11 +2154,7 @@ public function test_yearly_every_20th_monday_forever() {
// 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');

Expand All @@ -2183,7 +2179,6 @@ public function test_yearly_every_20th_monday_forever() {
$expecteddate->modify('January 1');
$expecteddate->add($interval);
$expecteddate->modify("+20 Monday");
$expecteddate->add($offset);
}
}

Expand Down

0 comments on commit eb70e8f

Please sign in to comment.