mirror of
https://github.com/Intervention/image.git
synced 2025-09-08 21:20:46 +02:00
Implement Image::encodeByExtension()
This commit is contained in:
@@ -133,6 +133,17 @@ class ImageTest extends TestCase
|
||||
$this->assertMediaType('image/png', (string) $result);
|
||||
}
|
||||
|
||||
public function testEncodeByExtension(): void
|
||||
{
|
||||
$result = $this->readTestImage('blue.gif')->encodeByExtension();
|
||||
$this->assertInstanceOf(EncodedImage::class, $result);
|
||||
$this->assertMediaType('image/gif', (string) $result);
|
||||
|
||||
$result = $this->readTestImage('blue.gif')->encodeByExtension('png');
|
||||
$this->assertInstanceOf(EncodedImage::class, $result);
|
||||
$this->assertMediaType('image/png', (string) $result);
|
||||
}
|
||||
|
||||
public function testWidthHeightSize(): void
|
||||
{
|
||||
$this->assertEquals(3, $this->image->width());
|
||||
|
@@ -132,6 +132,17 @@ class ImageTest extends TestCase
|
||||
$this->assertMediaType('image/png', (string) $result);
|
||||
}
|
||||
|
||||
public function testEncodeByExtension(): void
|
||||
{
|
||||
$result = $this->readTestImage('blue.gif')->encodeByExtension();
|
||||
$this->assertInstanceOf(EncodedImage::class, $result);
|
||||
$this->assertMediaType('image/gif', (string) $result);
|
||||
|
||||
$result = $this->readTestImage('blue.gif')->encodeByExtension('png');
|
||||
$this->assertInstanceOf(EncodedImage::class, $result);
|
||||
$this->assertMediaType('image/png', (string) $result);
|
||||
}
|
||||
|
||||
public function testWidthHeightSize(): void
|
||||
{
|
||||
$this->assertEquals(20, $this->image->width());
|
||||
|
@@ -14,4 +14,13 @@ class OriginTest extends TestCase
|
||||
$origin = new Origin('image/gif');
|
||||
$this->assertEquals('image/gif', $origin->mediaType());
|
||||
}
|
||||
|
||||
public function testFileExtension(): void
|
||||
{
|
||||
$origin = new Origin('image/jpeg', __DIR__ . '/tests/images/example.jpg');
|
||||
$this->assertEquals('jpg', $origin->fileExtension());
|
||||
|
||||
$origin = new Origin('image/jpeg');
|
||||
$this->assertEquals('', $origin->fileExtension());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user