mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/13031] Slightly change behavior of choose_mime_type and add unit tests
The mime type 'application/octet-stream' will still always be overwritten by proper guesses. However, guesses with guessers that have a higher priority will now overwrite previous guesses even if the mime types of these guesses had a slash in them. PHPBB3-13031
This commit is contained in:
@@ -206,4 +206,25 @@ class guesser_test extends \phpbb_test_case
|
||||
$this->assertInstanceOf('\phpbb\mimetype\content_guesser', $guessers[0]);
|
||||
$this->assertInstanceOf('\phpbb\mimetype\extension_guesser', $guessers[3]);
|
||||
}
|
||||
|
||||
public function data_choose_mime_type()
|
||||
{
|
||||
return array(
|
||||
array('application/octet-stream', 'application/octet-stream', null),
|
||||
array('application/octet-stream', 'application/octet-stream', 'application/octet-stream'),
|
||||
array('binary', 'application/octet-stream', 'binary'),
|
||||
array('image/jpeg', 'application/octet-stream', 'image/jpeg'),
|
||||
array('image/jpeg', 'binary', 'image/jpeg'),
|
||||
array('image/jpeg', 'image/jpg', 'image/jpeg'),
|
||||
array('image/jpeg', 'image/jpeg', 'binary'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_choose_mime_type
|
||||
*/
|
||||
public function test_choose_mime_type($expected, $mime_type, $guess)
|
||||
{
|
||||
$this->assertSame($expected, $this->guesser->choose_mime_type($mime_type, $guess));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user