mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-59287 core_completion: Update to unit tests.
This commit is contained in:
parent
1930749f46
commit
190646bd75
3 changed files with 15 additions and 10 deletions
|
@ -56,7 +56,7 @@ class core_completion_api_testcase extends advanced_testcase {
|
||||||
|
|
||||||
// Create the completion event.
|
// Create the completion event.
|
||||||
$CFG->enablecompletion = true;
|
$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.
|
// Check that there is now an event in the database.
|
||||||
$events = $DB->get_records('event');
|
$events = $DB->get_records('event');
|
||||||
|
@ -88,10 +88,10 @@ class core_completion_api_testcase extends advanced_testcase {
|
||||||
|
|
||||||
// Create the event.
|
// Create the event.
|
||||||
$CFG->enablecompletion = true;
|
$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.
|
// 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.
|
// Check that there is still only one event in the database.
|
||||||
$events = $DB->get_records('event');
|
$events = $DB->get_records('event');
|
||||||
|
@ -123,10 +123,10 @@ class core_completion_api_testcase extends advanced_testcase {
|
||||||
|
|
||||||
// Create the event.
|
// Create the event.
|
||||||
$CFG->enablecompletion = true;
|
$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.
|
// 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.
|
// Check that there is no event in the database.
|
||||||
$this->assertEquals(0, $DB->count_records('event'));
|
$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.
|
// Try and create the completion event with completion disabled.
|
||||||
$CFG->enablecompletion = false;
|
$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.
|
// Check that there is no event in the database.
|
||||||
$this->assertEquals(0, $DB->count_records('event'));
|
$this->assertEquals(0, $DB->count_records('event'));
|
||||||
|
@ -166,13 +166,13 @@ class core_completion_api_testcase extends advanced_testcase {
|
||||||
|
|
||||||
// Create the completion event.
|
// Create the completion event.
|
||||||
$CFG->enablecompletion = true;
|
$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.
|
// Disable completion.
|
||||||
$CFG->enablecompletion = false;
|
$CFG->enablecompletion = false;
|
||||||
|
|
||||||
// Try and update the completion date.
|
// 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.
|
// Check that there is an event in the database.
|
||||||
$events = $DB->get_records('event');
|
$events = $DB->get_records('event');
|
||||||
|
@ -204,13 +204,13 @@ class core_completion_api_testcase extends advanced_testcase {
|
||||||
|
|
||||||
// Create the completion event.
|
// Create the completion event.
|
||||||
$CFG->enablecompletion = true;
|
$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.
|
// Disable completion.
|
||||||
$CFG->enablecompletion = false;
|
$CFG->enablecompletion = false;
|
||||||
|
|
||||||
// Should still be able to delete completion events even when completion is disabled.
|
// 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.
|
// Check that there is now no event in the database.
|
||||||
$this->assertEquals(0, $DB->count_records('event'));
|
$this->assertEquals(0, $DB->count_records('event'));
|
||||||
|
|
|
@ -3237,6 +3237,8 @@ class core_course_courselib_testcase extends advanced_testcase {
|
||||||
|
|
||||||
$this->resetAfterTest(true);
|
$this->resetAfterTest(true);
|
||||||
|
|
||||||
|
$this->setAdminUser();
|
||||||
|
|
||||||
$CFG->enablecompletion = true;
|
$CFG->enablecompletion = true;
|
||||||
|
|
||||||
$this->setTimezone('UTC');
|
$this->setTimezone('UTC');
|
||||||
|
|
|
@ -186,6 +186,9 @@ class core_test_generator_testcase extends advanced_testcase {
|
||||||
|
|
||||||
public function test_create_module() {
|
public function test_create_module() {
|
||||||
global $CFG, $SITE, $DB;
|
global $CFG, $SITE, $DB;
|
||||||
|
|
||||||
|
$this->setAdminUser();
|
||||||
|
|
||||||
if (!file_exists("$CFG->dirroot/mod/page/")) {
|
if (!file_exists("$CFG->dirroot/mod/page/")) {
|
||||||
$this->markTestSkipped('Can not find standard Page module');
|
$this->markTestSkipped('Can not find standard Page module');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue