Skip to content

Commit

Permalink
MDL-56549 media_html5audio: 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_audio mime type extensions are
passing list_supported_urls method correctly.
  • Loading branch information
kabalin committed Oct 17, 2019
1 parent 043ba1b commit 4d8b88f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion media/player/html5audio/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() {
global $CFG;
require_once($CFG->libdir . '/filelib.php');

Expand All @@ -72,6 +72,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_audio');

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

// Make sure that the list of supported URLs is not filtering permitted extensions.
$player = new media_html5audio_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 4d8b88f

Please sign in to comment.