Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 22... Línea 22...
22
 * @package    mod_label
22
 * @package    mod_label
23
 * @category   test
23
 * @category   test
24
 * @copyright  2017 Mark Nelson <markn@moodle.com>
24
 * @copyright  2017 Mark Nelson <markn@moodle.com>
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 */
26
 */
27
class lib_test extends \advanced_testcase {
27
final class lib_test extends \advanced_testcase {
Línea 28... Línea 28...
28
 
28
 
29
    /**
29
    /**
30
     * Set up.
30
     * Set up.
31
     */
31
     */
-
 
32
    public function setUp(): void {
32
    public function setUp(): void {
33
        parent::setUp();
33
        $this->resetAfterTest();
34
        $this->resetAfterTest();
34
        $this->setAdminUser();
35
        $this->setAdminUser();
Línea 35... Línea 36...
35
    }
36
    }
Línea 232... Línea 233...
232
    /**
233
    /**
233
     * Dataprovider for test_label_get_label_name
234
     * Dataprovider for test_label_get_label_name
234
     *
235
     *
235
     * @return array
236
     * @return array
236
     */
237
     */
237
    public function label_get_name_data_provider(): array {
238
    public static function label_get_name_data_provider(): array {
238
        return [
239
        return [
239
            'withlabelname' => [
240
            'withlabelname' => [
240
                'name' => 'Test label 1',
241
                'name' => 'Test label 1',
241
                'content' => '<p>Simple textual content<p>',
242
                'content' => '<p>Simple textual content<p>',
242
                'format' => FORMAT_HTML,
243
                'format' => FORMAT_HTML,
243
                'expected' => 'Test label 1'
244
                'expectedname' => 'Test label 1'
244
            ],
245
            ],
245
            'simple' => [
246
            'simple' => [
246
                'name' => '',
247
                'name' => '',
247
                'content' => '<p>Simple textual content<p>',
248
                'content' => '<p>Simple textual content<p>',
248
                'format' => FORMAT_HTML,
249
                'format' => FORMAT_HTML,
249
                'expected' => 'Simple textual content'
250
                'expectedname' => 'Simple textual content'
250
            ],
251
            ],
251
            'empty' => [
252
            'empty' => [
252
                'name' => '',
253
                'name' => '',
253
                'content' => '',
254
                'content' => '',
254
                'format' => FORMAT_HTML,
255
                'format' => FORMAT_HTML,
255
                'expected' => 'Test label 1'
256
                'expectedname' => 'Test label 1'
256
            ],
257
            ],
257
            'withaudiocontent' => [
258
            'withaudiocontent' => [
258
                'name' => '',
259
                'name' => '',
259
                'content' => '<p>Test with audio</p>
260
                'content' => '<p>Test with audio</p>
260
<p>&nbsp; &nbsp;<audio controls="controls">
261
<p>&nbsp; &nbsp;<audio controls="controls">
261
<source src="@@PLUGINFILE@@/moodle-hit-song.mp3">
262
<source src="@@PLUGINFILE@@/moodle-hit-song.mp3">
262
@@PLUGINFILE@@/moodle-hit-song.mp3
263
@@PLUGINFILE@@/moodle-hit-song.mp3
263
</audio>&nbsp;</p>',
264
</audio>&nbsp;</p>',
264
                'format' => FORMAT_HTML,
265
                'format' => FORMAT_HTML,
265
                'expected' => 'Test with audio'
266
                'expectedname' => 'Test with audio'
266
            ],
267
            ],
267
            'withvideo' => [
268
            'withvideo' => [
268
                'name' => '',
269
                'name' => '',
269
                'content' => '<p>Test video</p>
270
                'content' => '<p>Test video</p>
270
<p>&nbsp;<video controls="controls">
271
<p>&nbsp;<video controls="controls">
271
        <source src="https://www.youtube.com/watch?v=xxxyy">
272
        <source src="https://www.youtube.com/watch?v=xxxyy">
272
    https://www.youtube.com/watch?v=xxxyy
273
    https://www.youtube.com/watch?v=xxxyy
273
</video>&nbsp;</p>',
274
</video>&nbsp;</p>',
274
                'format' => FORMAT_HTML,
275
                'format' => FORMAT_HTML,
275
                'expected' => 'Test video https://www.youtube.com/watch?v=xxxyy'
276
                'expectedname' => 'Test video https://www.youtube.com/watch?v=xxxyy'
276
            ],
277
            ],
277
            'with video trimming' => [
278
            'with video trimming' => [
278
                'name' => '',
279
                'name' => '',
279
                'content' => '<p>Test with video to be trimmed</p>
280
                'content' => '<p>Test with video to be trimmed</p>
280
<p>&nbsp;<video controls="controls">
281
<p>&nbsp;<video controls="controls">
281
        <source src="https://www.youtube.com/watch?v=xxxyy">
282
        <source src="https://www.youtube.com/watch?v=xxxyy">
282
    https://www.youtube.com/watch?v=xxxyy
283
    https://www.youtube.com/watch?v=xxxyy
283
</video>&nbsp;</p>',
284
</video>&nbsp;</p>',
284
                'format' => FORMAT_HTML,
285
                'format' => FORMAT_HTML,
285
                'expected' => 'Test with video to be trimmed https://www.youtube....'
286
                'expectedname' => 'Test with video to be trimmed https://www.youtube....'
286
            ],
287
            ],
287
            'with plain text' => [
288
            'with plain text' => [
288
                'name' => '',
289
                'name' => '',
289
                'content' => 'Content with @@PLUGINFILE@@/moodle-hit-song.mp3 nothing',
290
                'content' => 'Content with @@PLUGINFILE@@/moodle-hit-song.mp3 nothing',
290
                'format' => FORMAT_HTML,
291
                'format' => FORMAT_HTML,
291
                'expected' => 'Content with nothing'
292
                'expectedname' => 'Content with nothing'
292
            ],
293
            ],
293
            'with several spaces' => [
294
            'with several spaces' => [
294
                'name' => '',
295
                'name' => '',
295
                'content' => "Content with @@PLUGINFILE@@/moodle-hit-song.mp3 \r &nbsp; several spaces",
296
                'content' => "Content with @@PLUGINFILE@@/moodle-hit-song.mp3 \r &nbsp; several spaces",
296
                'format' => FORMAT_HTML,
297
                'format' => FORMAT_HTML,
297
                'expected' => 'Content with several spaces'
298
                'expectedname' => 'Content with several spaces'
298
            ],
299
            ],
299
            'empty spaces' => [
300
            'empty spaces' => [
300
                'name' => '',
301
                'name' => '',
301
                'content' => ' &nbsp; ',
302
                'content' => ' &nbsp; ',
302
                'format' => FORMAT_HTML,
303
                'format' => FORMAT_HTML,
303
                'expected' => 'Text and media area'
304
                'expectedname' => 'Text and media area'
304
            ],
305
            ],
305
            'only html' => [
306
            'only html' => [
306
                'name' => '',
307
                'name' => '',
307
                'content' => '<audio controls="controls"><source src=""></audio>',
308
                'content' => '<audio controls="controls"><source src=""></audio>',
308
                'format' => FORMAT_HTML,
309
                'format' => FORMAT_HTML,
309
                'expected' => 'Text and media area'
310
                'expectedname' => 'Text and media area'
310
            ],
311
            ],
311
            'markdown' => [
312
            'markdown' => [
312
                'name' => '',
313
                'name' => '',
313
                'content' => "##Simple Title\n simple markdown format",
314
                'content' => "##Simple Title\n simple markdown format",
314
                'format' => FORMAT_MARKDOWN,
315
                'format' => FORMAT_MARKDOWN,
315
                'expected' => 'Simple Title simple markdown format'
316
                'expectedname' => 'Simple Title simple markdown format'
316
            ],
317
            ],
317
            'markdown with pluginfile' => [
318
            'markdown with pluginfile' => [
318
                'name' => '',
319
                'name' => '',
319
                'content' => "##Simple Title\n simple markdown format @@PLUGINFILE@@/moodle-hit-song.mp3",
320
                'content' => "##Simple Title\n simple markdown format @@PLUGINFILE@@/moodle-hit-song.mp3",
320
                'format' => FORMAT_MARKDOWN,
321
                'format' => FORMAT_MARKDOWN,
321
                'expected' => 'Simple Title simple markdown format'
322
                'expectedname' => 'Simple Title simple markdown format'
322
            ],
323
            ],
323
            'plain text' => [
324
            'plain text' => [
324
                'name' => '',
325
                'name' => '',
325
                'content' => "Simple plain text @@PLUGINFILE@@/moodle-hit-song.mp3",
326
                'content' => "Simple plain text @@PLUGINFILE@@/moodle-hit-song.mp3",
326
                'format' => FORMAT_PLAIN,
327
                'format' => FORMAT_PLAIN,
327
                'expected' => 'Simple plain text'
328
                'expectedname' => 'Simple plain text'
328
            ],
329
            ],
329
            'moodle format text' => [
330
            'moodle format text' => [
330
                'name' => '',
331
                'name' => '',
331
                'content' => "Simple plain text @@PLUGINFILE@@/moodle-hit-song.mp3",
332
                'content' => "Simple plain text @@PLUGINFILE@@/moodle-hit-song.mp3",
332
                'format' => FORMAT_MOODLE,
333
                'format' => FORMAT_MOODLE,
333
                'expected' => 'Simple plain text'
334
                'expectedname' => 'Simple plain text'
334
            ],
335
            ],
335
            'html format text' => [
336
            'html format text' => [
336
                'name' => '',
337
                'name' => '',
337
                'content' => "<h1>Simple plain title</h1><p> with plain text</p> @@PLUGINFILE@@/moodle-hit-song.mp3",
338
                'content' => "<h1>Simple plain title</h1><p> with plain text</p> @@PLUGINFILE@@/moodle-hit-song.mp3",
338
                'format' => FORMAT_HTML,
339
                'format' => FORMAT_HTML,
339
                'expected' => 'Simple plain title with plain text'
340
                'expectedname' => 'Simple plain title with plain text'
340
            ],
341
            ],
341
        ];
342
        ];
342
    }
343
    }
Línea 343... Línea 344...
343
 
344