mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-59287 core_completion: Update to unit tests.
This commit is contained in:
parent
1930749f46
commit
190646bd75
@ -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'));
|
||||
|
@ -3237,6 +3237,8 @@ class core_course_courselib_testcase extends advanced_testcase {
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
$this->setAdminUser();
|
||||
|
||||
$CFG->enablecompletion = true;
|
||||
|
||||
$this->setTimezone('UTC');
|
||||
|
@ -186,6 +186,9 @@ class core_test_generator_testcase extends advanced_testcase {
|
||||
|
||||
public function test_create_module() {
|
||||
global $CFG, $SITE, $DB;
|
||||
|
||||
$this->setAdminUser();
|
||||
|
||||
if (!file_exists("$CFG->dirroot/mod/page/")) {
|
||||
$this->markTestSkipped('Can not find standard Page module');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user