Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403] [Versions 39 and 310]
1 <?php 2 // This file is part of Moodle - http://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 * Unit tests for MoodleQuickForm_course. 19 * 20 * This file contains unit tests related to course forms element. 21 * 22 * @package core_form 23 * @category test 24 * @copyright 2020 Ruslan Kabalin 25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 26 */ 27 28 defined('MOODLE_INTERNAL') || die(); 29 30 global $CFG; 31 require_once($CFG->libdir . '/form/course.php'); 32 33 /** 34 * Unit tests for MoodleQuickForm_course 35 * 36 * Contains test cases for testing MoodleQuickForm_course. 37 * 38 * @package core_form 39 * @category test 40 * @copyright 2020 Ruslan Kabalin 41 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 42 */ 43 class core_form_course_testcase extends basic_testcase { 44 45 /** 46 * Test constructor supports all declared attributes. 47 */ 48 public function test_constructor_attributes() { 49 $attributes = [ 50 'exclude' => [1, 2], 51 'requiredcapabilities' => ['moodle/course:update'], 52 ]; 53 54 $element = new MoodleQuickForm_course('testel', null, $attributes); 55 $html = $element->toHtml(); 56 $this->assertStringContainsString('data-exclude="1,2"', $html); 57 $this->assertStringContainsString('data-requiredcapabilities="moodle/course:update"', $html); 58 $this->assertStringContainsString('data-limittoenrolled="0"', $html); 59 $this->assertStringNotContainsString('multiple', $html); 60 $this->assertStringNotContainsString('data-includefrontpage', $html); 61 $this->assertStringNotContainsString('data-onlywithcompletion', $html); 62 63 // Add more attributes. 64 $attributes = [ 65 'multiple' => true, 66 'limittoenrolled' => true, 67 'includefrontpage' => true, 68 'onlywithcompletion' => true, 69 ]; 70 $element = new MoodleQuickForm_course('testel', null, $attributes); 71 $html = $element->toHtml(); 72 $this->assertStringContainsString('multiple', $html); 73 $this->assertStringContainsString('data-limittoenrolled="1"', $html); 74 $this->assertStringContainsString('data-includefrontpage="' . SITEID . '"', $html); 75 $this->assertStringContainsString('data-onlywithcompletion="1"', $html); 76 } 77 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body