X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Flibs%2Fmime%2FMimeAnalyzerTest.php;h=d2188a1f73fb8e41fe238e50e15c85227d93daeb;hb=823a96e2ceab3a552075bde676c03c2cb163ce8f;hp=cf891e288dfc3793adaa0c1fd0e704d9c53c1f7f;hpb=4a36045d47b3834b058c4880c1d6040c97ab5d67;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php b/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php index cf891e288d..d2188a1f73 100644 --- a/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php +++ b/tests/phpunit/includes/libs/mime/MimeAnalyzerTest.php @@ -1,5 +1,9 @@ mimeAnalyzer ) ); + $method = $class->getMethod( 'doGuessMimeType' ); + $method->setAccessible( true ); + return $method->invokeArgs( $this->mimeAnalyzer, $parameters ); + } + /** * @dataProvider providerImproveTypeFromExtension * @param string $ext File extension (no leading dot) @@ -69,4 +80,49 @@ class MimeMagicTest extends PHPUnit_Framework_TestCase { $actualType = $this->mimeAnalyzer->getMediaType( $oggFile, 'application/ogg' ); $this->assertEquals( MEDIATYPE_AUDIO, $actualType ); } + + /** + * Test to make sure that mp3 files are detected as audio type + */ + function testMP3AsAudio() { + $file = __DIR__ . '/../../../data/media/say-test-with-id3.mp3'; + $actualType = $this->mimeAnalyzer->getMediaType( $file ); + $this->assertEquals( MEDIATYPE_AUDIO, $actualType ); + } + + /** + * Test to make sure that MP3 with id3 tag is recognized + */ + function testMP3WithID3Recognize() { + $file = __DIR__ . '/../../../data/media/say-test-with-id3.mp3'; + $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] ); + $this->assertEquals( 'audio/mpeg', $actualType ); + } + + /** + * Test to make sure that MP3 without id3 tag is recognized (MPEG-1 sample rates) + */ + function testMP3NoID3RecognizeMPEG1() { + $file = __DIR__ . '/../../../data/media/say-test-mpeg1.mp3'; + $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] ); + $this->assertEquals( 'audio/mpeg', $actualType ); + } + + /** + * Test to make sure that MP3 without id3 tag is recognized (MPEG-2 sample rates) + */ + function testMP3NoID3RecognizeMPEG2() { + $file = __DIR__ . '/../../../data/media/say-test-mpeg2.mp3'; + $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] ); + $this->assertEquals( 'audio/mpeg', $actualType ); + } + + /** + * Test to make sure that MP3 without id3 tag is recognized (MPEG-2.5 sample rates) + */ + function testMP3NoID3RecognizeMPEG2_5() { + $file = __DIR__ . '/../../../data/media/say-test-mpeg2.5.mp3'; + $actualType = $this->doGuessMimeType( [ $file, 'mp3' ] ); + $this->assertEquals( 'audio/mpeg', $actualType ); + } }