Differences Between: [Versions 310 and 400] [Versions 39 and 400]
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 namespace tool_templatelibrary; 18 19 use externallib_advanced_testcase; 20 21 defined('MOODLE_INTERNAL') || die(); 22 23 global $CFG; 24 25 require_once($CFG->dirroot . '/webservice/tests/helpers.php'); 26 27 /** 28 * External learning plans webservice API tests. 29 * 30 * @package tool_templatelibrary 31 * @copyright 2015 Damyon Wiese 32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 */ 34 class externallib_test extends externallib_advanced_testcase { 35 36 /** 37 * Test list all. 38 */ 39 public function test_list_templates() { 40 $result = external::list_templates('', ''); 41 $count = count($result); 42 // We have 3 templates in this tool - and there must be more else where. 43 $this->assertGreaterThan(3, $count); 44 } 45 46 /** 47 * Test we can filter by component. 48 */ 49 public function test_list_templates_for_component() { 50 $result = external::list_templates('tool_templatelibrary', ''); 51 $count = count($result); 52 $this->assertEquals(3, $count); 53 54 $this->assertContains("tool_templatelibrary/display_template", $result); 55 $this->assertContains("tool_templatelibrary/search_results", $result); 56 $this->assertContains("tool_templatelibrary/list_templates_page", $result); 57 } 58 59 /** 60 * Test we can filter by a string. 61 */ 62 public function test_list_templates_with_filter() { 63 $result = external::list_templates('tool_templatelibrary', 'page'); 64 $count = count($result); 65 // Should be only one matching template. 66 $this->assertEquals(1, $count); 67 $this->assertEquals($result[0], "tool_templatelibrary/list_templates_page"); 68 } 69 70 public function test_load_canonical_template() { 71 global $CFG; 72 73 $originaltheme = $CFG->theme; 74 // Change the theme to 'base' because it overrides these templates. 75 $CFG->theme = 'boost'; 76 77 $template = external::load_canonical_template('core', 'notification_error'); 78 79 // Only the base template should contain the docs. 80 $this->assertStringContainsString('@template core/notification_error', $template); 81 82 // Restore the original theme. 83 $CFG->theme = $originaltheme; 84 } 85 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body