See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 39 and 401]
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 core; 18 19 use test_output_factory; 20 21 defined('MOODLE_INTERNAL') || die(); 22 23 global $CFG; 24 require_once($CFG->libdir . '/outputfactories.php'); 25 require_once($CFG->libdir . '/tests/fixtures/test_renderer_factory.php'); 26 27 /** 28 * Unit tests for lib/outputfactories.php. 29 * 30 * @package core 31 * @category test 32 * @copyright 2014 Damyon Wiese 33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 34 */ 35 class outputfactories_test extends \advanced_testcase { 36 37 public function test_nonautoloaded_classnames() { 38 global $PAGE; 39 $renderer = $PAGE->get_renderer('mod_assign'); 40 } 41 42 public function test_autoloaded_classnames() { 43 $testfactory = new test_output_factory(); 44 $component = 'mod_assign'; 45 $subtype = 'custom'; 46 $target = RENDERER_TARGET_AJAX; 47 48 $paths = $testfactory->get_standard_renderer_factory_search_paths(''); 49 $this->assertSame($paths, array ( 50 '\\core\\output\\renderer_cli', 51 'core_renderer_cli', 52 '\\core\\output\\renderer', 53 'core_renderer', 54 )); 55 $paths = $testfactory->get_standard_renderer_factory_search_paths($component); 56 $this->assertSame($paths, array ( 57 '\\mod_assign\\output\\renderer_cli', 58 'mod_assign_renderer_cli', 59 '\\mod_assign\\output\\renderer', 60 'mod_assign_renderer', 61 )); 62 $paths = $testfactory->get_standard_renderer_factory_search_paths($component, $subtype); 63 $this->assertSame($paths, array ( 64 '\\mod_assign\\output\\custom_renderer_cli', 65 '\\mod_assign\\output\\custom\\renderer_cli', 66 'mod_assign_custom_renderer_cli', 67 '\\mod_assign\\output\\custom_renderer', 68 '\\mod_assign\\output\\custom\\renderer', 69 'mod_assign_custom_renderer', 70 )); 71 $paths = $testfactory->get_standard_renderer_factory_search_paths($component, $subtype, $target); 72 $this->assertSame($paths, array ( 73 '\\mod_assign\\output\\custom_renderer_ajax', 74 '\\mod_assign\\output\\custom\\renderer_ajax', 75 'mod_assign_custom_renderer_ajax', 76 '\\mod_assign\\output\\custom_renderer', 77 '\\mod_assign\\output\\custom\\renderer', 78 'mod_assign_custom_renderer', 79 )); 80 $paths = $testfactory->get_theme_overridden_renderer_factory_search_paths(''); 81 $this->assertSame($paths, array ( 82 'theme_child\\output\\core_renderer_cli', 83 'theme_child_core_renderer_cli', 84 'theme_parent\\output\\core_renderer_cli', 85 'theme_parent_core_renderer_cli', 86 '\\core\\output\\renderer_cli', 87 'core_renderer_cli', 88 'theme_child\\output\\core_renderer', 89 'theme_child_core_renderer', 90 'theme_parent\\output\\core_renderer', 91 'theme_parent_core_renderer', 92 '\\core\\output\\renderer', 93 'core_renderer', 94 )); 95 $paths = $testfactory->get_theme_overridden_renderer_factory_search_paths($component); 96 $this->assertSame($paths, array ( 97 'theme_child\\output\\mod_assign_renderer_cli', 98 'theme_child_mod_assign_renderer_cli', 99 'theme_parent\\output\\mod_assign_renderer_cli', 100 'theme_parent_mod_assign_renderer_cli', 101 '\\mod_assign\\output\\renderer_cli', 102 'mod_assign_renderer_cli', 103 'theme_child\\output\\mod_assign_renderer', 104 'theme_child_mod_assign_renderer', 105 'theme_parent\\output\\mod_assign_renderer', 106 'theme_parent_mod_assign_renderer', 107 '\\mod_assign\\output\\renderer', 108 'mod_assign_renderer', 109 )); 110 $paths = $testfactory->get_theme_overridden_renderer_factory_search_paths($component, $subtype); 111 $this->assertSame($paths, array ( 112 'theme_child\\output\\mod_assign\\custom_renderer_cli', 113 'theme_child\\output\\mod_assign\\custom\\renderer_cli', 114 'theme_child_mod_assign_custom_renderer_cli', 115 'theme_parent\\output\\mod_assign\\custom_renderer_cli', 116 'theme_parent\\output\\mod_assign\\custom\\renderer_cli', 117 'theme_parent_mod_assign_custom_renderer_cli', 118 '\\mod_assign\\output\\custom_renderer_cli', 119 '\\mod_assign\\output\\custom\\renderer_cli', 120 'mod_assign_custom_renderer_cli', 121 'theme_child\\output\\mod_assign\\custom_renderer', 122 'theme_child\\output\\mod_assign\\custom\\renderer', 123 'theme_child_mod_assign_custom_renderer', 124 'theme_parent\\output\\mod_assign\\custom_renderer', 125 'theme_parent\\output\\mod_assign\\custom\\renderer', 126 'theme_parent_mod_assign_custom_renderer', 127 '\\mod_assign\\output\\custom_renderer', 128 '\\mod_assign\\output\\custom\\renderer', 129 'mod_assign_custom_renderer', 130 )); 131 $paths = $testfactory->get_theme_overridden_renderer_factory_search_paths($component, $subtype, $target); 132 $this->assertSame($paths, array ( 133 'theme_child\\output\\mod_assign\\custom_renderer_ajax', 134 'theme_child\\output\\mod_assign\\custom\\renderer_ajax', 135 'theme_child_mod_assign_custom_renderer_ajax', 136 'theme_parent\\output\\mod_assign\\custom_renderer_ajax', 137 'theme_parent\\output\\mod_assign\\custom\\renderer_ajax', 138 'theme_parent_mod_assign_custom_renderer_ajax', 139 '\\mod_assign\\output\\custom_renderer_ajax', 140 '\\mod_assign\\output\\custom\\renderer_ajax', 141 'mod_assign_custom_renderer_ajax', 142 'theme_child\\output\\mod_assign\\custom_renderer', 143 'theme_child\\output\\mod_assign\\custom\\renderer', 144 'theme_child_mod_assign_custom_renderer', 145 'theme_parent\\output\\mod_assign\\custom_renderer', 146 'theme_parent\\output\\mod_assign\\custom\\renderer', 147 'theme_parent_mod_assign_custom_renderer', 148 '\\mod_assign\\output\\custom_renderer', 149 '\\mod_assign\\output\\custom\\renderer', 150 'mod_assign_custom_renderer', 151 )); 152 } 153 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body