Skip to content

Commit

Permalink
MDL-69187 core_file: Unit test for file_get_typegroup string types
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols authored and paulholden committed Aug 22, 2023
1 parent 37e9c47 commit 215f370
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions lib/tests/filelib_test.php
Expand Up @@ -1985,6 +1985,42 @@ public function test_file_prepare_standard_editor_clean_text() {
['noclean' => true, 'context' => $syscontext], $syscontext, 'core', 'some', 1);
$this->assertSame($text, $result->some);
}

/**
* Tests for file_get_typegroup to check that both arrays, and string values are accepted.
*
* @dataProvider file_get_typegroup_provider
* @param string|array $group
* @param string $expected
*/
public function test_file_get_typegroup(
string|array $group,
string $expected,
): void {
$result = file_get_typegroup('type', $group);
$this->assertContains($expected, $result);
}

public static function file_get_typegroup_provider(): array {
return [
'Array of values' => [
['.html', '.htm'],
'text/html',
],
'String of comma-separated values' => [
'.html, .htm',
'text/html',
],
'String of colon-separated values' => [
'.html : .htm',
'text/html',
],
'String of semi-colon-separated values' => [
'.html ; .htm',
'text/html',
],
];
}
}

/**
Expand Down

0 comments on commit 215f370

Please sign in to comment.