1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-01 06:20:46 +02:00

[ticket/11912] Add extension_guesser for guessing mimetype by extension

The content_guesser now only guesses the mimetype with the function
mime_content_type() while the guessing by extension is done using the
extension_guesser.

PHPBB3-11912
This commit is contained in:
Marc Alexander
2013-11-11 20:15:28 +01:00
parent 3bd4289562
commit b1719db47d
4 changed files with 535 additions and 483 deletions

View File

@@ -101,14 +101,23 @@ class guesser_test extends \phpbb_test_case
'image/jpeg',
'image/jpeg',
),
array(new \phpbb\mimetype\content_guesser),
false,
),
array(
array(
'application/octet-stream',
'application/octet-stream',
),
array(new \phpbb\mimetype\content_guesser),
true,
),
array(
array(
'application/octet-stream',
'image/jpeg',
),
true,
array(new \phpbb\mimetype\extension_guesser),
),
);
}
@@ -116,10 +125,10 @@ class guesser_test extends \phpbb_test_case
/**
* @dataProvider data_content_guesser
*/
public function test_content_guesser($expected, $overload = false)
public function test_content_guesser($expected, $guessers, $overload = false)
{
self::$function_exists = ($overload) ? false : true;
$guesser = new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\content_guesser));
$guesser = new \phpbb\mimetype\guesser($guessers);
$this->assertEquals($expected[0], $guesser->guess($this->jpg_file));
$this->assertEquals($expected[1], $guesser->guess($this->jpg_file, $this->jpg_file . '.jpg'));
@copy($this->jpg_file, $this->jpg_file . '.jpg');