Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 39... Línea 39...
39
class html_writer_test extends basic_testcase {
39
class html_writer_test extends basic_testcase {
Línea 40... Línea 40...
40
 
40
 
41
    /**
41
    /**
42
     * @covers ::start_tag
42
     * @covers ::start_tag
43
     */
43
     */
44
    public function test_start_tag() {
44
    public function test_start_tag(): void {
45
        $this->assertSame('<div>', html_writer::start_tag('div'));
45
        $this->assertSame('<div>', html_writer::start_tag('div'));
Línea 46... Línea 46...
46
    }
46
    }
47
 
47
 
48
    /**
48
    /**
49
     * @covers ::start_tag
49
     * @covers ::start_tag
50
     */
50
     */
51
    public function test_start_tag_with_attr() {
51
    public function test_start_tag_with_attr(): void {
52
        $this->assertSame('<div class="frog">',
52
        $this->assertSame('<div class="frog">',
Línea 53... Línea 53...
53
            html_writer::start_tag('div', array('class' => 'frog')));
53
            html_writer::start_tag('div', array('class' => 'frog')));
54
    }
54
    }
55
 
55
 
56
    /**
56
    /**
57
     * @covers ::start_tag
57
     * @covers ::start_tag
58
     */
58
     */
59
    public function test_start_tag_with_attrs() {
59
    public function test_start_tag_with_attrs(): void {
Línea 60... Línea 60...
60
        $this->assertSame('<div class="frog" id="mydiv">',
60
        $this->assertSame('<div class="frog" id="mydiv">',
61
            html_writer::start_tag('div', array('class' => 'frog', 'id' => 'mydiv')));
61
            html_writer::start_tag('div', array('class' => 'frog', 'id' => 'mydiv')));
62
    }
62
    }
63
 
63
 
64
    /**
64
    /**
65
     * @covers ::end_tag
65
     * @covers ::end_tag
Línea 66... Línea 66...
66
     */
66
     */
67
    public function test_end_tag() {
67
    public function test_end_tag(): void {
68
        $this->assertSame('</div>', html_writer::end_tag('div'));
68
        $this->assertSame('</div>', html_writer::end_tag('div'));
69
    }
69
    }
70
 
70
 
71
    /**
71
    /**
Línea 72... Línea 72...
72
     * @covers ::empty_Tag
72
     * @covers ::empty_Tag
73
     */
73
     */
74
    public function test_empty_tag() {
74
    public function test_empty_tag(): void {
75
        $this->assertSame('<br />', html_writer::empty_tag('br'));
75
        $this->assertSame('<br />', html_writer::empty_tag('br'));
76
    }
76
    }
77
 
77
 
78
    /**
78
    /**
Línea 79... Línea 79...
79
     * @covers ::empty_Tag
79
     * @covers ::empty_Tag
80
     */
80
     */
81
    public function test_empty_tag_with_attrs() {
81
    public function test_empty_tag_with_attrs(): void {
82
        $this->assertSame('<input type="submit" value="frog" />',
82
        $this->assertSame('<input type="submit" value="frog" />',
83
            html_writer::empty_tag('input', array('type' => 'submit', 'value' => 'frog')));
83
            html_writer::empty_tag('input', array('type' => 'submit', 'value' => 'frog')));
84
    }
84
    }
85
 
85
 
Línea 86... Línea 86...
86
    /**
86
    /**
87
     * @covers ::nonempty_tag
87
     * @covers ::nonempty_tag
88
     */
88
     */
89
    public function test_nonempty_tag_with_content() {
89
    public function test_nonempty_tag_with_content(): void {
90
        $this->assertSame('<div>Hello world!</div>',
90
        $this->assertSame('<div>Hello world!</div>',
91
            html_writer::nonempty_tag('div', 'Hello world!'));
91
            html_writer::nonempty_tag('div', 'Hello world!'));
92
    }
92
    }
Línea 93... Línea 93...
93
 
93
 
94
    /**
94
    /**
95
     * @covers ::nonempty_tag
95
     * @covers ::nonempty_tag
96
     */
96
     */
97
    public function test_nonempty_tag_empty() {
97
    public function test_nonempty_tag_empty(): void {
98
        $this->assertSame('',
98
        $this->assertSame('',
99
            html_writer::nonempty_tag('div', ''));
99
            html_writer::nonempty_tag('div', ''));
Línea 100... Línea 100...
100
    }
100
    }
101
 
101
 
102
    /**
102
    /**
103
     * @covers ::nonempty_tag
103
     * @covers ::nonempty_tag
104
     */
104
     */
105
    public function test_nonempty_tag_null() {
105
    public function test_nonempty_tag_null(): void {
106
        $this->assertSame('',
106
        $this->assertSame('',
Línea 107... Línea 107...
107
            html_writer::nonempty_tag('div', null));
107
            html_writer::nonempty_tag('div', null));
108
    }
108
    }
109
 
109
 
110
    /**
110
    /**
111
     * @covers ::nonempty_tag
111
     * @covers ::nonempty_tag
112
     */
112
     */
113
    public function test_nonempty_tag_zero() {
113
    public function test_nonempty_tag_zero(): void {
Línea 114... Línea 114...
114
        $this->assertSame('<div class="score">0</div>',
114
        $this->assertSame('<div class="score">0</div>',
115
            html_writer::nonempty_tag('div', 0, array('class' => 'score')));
115
            html_writer::nonempty_tag('div', 0, array('class' => 'score')));
116
    }
116
    }
117
 
117
 
118
    /**
118
    /**
119
     * @covers ::nonempty_tag
119
     * @covers ::nonempty_tag
120
     */
120
     */
121
    public function test_nonempty_tag_zero_string() {
121
    public function test_nonempty_tag_zero_string(): void {
122
        $this->assertSame('<div class="score">0</div>',
122
        $this->assertSame('<div class="score">0</div>',
Línea 145... Línea 145...
145
    }
145
    }
Línea 146... Línea 146...
146
 
146
 
147
    /**
147
    /**
148
     * @covers ::start_div
148
     * @covers ::start_div
149
     */
149
     */
150
    public function test_start_div() {
150
    public function test_start_div(): void {
151
        // All options.
151
        // All options.
152
        $this->assertSame('<div class="frog" id="kermit">',
152
        $this->assertSame('<div class="frog" id="kermit">',
153
                html_writer::start_div('frog', array('id' => 'kermit')));
153
                html_writer::start_div('frog', array('id' => 'kermit')));
154
        // Combine class from attributes and $class.
154
        // Combine class from attributes and $class.
Línea 166... Línea 166...
166
    }
166
    }
Línea 167... Línea 167...
167
 
167
 
168
    /**
168
    /**
169
     * @covers ::end_div
169
     * @covers ::end_div
170
     */
170
     */
171
    public function test_end_div() {
171
    public function test_end_div(): void {
172
        $this->assertSame('</div>', html_writer::end_div());
172
        $this->assertSame('</div>', html_writer::end_div());
Línea 173... Línea 173...
173
    }
173
    }
174
 
174
 
175
    /**
175
    /**
176
     * @covers ::span
176
     * @covers ::span
177
     */
177
     */
178
    public function test_span() {
178
    public function test_span(): void {
179
        // All options.
179
        // All options.
180
        $this->assertSame('<span class="frog" id="kermit">ribbit</span>',
180
        $this->assertSame('<span class="frog" id="kermit">ribbit</span>',
181
                html_writer::span('ribbit', 'frog', array('id' => 'kermit')));
181
                html_writer::span('ribbit', 'frog', array('id' => 'kermit')));
Línea 194... Línea 194...
194
    }
194
    }
Línea 195... Línea 195...
195
 
195
 
196
    /**
196
    /**
197
     * @covers ::start_span
197
     * @covers ::start_span
198
     */
198
     */
199
    public function test_start_span() {
199
    public function test_start_span(): void {
200
        // All options.
200
        // All options.
201
        $this->assertSame('<span class="frog" id="kermit">',
201
        $this->assertSame('<span class="frog" id="kermit">',
202
                html_writer::start_span('frog', array('id' => 'kermit')));
202
                html_writer::start_span('frog', array('id' => 'kermit')));
203
        // Combine class from attributes and $class.
203
        // Combine class from attributes and $class.
Línea 215... Línea 215...
215
    }
215
    }
Línea 216... Línea 216...
216
 
216
 
217
    /**
217
    /**
218
     * @covers ::end_span
218
     * @covers ::end_span
219
     */
219
     */
220
    public function test_end_span() {
220
    public function test_end_span(): void {
221
        $this->assertSame('</span>', html_writer::end_span());
221
        $this->assertSame('</span>', html_writer::end_span());
Línea 222... Línea 222...
222
    }
222
    }
223
 
223
 
224
    /**
224
    /**
225
     * @covers ::table
225
     * @covers ::table
226
     * @covers \html_table_row
226
     * @covers \html_table_row
227
     * @covers \html_table_cell
227
     * @covers \html_table_cell
228
     * @covers \html_table
228
     * @covers \html_table
229
     */
229
     */
Línea 230... Línea 230...
230
    public function test_table() {
230
    public function test_table(): void {
231
        $row = new html_table_row();
231
        $row = new html_table_row();
232
 
232
 
Línea 277... Línea 277...
277
    }
277
    }
Línea 278... Línea 278...
278
 
278
 
279
    /**
279
    /**
280
     * @covers ::table
280
     * @covers ::table
281
     */
281
     */
Línea 282... Línea 282...
282
    public function test_table_hidden_caption() {
282
    public function test_table_hidden_caption(): void {
283
 
283
 
284
        $table = new html_table();
284
        $table = new html_table();
285
        $table->id = "whodat";
285
        $table->id = "whodat";