From 55b55d59cf2edd5d0cd31bcb163fbe14d8d44f84 Mon Sep 17 00:00:00 2001 From: Renaat Debleu Date: Fri, 8 Mar 2024 08:38:56 +0000 Subject: [PATCH] checkout v4 --- .github/workflows/cron.yml | 2 +- .github/workflows/main.yml | 2 +- tests/condition_test.php | 14 +++++--------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index a90a730..0dcbae5 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -18,7 +18,7 @@ jobs: steps: - name: checkout plugin - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: this-plugin diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aff070b..752f5c7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ jobs: steps: - name: checkout plugin - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: this-plugin diff --git a/tests/condition_test.php b/tests/condition_test.php index 2ea4335..8016c20 100755 --- a/tests/condition_test.php +++ b/tests/condition_test.php @@ -112,12 +112,10 @@ public function test_sections(): void { // Create course with language turned on and a Page. $generator = $this->getDataGenerator(); $course = $generator->create_course(); - $user1 = $generator->create_user()->id; + $user1 = $generator->create_and_enrol($course)->id; // MDL-68333 hack when nl language is not installed. $DB->set_field('user', 'lang', 'nl', ['id' => $user1]); - $user2 = $generator->create_user()->id; - $generator->enrol_user($user1, $course->id); - $generator->enrol_user($user2, $course->id); + $user2 = $generator->create_and_enrol($course)->id; $cond = '{"op":"|","show":false,"c":[{"type":"language","id":"nl"}]}'; $DB->set_field('course_sections', 'availability', $cond, ['course' => $course->id, 'section' => 0]); $cond = '{"op":"|","show":true,"c":[{"type":"language","id":""}]}'; @@ -217,13 +215,12 @@ public function test_frontend(): void { $les = new \lesson($generator->get_plugin_generator('mod_lesson')->create_instance($params)); $params['lang'] = 'nl'; $page = $generator->get_plugin_generator('mod_page')->create_instance($params); - $user = $generator->create_user(); + $user = $generator->create_and_enrol($course); $modinfo = get_fast_modinfo($course); $cm1 = $modinfo->get_cm($les->cmid); $cm2 = $modinfo->get_cm($page->cmid); $sections = $modinfo->get_section_info_all(); - $generator->enrol_user($user->id, $course->id); - + $name = 'availability_language\frontend'; $frontend = new \availability_language\frontend(); // There is only 1 language installed, so we cannot assert allow add will return true. @@ -264,8 +261,7 @@ public function test_backend(): void { $generator = $this->getDataGenerator(); $course = $generator->create_course(); $context = \context_course::instance($course->id); - $user = $generator->create_user(); - $generator->enrol_user($user->id, $course->id); + $user = $generator->create_and_enrol($course); $pagegen = $generator->get_plugin_generator('mod_page'); $restriction = \core_availability\tree::get_root_json([condition::get_json('fr')]); $pagegen->create_instance(['course' => $course, 'availability' => json_encode($restriction)]);