aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mimetype/guesser_test.php
diff options
context:
space:
mode:
authormarc1706 <admin@m-a-styles.de>2014-01-03 16:40:12 +0100
committermarc1706 <admin@m-a-styles.de>2014-01-03 16:40:12 +0100
commit98aebabd73e0be202f91a31f3f689a8bccd01079 (patch)
treedfd9a492a29029351c629ddc3866cd037d124a5b /tests/mimetype/guesser_test.php
parentf111a9262fdca8668e57e3cc4230107e75d957a7 (diff)
downloadforums-98aebabd73e0be202f91a31f3f689a8bccd01079.tar
forums-98aebabd73e0be202f91a31f3f689a8bccd01079.tar.gz
forums-98aebabd73e0be202f91a31f3f689a8bccd01079.tar.bz2
forums-98aebabd73e0be202f91a31f3f689a8bccd01079.tar.xz
forums-98aebabd73e0be202f91a31f3f689a8bccd01079.zip
[ticket/12071] Add test that covers not available fileinfo
The newly added test case will also emulate a non-existing fileinfo in order to check if the mimetype guesser is properly working when fileinfo is not available. PHPBB3-12071
Diffstat (limited to 'tests/mimetype/guesser_test.php')
-rw-r--r--tests/mimetype/guesser_test.php24
1 files changed, 22 insertions, 2 deletions
diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php
index a211b99147..7c58340a7a 100644
--- a/tests/mimetype/guesser_test.php
+++ b/tests/mimetype/guesser_test.php
@@ -37,6 +37,9 @@ class guesser_test extends \phpbb_test_case
// Check if any guesser except the extension_guesser is available
$this->fileinfo_supported = $guessers[0]->isSupported() | $guessers[1]->isSupported() | $guessers[3]->is_supported();
+ // Also create a guesser that emulates not having fileinfo available
+ $this->guesser_no_fileinfo = new \phpbb\mimetype\guesser(array($guessers[2]));
+
$this->guesser = new \phpbb\mimetype\guesser($guessers);
$this->path = dirname(__FILE__);
$this->jpg_file = $this->path . '/fixtures/jpg';
@@ -62,13 +65,30 @@ class guesser_test extends \phpbb_test_case
{
// We will always get application/octet-stream as mimetype if only the
// extension guesser is supported
- if ($expected && !$this->fileinfo_supported)
+ if (!$this->fileinfo_supported)
{
- $expected = 'application/octet-stream';
+ $this->markTestSkipped('Unable to run tests depending on fileinfo if it is not available');
}
$this->assertEquals($expected, $this->guesser->guess($this->path . '/../upload/fixture/' . $file));
}
+ public function data_guess_files_no_fileinfo()
+ {
+ return array(
+ array('application/octet-stream', 'gif'),
+ array('application/octet-stream', 'txt'),
+ array(false, 'foobar'),
+ );
+ }
+
+ /**
+ * @dataProvider data_guess_files_no_fileinfo
+ */
+ public function test_guess_files_no_fileinfo($expected, $file)
+ {
+ $this->assertEquals($expected, $this->guesser_no_fileinfo->guess($this->path . '/../upload/fixture/' . $file));
+ }
+
public function test_file_not_readable()
{
@chmod($this->jpg_file, 0000);