Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 28... Línea 28...
28
 
28
 
Línea 29... Línea 29...
29
require_once('all_checks.php');
29
require_once('all_checks.php');
30
 
30
 
-
 
31
/**
-
 
32
 * Class table_data_should_have_th_test
31
/**
33
 *
32
 * Class table_data_should_have_th_test
34
 * @covers \tool_brickfield\local\htmlchecker\common\checks\table_data_should_have_th
33
 */
35
 */
34
class table_data_should_have_th_test extends all_checks {
36
final class table_data_should_have_th_test extends all_checks {
Línea 35... Línea 37...
35
    /** @var string Check type */
37
    /** @var string Check type */
36
    public $checktype = 'table_data_should_have_th';
38
    public $checktype = 'table_data_should_have_th';
Línea 112... Línea 114...
112
            <tr><td>This is a tables data</td></tr>
114
            <tr><td>This is a tables data</td></tr>
113
        </table>
115
        </table>
114
    </body>
116
    </body>
115
</html>
117
</html>
116
EOD;
118
EOD;
-
 
119
 
-
 
120
    /** @var string HTML that should not get flagged. */
-
 
121
    private $htmlpass3 = <<<EOD
-
 
122
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-
 
123
<html>
-
 
124
    <head>
-
 
125
        <title>Table should have at least one th - pass</title>
-
 
126
    </head>
-
 
127
    <body>
-
 
128
        <table>
-
 
129
            <thead>
-
 
130
                <tr>
-
 
131
                    <th>
-
 
132
                        This is table heading
-
 
133
                    </th>
-
 
134
                </tr>
-
 
135
            </thead>
-
 
136
            <tbody>
-
 
137
                <tr>
-
 
138
                    <td>
-
 
139
                        This is a tables data
-
 
140
                    </td>
-
 
141
                </tr>
-
 
142
            </tbody>
-
 
143
        </table>
-
 
144
    </body>
-
 
145
</html>
-
 
146
EOD;
-
 
147
 
-
 
148
    /** @var string HTML that should not get flagged. */
-
 
149
    private $htmlpass4 = <<<EOD
-
 
150
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-
 
151
<html>
-
 
152
    <head>
-
 
153
        <title>Table should have at least one th - pass</title>
-
 
154
    </head>
-
 
155
    <body>
-
 
156
        <table>
-
 
157
            <tr>
-
 
158
                <th>
-
 
159
                    This is table heading
-
 
160
                </th>
-
 
161
            </tr>
-
 
162
            <tr>
-
 
163
                <td>
-
 
164
                    This is a tables data
-
 
165
                </td>
-
 
166
            </tr>
-
 
167
        </table>
-
 
168
    </body>
-
 
169
</html>
-
 
170
EOD;
-
 
171
 
-
 
172
    /** @var string HTML that should not get flagged. */
-
 
173
    private $htmlpass5 = <<<EOD
-
 
174
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-
 
175
<html>
-
 
176
    <head>
-
 
177
        <title>Table should have at least one th - pass</title>
-
 
178
    </head>
-
 
179
    <body>
-
 
180
        <table>
-
 
181
            <thead>
-
 
182
                <tr>
-
 
183
                    <th>
-
 
184
                        This is table heading
-
 
185
                    </th>
-
 
186
                </tr>
-
 
187
            </thead>
-
 
188
            <tbody>
-
 
189
                <tr>
-
 
190
                    <th>
-
 
191
                        This is a table heading in table data
-
 
192
                    </th>
-
 
193
                </tr>
-
 
194
                <tr>
-
 
195
                    <td>
-
 
196
                        This is a tables data
-
 
197
                    </td>
-
 
198
                </tr>
-
 
199
            </tbody>
-
 
200
        </table>
-
 
201
    </body>
-
 
202
</html>
-
 
203
EOD;
-
 
204
 
-
 
205
    /** @var string HTML that should not get flagged. */
-
 
206
    private $htmlpass6 = <<<EOD
-
 
207
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-
 
208
<html>
-
 
209
    <head>
-
 
210
        <title>Table should have at least one th - pass</title>
-
 
211
    </head>
-
 
212
    <body>
-
 
213
        <table>
-
 
214
            <tbody>
-
 
215
                <tr>
-
 
216
                    <th>
-
 
217
                        This is a table heading in table data
-
 
218
                    </th>
-
 
219
                </tr>
-
 
220
                <tr>
-
 
221
                    <td>
-
 
222
                        This is a tables data
-
 
223
                    </td>
-
 
224
                </tr>
-
 
225
            </tbody>
-
 
226
        </table>
-
 
227
    </body>
-
 
228
</html>
-
 
229
EOD;
117
    /**
230
    /**
118
     * Test that th does not exist
231
     * Test that th does not exist
119
     */
232
     */
120
    public function test_check_fail(): void {
233
    public function test_check_fail(): void {
121
        $results = $this->get_checker_results($this->htmlfail1);
234
        $results = $this->get_checker_results($this->htmlfail1);
Línea 132... Línea 245...
132
        $results = $this->get_checker_results($this->htmlpass1);
245
        $results = $this->get_checker_results($this->htmlpass1);
133
        $this->assertEmpty($results);
246
        $this->assertEmpty($results);
Línea 134... Línea 247...
134
 
247
 
135
        $results = $this->get_checker_results($this->htmlpass2);
248
        $results = $this->get_checker_results($this->htmlpass2);
-
 
249
        $this->assertEmpty($results);
-
 
250
 
-
 
251
        $results = $this->get_checker_results($this->htmlpass3);
-
 
252
        $this->assertEmpty($results);
-
 
253
 
-
 
254
        $results = $this->get_checker_results($this->htmlpass4);
-
 
255
        $this->assertEmpty($results);
-
 
256
 
-
 
257
        $results = $this->get_checker_results($this->htmlpass5);
-
 
258
        $this->assertEmpty($results);
-
 
259
 
-
 
260
        $results = $this->get_checker_results($this->htmlpass6);
136
        $this->assertEmpty($results);
261
        $this->assertEmpty($results);
137
    }
262
    }