Skip to content

Commit

Permalink
MDL-56549 media_html5video: Add test for native extensions support.
Browse files Browse the repository at this point in the history
This is to verify that all files of html_video mime type extensions are
passing list_supported_urls method correctly.
  • Loading branch information
kabalin committed Oct 17, 2019
1 parent 4d8b88f commit 12ce73a
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion media/player/html5video/tests/player_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function test_is_installed() {
/**
* Test method get_supported_extensions()
*/
public function test_supported_extensions() {
public function test_get_supported_extensions() {
$nativeextensions = file_get_typegroup('extension', 'html_video');

// Make sure that the list of extensions from the setting is exactly the same as html_video group.
Expand All @@ -69,6 +69,25 @@ public function test_supported_extensions() {
$this->assertEmpty(array_diff($nativeextensions, $player->get_supported_extensions()));
}

/**
* Test method list_supported_urls()
*/
public function test_list_supported_urls() {
global $CFG;
require_once($CFG->libdir . '/filelib.php');

$nativeextensions = file_get_typegroup('extension', 'html_video');

// Create list of URLs for each extension.
$urls = array_map(function($ext){
return new moodle_url('http://example.org/video.' . $ext);
}, $nativeextensions);

// Make sure that the list of supported URLs is not filtering permitted extensions.
$player = new media_html5video_plugin();
$this->assertCount(count($urls), $player->list_supported_urls($urls));
}

/**
* Test embedding without media filter (for example for displaying file resorce).
*/
Expand Down

0 comments on commit 12ce73a

Please sign in to comment.