Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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 format_social;
18
 
19
/**
20
 * Social course format related unit tests.
21
 *
22
 * @package    format_social
23
 * @copyright  2023 Sara Arjona <sara@moodle.com>
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 * @covers     \format_social
26
 */
27
class format_social_test extends \advanced_testcase {
28
 
29
    /**
30
     * Test for get_view_url().
31
     *
32
     * @covers ::get_view_url
33
     */
34
    public function test_get_view_url(): void {
35
        global $CFG;
36
        $this->resetAfterTest();
37
 
38
        // Generate a course with two sections (0 and 1) and two modules.
39
        $generator = $this->getDataGenerator();
40
        $course1 = $generator->create_course(['format' => 'social']);
41
        course_create_sections_if_missing($course1, [0, 1]);
42
 
43
        $data = (object)['id' => $course1->id];
44
        $format = course_get_format($course1);
45
        $format->update_course_format_options($data);
46
 
47
        // In page.
48
        $this->assertNotEmpty($format->get_view_url(null));
49
        $this->assertNotEmpty($format->get_view_url(0));
50
        $this->assertNotEmpty($format->get_view_url(1));
51
 
52
        // Navigation.
53
        $this->assertStringContainsString('course/view.php', $format->get_view_url(0));
54
        $this->assertStringContainsString('course/view.php', $format->get_view_url(1));
55
        $this->assertStringContainsString('course/view.php', $format->get_view_url(0, ['navigation' => 1]));
56
        $this->assertStringContainsString('course/view.php', $format->get_view_url(1, ['navigation' => 1]));
57
        $this->assertStringContainsString('course/view.php', $format->get_view_url(0, ['sr' => 1]));
58
        $this->assertStringContainsString('course/view.php', $format->get_view_url(1, ['sr' => 1]));
59
        $this->assertStringContainsString('course/view.php', $format->get_view_url(0, ['sr' => 0]));
60
        $this->assertStringContainsString('course/view.php', $format->get_view_url(1, ['sr' => 0]));
61
    }
62
 
63
    /**
64
     * Test get_required_jsfiles().
65
     *
66
     * @covers ::get_required_jsfiles
67
     */
68
    public function test_get_required_jsfiles(): void {
69
        $this->resetAfterTest();
70
 
71
        $generator = $this->getDataGenerator();
72
 
73
        $course = $generator->create_course(['format' => 'social']);
74
        $format = course_get_format($course);
75
        $this->assertEmpty($format->get_required_jsfiles());
76
    }
77
}