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:
@@ -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');
|
||||
|
Reference in New Issue
Block a user