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 core;
18
 
19
/**
20
 * Tests for \core_userfeedback
21
 *
22
 * @package    core
23
 * @category   test
24
 * @copyright  2024 Andrew Lyons <andrew@nicols.co.uk>
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 * @covers \core_userfeedback
27
 */
28
final class core_userfeedback_test extends \advanced_testcase {
29
    public function test_footer_not_added_if_disabled(): void {
30
        $this->resetAfterTest();
31
        $this->setAdminUser();
32
 
33
        $page = new \moodle_page();
34
        $renderer = new \core_renderer($page, RENDERER_TARGET_GENERAL);
35
 
36
        $html = $renderer->standard_footer_html();
37
        $this->assertStringNotContainsString(
38
            get_string('calltofeedback_give', 'core'),
39
            $html,
40
        );
41
    }
42
 
43
    public function test_footer_added_if_enabled_loggedin(): void {
44
        $this->resetAfterTest();
45
        $this->setAdminUser();
46
 
47
        set_config('enableuserfeedback', 1);;
48
 
49
        $page = new \moodle_page();
50
        $renderer = new \core_renderer($page, RENDERER_TARGET_GENERAL);
51
 
52
        $html = $renderer->standard_footer_html();
53
        $this->assertStringContainsString(
54
            get_string('calltofeedback_give', 'core'),
55
            $html,
56
        );
57
    }
58
 
59
    public function test_footer_not_added_if_loggedout(): void {
60
        $this->resetAfterTest();
61
 
62
        set_config('enableuserfeedback', 1);;
63
 
64
        $page = new \moodle_page();
65
        $renderer = new \core_renderer($page, RENDERER_TARGET_GENERAL);
66
 
67
        $html = $renderer->standard_footer_html();
68
        $this->assertStringNotContainsString(
69
            get_string('calltofeedback_give', 'core'),
70
            $html,
71
        );
72
    }
73
}