diff options
author | marc1706 <admin@m-a-styles.de> | 2014-01-03 13:30:52 +0100 |
---|---|---|
committer | marc1706 <admin@m-a-styles.de> | 2014-01-03 13:30:52 +0100 |
commit | 8ebf5bb8d1070b214ba3bc7a900da46283ebb510 (patch) | |
tree | f3147cfaf8239ab932b4d0deccbd312f5d460f53 /tests | |
parent | db94f80c5ba117ca410bb2aafa3ae5c02dcf11c8 (diff) | |
download | forums-8ebf5bb8d1070b214ba3bc7a900da46283ebb510.tar forums-8ebf5bb8d1070b214ba3bc7a900da46283ebb510.tar.gz forums-8ebf5bb8d1070b214ba3bc7a900da46283ebb510.tar.bz2 forums-8ebf5bb8d1070b214ba3bc7a900da46283ebb510.tar.xz forums-8ebf5bb8d1070b214ba3bc7a900da46283ebb510.zip |
[ticket/12071] Skip tests that depend on fileinfo and fix expected results
Tests that depend on fileinfo being enabled will now be skipped to prevent
fatal errors while running the test suite. The expected results will be
modified to "application/octet-stream" in test_guess_files() if only the
extension_guesser is available due to the non-existing extension of those
files.
PHPBB3-12071
Diffstat (limited to 'tests')
-rw-r--r-- | tests/mimetype/guesser_test.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php index 9f0371262b..244293020f 100644 --- a/tests/mimetype/guesser_test.php +++ b/tests/mimetype/guesser_test.php @@ -19,7 +19,9 @@ function function_exists($name) class guesser_test extends \phpbb_test_case { - public static $function_exists = true; + public static $function_exists = false; + + protected $fileinfo_supported = false; public function setUp() { @@ -28,7 +30,13 @@ class guesser_test extends \phpbb_test_case $guessers = array( new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser(), new \Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser(), + new \phpbb\mimetype\extension_guesser, + new \phpbb\mimetype\content_guesser, ); + + // Check if any guesser except the extension_guesser is available + $this->fileinfo_supported = (bool) $guessers[0]->isSupported() | $guessers[1]->isSupported() | $guessers[3]->is_supported(); + $this->guesser = new \phpbb\mimetype\guesser($guessers); $this->path = dirname(__FILE__); $this->jpg_file = $this->path . '/fixtures/jpg'; @@ -52,6 +60,12 @@ class guesser_test extends \phpbb_test_case */ public function test_guess_files($expected, $file) { + // We will always get application/octet-stream as mimetype if only the + // extension guesser is supported + if ($expected && !$this->fileinfo_supported) + { + $expected = 'application/octet-stream'; + } $this->assertEquals($expected, $this->guesser->guess($this->path . '/../upload/fixture/' . $file)); } @@ -130,6 +144,11 @@ class guesser_test extends \phpbb_test_case $supported = false; self::$function_exists = !$overload; + if (!\function_exists('mime_content_type')) + { + $this->markTestSkipped('Emulating supported mime_content_type() when it is not supported will cause a fatal error'); + } + // Cover possible LogicExceptions foreach ($guessers as $cur_guesser) { |