Proyectos de Subversion Moodle

Rev

Ir a la última revisión | | 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 tool_brickfield\local\tool;
18
 
19
/**
20
 * Unit tests for {@printable tool_brickfield\local\tool\printable\tool}.
21
 *
22
 * @package   tool_brickfield
23
 * @copyright  2020 onward: Brickfield Education Labs, www.brickfield.ie
24
 * @author     Jay Churchward (jay.churchward@poetopensource.org)
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 */
27
class printable_test extends \advanced_testcase {
28
 
29
    /**
30
     * Test tool name.
31
     */
32
    public function test_toolname() {
33
        $this->resetAfterTest();
34
 
35
        $object = new printable();
36
        $output = $object->toolname();
37
        $this->assertEquals($output, 'Summary report');
38
    }
39
 
40
    /**
41
     * Test tool short name.
42
     */
43
    public function test_toolshortname() {
44
        $this->resetAfterTest();
45
 
46
        $object = new printable();
47
        $output = $object->toolshortname();
48
        $this->assertEquals($output, 'Summary report');
49
    }
50
 
51
    /**
52
     * Test plugin name.
53
     */
54
    public function test_pluginname() {
55
        $this->resetAfterTest();
56
 
57
        $object = new printable();
58
        $output = $object->pluginname();
59
        $this->assertEquals($output, 'printable');
60
    }
61
 
62
    /**
63
     * Can access.
64
     */
65
    public function can_access() {
66
        $this->resetAfterTest();
67
        $category = $this->getDataGenerator()->create_category();
68
 
69
        $filter = new filter(1, $category->id, 'tab', 3, 4);
70
        $filter->courseids = [];
71
 
72
        $object = new printable();
73
        $output = $object->can_access($filter);
74
        $this->assertFalse($output);
75
    }
76
 
77
    /**
78
     * Test get output.
79
     */
80
    public function test_get_output() {
81
        $this->resetAfterTest();
82
        $category = $this->getDataGenerator()->create_category();
83
 
84
        $filter = new filter(1, $category->id, 'printable', 3, 4);
85
        $filter->courseids = [];
86
 
87
        $filter->target = 'html';
88
        $object = new printable();
89
        $object->set_filter($filter);
90
        $output = $object->get_output();
91
        $this->assertStringContainsString('<h3>Course PHPUnit test site</h3><div id=', $output);
92
 
93
        $filter->target = '';
94
        $object = new printable();
95
        $object->set_filter($filter);
96
        $output = $object->get_output();
97
        $this->assertStringContainsString('<h3>Course PHPUnit test site</h3><a href=', $output);
98
 
99
        $filter->target = 'html';
100
        $object = new printable();
101
        $object->set_filter($filter);
102
        $output = $object->get_output();
103
        $this->assertStringContainsString('<i class="icon fa fa-tachometer fa-fw "  title="Total activities" '.
104
            'role="img" aria-label="Total activities">', $output);
105
    }
106
}