-
Bug
-
Resolution: Fixed
-
Critical
-
3.2.3, 3.3
-
MOODLE_32_STABLE, MOODLE_33_STABLE
-
MOODLE_32_STABLE, MOODLE_33_STABLE
-
MDL-59101-master -
- Run core_calendar test suite (again).
- Confirm that the test passes (again).
- Run core_calendar test suite (again).
When running unit test calendar/tests/rrule_manager_test.php
function test_yearly_september_every_two_years_forever()
It uses the month of September, if you try and run the test on the 31st day of a month i.e. 31/05/17 it will try and change the event start date to 31/09 but as this day doesn't exist it changes it to 01/10 hence causing the test to fail.
Looks like 2 options to sort the issue,
hardcode the day as 01or change the month to one that has 31 days.
Error
Moodle 3.2.3+ (Build: 20170525), 9651aba2fe0a6654ce1aa515fa89fd2d24748689
Php: 5.6.30.10.2, pgsql: 9.3.16, OS: Linux 3.19.0-25-generic x86_64
PHPUnit 5.5.7 by Sebastian Bergmann and contributors.
.......................................FDateTime Object
(
[date] => 2017-10-01 09:00:00.000000
[timezone_type] => 3
[timezone] => US/Eastern
)
......................... 65 / 85 ( 76%)
.................... 85 / 85 (100%)
Time: 9.72 seconds, Memory: 69.50MB
There was 1 failure:
1) core_calendar_rrule_manager_testcase::test_yearly_september_every_two_years_forever
Failed asserting that two strings are equal.
— Expected
+++ Actual
@@ @@
-'2017-10-01 09:00:00'
+'2019-09-01 09:00:00'
FIX - Change of month to May - 31 days.
public function test_yearly_september_every_two_years_forever() {
global $DB;
// Change the start date for forever events to 9am on the month of MAY of the current year using the current day.
$this->change_event_startdate(date('Y0*5*d\T090000'));
$rrule = "FREQ=YEARLY;BYMONTH=5;INTERVAL=2"; // Forever event.
$mang = new rrule_manager($rrule);
$untildate = new DateTime();
$untildate->add(new DateInterval('P' . $mang::TIME_UNLIMITED_YEARS . 'Y'));
$untiltimestamp = $untildate->getTimestamp();
$mang->parse_rrule();
$mang->create_events($this->event);
$records = $DB->get_records('event', ['repeatid' => $this->event->id], 'timestart ASC', 'id, repeatid, timestart');
$interval = new DateInterval('P2Y');
$expecteddate = new DateTime(date('Y0*5*d\T090000'));
print_r($expecteddate);
foreach ($records as $record) {
$this->assertLessThanOrEqual($untiltimestamp, $record->timestart);
$this->assertEquals($expecteddate->format('Y-m-d H:i:s'), date('Y-m-d H:i:s', $record->timestart));
// Go to the next expected date.
$expecteddate->add($interval);
}
}