Differences Between: [Versions 39 and 310]
1 <?php 2 // This file is part of Moodle - https://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Provides the {@link mod_workshop_cron_task_testcase} class. 19 * 20 * @package mod_workshop 21 * @category test 22 * @copyright 2019 David Mudrák <david@moodle.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 global $CFG; 29 30 require_once($CFG->dirroot.'/mod/workshop/lib.php'); 31 32 /** 33 * Test the functionality provided by the {@link mod_workshop\task\cron_task} scheduled task. 34 * 35 * @copyright 2019 David Mudrák <david@moodle.com> 36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 */ 38 class mod_workshop_cron_task_testcase extends advanced_testcase { 39 40 /** 41 * Test that the phase is automatically switched after the submissions deadline. 42 */ 43 public function test_phase_switching() { 44 global $DB; 45 46 $this->resetAfterTest(); 47 $this->setAdminUser(); 48 49 // Set up a test workshop with 'Switch to the next phase after the submissions deadline' enabled. 50 $generator = $this->getDataGenerator(); 51 $course = $generator->create_course(); 52 $workshop = $generator->create_module('workshop', [ 53 'course' => $course, 54 'name' => 'Test Workshop', 55 ]); 56 57 $DB->update_record('workshop', [ 58 'id' => $workshop->id, 59 'phase' => workshop::PHASE_SUBMISSION, 60 'phaseswitchassessment' => 1, 61 'submissionend' => time() - 1, 62 ]); 63 64 // Execute the cron. 65 ob_start(); 66 cron_setup_user(); 67 $cron = new \mod_workshop\task\cron_task(); 68 $cron->execute(); 69 $output = ob_get_contents(); 70 ob_end_clean(); 71 72 // Assert that the phase has been switched. 73 $this->assertStringContainsString('Processing automatic assessment phase switch', $output); 74 $this->assertEquals(workshop::PHASE_ASSESSMENT, $DB->get_field('workshop', 'phase', ['id' => $workshop->id])); 75 } 76 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body