Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 29... Línea 29...
29
 * @category  test
29
 * @category  test
30
 * @copyright 2012 Petr Škoda
30
 * @copyright 2012 Petr Škoda
31
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32
 */
32
 */
33
class outputrequirementslib_test extends \advanced_testcase {
33
class outputrequirementslib_test extends \advanced_testcase {
34
    public function test_string_for_js() {
34
    public function test_string_for_js(): void {
35
        $this->resetAfterTest();
35
        $this->resetAfterTest();
Línea 36... Línea 36...
36
 
36
 
37
        $page = new \moodle_page();
37
        $page = new \moodle_page();
38
        $page->requires->string_for_js('course', 'moodle', 1);
38
        $page->requires->string_for_js('course', 'moodle', 1);
Línea 42... Línea 42...
42
 
42
 
43
        // Note: we can not switch languages in phpunit yet,
43
        // Note: we can not switch languages in phpunit yet,
44
        //       it would be nice to test that the strings are actually fetched in the footer.
44
        //       it would be nice to test that the strings are actually fetched in the footer.
Línea 45... Línea 45...
45
    }
45
    }
46
 
46
 
47
    public function test_one_time_output_normal_case() {
47
    public function test_one_time_output_normal_case(): void {
48
        $page = new \moodle_page();
48
        $page = new \moodle_page();
49
        $this->assertTrue($page->requires->should_create_one_time_item_now('test_item'));
49
        $this->assertTrue($page->requires->should_create_one_time_item_now('test_item'));
Línea 50... Línea 50...
50
        $this->assertFalse($page->requires->should_create_one_time_item_now('test_item'));
50
        $this->assertFalse($page->requires->should_create_one_time_item_now('test_item'));
51
    }
51
    }
52
 
52
 
53
    public function test_one_time_output_repeat_output_throws() {
53
    public function test_one_time_output_repeat_output_throws(): void {
54
        $page = new \moodle_page();
54
        $page = new \moodle_page();
55
        $page->requires->set_one_time_item_created('test_item');
55
        $page->requires->set_one_time_item_created('test_item');
Línea 56... Línea 56...
56
        $this->expectException('coding_exception');
56
        $this->expectException('coding_exception');
57
        $page->requires->set_one_time_item_created('test_item');
57
        $page->requires->set_one_time_item_created('test_item');
58
    }
58
    }
59
 
59
 
60
    public function test_one_time_output_different_pages_independent() {
60
    public function test_one_time_output_different_pages_independent(): void {
61
        $firstpage = new \moodle_page();
61
        $firstpage = new \moodle_page();
Línea 67... Línea 67...
67
    /**
67
    /**
68
     * Test for the jquery_plugin method.
68
     * Test for the jquery_plugin method.
69
     *
69
     *
70
     * Test to make sure that backslashes are not generated with either slasharguments set to on or off.
70
     * Test to make sure that backslashes are not generated with either slasharguments set to on or off.
71
     */
71
     */
72
    public function test_jquery_plugin() {
72
    public function test_jquery_plugin(): void {
73
        global $CFG, $PAGE;
73
        global $CFG, $PAGE;
Línea 74... Línea 74...
74
 
74
 
Línea 75... Línea 75...
75
        $this->resetAfterTest();
75
        $this->resetAfterTest();
Línea 105... Línea 105...
105
    }
105
    }
Línea 106... Línea 106...
106
 
106
 
107
    /**
107
    /**
108
     * Test AMD modules loading.
108
     * Test AMD modules loading.
109
     */
109
     */
Línea 110... Línea 110...
110
    public function test_js_call_amd() {
110
    public function test_js_call_amd(): void {
Línea 111... Línea 111...
111
 
111
 
112
        $page = new \moodle_page();
112
        $page = new \moodle_page();
Línea 146... Línea 146...
146
     * @see \page_requirements_manager::js_fix_url()
146
     * @see \page_requirements_manager::js_fix_url()
147
     * @see \moodle_url
147
     * @see \moodle_url
148
     * @covers \page_requirements_manager::js_fix_url
148
     * @covers \page_requirements_manager::js_fix_url
149
     * @dataProvider js_fix_url_moodle_url_provider
149
     * @dataProvider js_fix_url_moodle_url_provider
150
     */
150
     */
151
    public function test_js_fix_url_moodle_url(\moodle_url $moodleurl, int $cfgslashargs, string $expected) {
151
    public function test_js_fix_url_moodle_url(\moodle_url $moodleurl, int $cfgslashargs, string $expected): void {
152
        global $CFG;
152
        global $CFG;
153
        $defaultslashargs = $CFG->slasharguments;
153
        $defaultslashargs = $CFG->slasharguments;
Línea 154... Línea 154...
154
 
154
 
155
        $CFG->slasharguments = $cfgslashargs;
155
        $CFG->slasharguments = $cfgslashargs;
Línea 229... Línea 229...
229
     * @throws ReflectionException if the class does not exist.
229
     * @throws ReflectionException if the class does not exist.
230
     * @see \page_requirements_manager::js_fix_url()
230
     * @see \page_requirements_manager::js_fix_url()
231
     * @covers \page_requirements_manager::js_fix_url
231
     * @covers \page_requirements_manager::js_fix_url
232
     * @dataProvider js_fix_url_plain_string_provider
232
     * @dataProvider js_fix_url_plain_string_provider
233
     */
233
     */
234
    public function test_js_fix_url_plain_string(string $url, int $cfgslashargs, string $expected) {
234
    public function test_js_fix_url_plain_string(string $url, int $cfgslashargs, string $expected): void {
235
        global $CFG;
235
        global $CFG;
236
        $defaultslashargs = $CFG->slasharguments;
236
        $defaultslashargs = $CFG->slasharguments;
Línea 237... Línea 237...
237
 
237
 
238
        $CFG->slasharguments = $cfgslashargs;
238
        $CFG->slasharguments = $cfgslashargs;
Línea 309... Línea 309...
309
     * @throws ReflectionException if the class does not exist.
309
     * @throws ReflectionException if the class does not exist.
310
     * @see \page_requirements_manager::js_fix_url()
310
     * @see \page_requirements_manager::js_fix_url()
311
     * @covers \page_requirements_manager::js_fix_url
311
     * @covers \page_requirements_manager::js_fix_url
312
     * @dataProvider js_fix_url_coding_exception_provider
312
     * @dataProvider js_fix_url_coding_exception_provider
313
     */
313
     */
314
    public function test_js_fix_url_coding_exception($url, string $exmessage) {
314
    public function test_js_fix_url_coding_exception($url, string $exmessage): void {
315
        $rc = new \ReflectionClass(\page_requirements_manager::class);
315
        $rc = new \ReflectionClass(\page_requirements_manager::class);
316
        $rcm = $rc->getMethod('js_fix_url');
316
        $rcm = $rc->getMethod('js_fix_url');
317
        $requires = new \page_requirements_manager();
317
        $requires = new \page_requirements_manager();
318
        $this->expectException(\coding_exception::class);
318
        $this->expectException(\coding_exception::class);
319
        $this->expectExceptionMessage($exmessage);
319
        $this->expectExceptionMessage($exmessage);