1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-07 09:23:31 +02:00

MDL-47889 tool_monitor: Test handles random DB ordering

On Oracle, the subscriptions are not ordered in the same way
than in other DB engines, so we do not rely on that ordering
any more in the test.
This commit is contained in:
Frederic Massart 2014-10-27 17:02:03 +08:00
parent db310f7737
commit d9e879e5d1
2 changed files with 15 additions and 9 deletions
admin/tool/monitor

@ -201,6 +201,8 @@ class subscription_manager {
}
}
$subscriptions->close();
return $success;
}

@ -264,13 +264,12 @@ class tool_monitor_events_testcase extends advanced_testcase {
$this->assertEquals(context_system::instance(), $event->get_context());
// Now, create a bunch of subscriptions for the rule we created.
$subids = array();
$sub->courseid = $course->id;
for ($i = 1; $i <= 10; $i++) {
$sub->userid = $i;
$subscription = $monitorgenerator->create_subscription($sub);
if ($i == 1) {
$subscription1 = $subscription;
}
$subids[$subscription->id] = $subscription;
}
// Trigger and capture the events.
@ -281,12 +280,17 @@ class tool_monitor_events_testcase extends advanced_testcase {
// Check that there were 10 events in total.
$this->assertCount(10, $events);
// Get the first event and ensure it is valid (we can assume the rest are the same).
$event = reset($events);
$this->assertInstanceOf('\tool_monitor\event\subscription_deleted', $event);
$this->assertEquals(context_course::instance($course->id), $event->get_context());
$this->assertEquals($subscription1->id, $event->objectid);
$this->assertEventContextNotUsed($event);
// Get all the events and ensure they are valid.
foreach ($events as $event) {
$this->assertInstanceOf('\tool_monitor\event\subscription_deleted', $event);
$this->assertEquals(context_course::instance($course->id), $event->get_context());
$this->assertEventContextNotUsed($event);
$this->assertArrayHasKey($event->objectid, $subids);
unset($subids[$event->objectid]);
}
// We should have found all the subscriptions.
$this->assertEmpty($subids);
}
/**