MDL-59287 core_completion: Update to unit tests.

This commit is contained in:
Adrian Greeve 2017-06-29 09:07:50 +08:00
parent 1930749f46
commit 190646bd75
3 changed files with 15 additions and 10 deletions

View file

@ -56,7 +56,7 @@ class core_completion_api_testcase extends advanced_testcase {
// Create the completion event.
$CFG->enablecompletion = true;
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign->id, $time);
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign, $time);
// Check that there is now an event in the database.
$events = $DB->get_records('event');
@ -88,10 +88,10 @@ class core_completion_api_testcase extends advanced_testcase {
// Create the event.
$CFG->enablecompletion = true;
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign->id, $time);
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign, $time);
// Call it again, but this time with a different time.
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign->id, $time + DAYSECS);
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign, $time + DAYSECS);
// Check that there is still only one event in the database.
$events = $DB->get_records('event');
@ -123,10 +123,10 @@ class core_completion_api_testcase extends advanced_testcase {
// Create the event.
$CFG->enablecompletion = true;
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign->id, $time);
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign, $time);
// Call it again, but the time specified as null.
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign->id, null);
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign, null);
// Check that there is no event in the database.
$this->assertEquals(0, $DB->count_records('event'));
@ -146,7 +146,7 @@ class core_completion_api_testcase extends advanced_testcase {
// Try and create the completion event with completion disabled.
$CFG->enablecompletion = false;
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign->id, $time);
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign, $time);
// Check that there is no event in the database.
$this->assertEquals(0, $DB->count_records('event'));
@ -166,13 +166,13 @@ class core_completion_api_testcase extends advanced_testcase {
// Create the completion event.
$CFG->enablecompletion = true;
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign->id, $time);
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign, $time);
// Disable completion.
$CFG->enablecompletion = false;
// Try and update the completion date.
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign->id, $time + DAYSECS);
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign, $time + DAYSECS);
// Check that there is an event in the database.
$events = $DB->get_records('event');
@ -204,13 +204,13 @@ class core_completion_api_testcase extends advanced_testcase {
// Create the completion event.
$CFG->enablecompletion = true;
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign->id, $time);
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign, $time);
// Disable completion.
$CFG->enablecompletion = false;
// Should still be able to delete completion events even when completion is disabled.
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign->id, null);
\core_completion\api::update_completion_date_event($assign->cmid, 'assign', $assign, null);
// Check that there is now no event in the database.
$this->assertEquals(0, $DB->count_records('event'));