1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
<?php
namespace Illuminate\Tests\Http;
use Illuminate\Http\Testing\FileFactory;
use PHPUnit\Framework\TestCase;
class HttpTestingFileFactoryTest extends TestCase
{
public function testImagePng()
{
if (! function_exists('imagepng')) {
$this->markTestSkipped('The extension gd is missing from your system or was compiled without PNG support.');
}
$image = (new FileFactory)->image('test.png', 15, 20);
$info = getimagesize($image->getRealPath());
$this->assertSame('image/png', $info['mime']);
$this->assertSame(15, $info[0]);
$this->assertSame(20, $info[1]);
}
public function testImageJpeg()
{
if (! function_exists('imagejpeg')) {
$this->markTestSkipped('The extension gd is missing from your system or was compiled without JPEG support.');
}
$image = (new FileFactory)->image('test.jpeg', 15, 20);
$info = getimagesize($image->getRealPath());
$this->assertSame('image/jpeg', $info['mime']);
$this->assertSame(15, $info[0]);
$this->assertSame(20, $info[1]);
}
public function testCreateWithMimeType()
{
$this->assertSame(
'audio/webm',
(new FileFactory)->create('someaudio.webm', 0, 'audio/webm')->getMimeType()
);
}
public function testCreateWithoutMimeType()
{
$this->assertSame(
'video/webm',
(new FileFactory)->create('someaudio.webm')->getMimeType()
);
}
}
|