2014-09-20 15:10:16 +02:00
|
|
|
<?php
|
|
|
|
namespace Szurubooru\Tests\Helpers;
|
2014-10-08 14:47:47 +02:00
|
|
|
use Szurubooru\Helpers\MimeHelper;
|
|
|
|
use Szurubooru\Tests\AbstractTestCase;
|
2014-09-20 15:10:16 +02:00
|
|
|
|
2014-10-08 14:47:47 +02:00
|
|
|
final class MimeHelperTest extends AbstractTestCase
|
2014-09-20 15:10:16 +02:00
|
|
|
{
|
|
|
|
public function testGettingMime()
|
|
|
|
{
|
|
|
|
$expected = 'image/jpeg';
|
2014-10-08 14:47:47 +02:00
|
|
|
$actual = MimeHelper::getMimeTypeFromBuffer($this->getTestFile('image.jpg'));
|
2014-09-20 15:10:16 +02:00
|
|
|
$this->assertEquals($expected, $actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testIsFlash()
|
|
|
|
{
|
2014-10-08 14:47:47 +02:00
|
|
|
$this->assertTrue(MimeHelper::isFlash('application/x-shockwave-flash'));
|
|
|
|
$this->assertTrue(MimeHelper::isFlash('APPLICATION/X-SHOCKWAVE-FLASH'));
|
|
|
|
$this->assertFalse(MimeHelper::isFlash('something else'));
|
2014-09-20 15:10:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testIsImage()
|
|
|
|
{
|
2014-10-08 14:47:47 +02:00
|
|
|
$this->assertTrue(MimeHelper::isImage('IMAGE/JPEG'));
|
|
|
|
$this->assertTrue(MimeHelper::isImage('IMAGE/PNG'));
|
|
|
|
$this->assertTrue(MimeHelper::isImage('IMAGE/GIF'));
|
|
|
|
$this->assertTrue(MimeHelper::isImage('image/jpeg'));
|
|
|
|
$this->assertTrue(MimeHelper::isImage('image/png'));
|
|
|
|
$this->assertTrue(MimeHelper::isImage('image/gif'));
|
|
|
|
$this->assertFalse(MimeHelper::isImage('something else'));
|
2014-09-20 15:10:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testIsVideo()
|
|
|
|
{
|
2014-10-08 14:47:47 +02:00
|
|
|
$this->assertTrue(MimeHelper::isVideo('VIDEO/MP4'));
|
|
|
|
$this->assertTrue(MimeHelper::isVideo('video/mp4'));
|
|
|
|
$this->assertTrue(MimeHelper::isVideo('APPLICATION/OGG'));
|
|
|
|
$this->assertTrue(MimeHelper::isVideo('application/ogg'));
|
|
|
|
$this->assertFalse(MimeHelper::isVideo('something else'));
|
2014-09-20 15:10:16 +02:00
|
|
|
}
|
|
|
|
}
|