mirror of
https://github.com/Intervention/image.git
synced 2025-08-28 16:19:50 +02:00
PHPUnit 10 Migration (#1302)
* Bump PHPUnit dependencies * Set return type of base TestCase methods From the [PHPUnit 8 release notes][1], the `TestCase` methods below now declare a `void` return type: - `setUpBeforeClass()` - `setUp()` - `assertPreConditions()` - `assertPostConditions()` - `tearDown()` - `tearDownAfterClass()` - `onNotSuccessfulTest()` [1]: https://phpunit.de/announcements/phpunit-8.html * Ignore PHPUnit cache folder * Adopt PHP attributes in test classes * Declare data providers as `static` * Add return types to test methods * Define test classes as `final` * Migrate phpunit.xml to phpunit 10 * Correct phpunit attribute class name * Rename base test class * Restructure test folders * Fix test image paths * Only set rules for php files in .editorconfig * Remove php unit flag in local test env --------- Co-authored-by: Shift <shift@laravelshift.com>
This commit is contained in:
60
tests/Unit/EncodedImageTest.php
Normal file
60
tests/Unit/EncodedImageTest.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use Intervention\Image\EncodedImage;
|
||||
use Intervention\Image\Tests\BaseTestCase;
|
||||
|
||||
#[CoversClass(\Intervention\Image\EncodedImage::class)]
|
||||
final class EncodedImageTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$image = new EncodedImage('foo', 'bar');
|
||||
$this->assertInstanceOf(EncodedImage::class, $image);
|
||||
}
|
||||
|
||||
public function testSave(): void
|
||||
{
|
||||
$image = new EncodedImage('foo', 'bar');
|
||||
$path = __DIR__ . '/foo.tmp';
|
||||
$this->assertFalse(file_exists($path));
|
||||
$image->save($path);
|
||||
$this->assertTrue(file_exists($path));
|
||||
$this->assertEquals('foo', file_get_contents($path));
|
||||
unlink($path);
|
||||
}
|
||||
|
||||
public function testToDataUri(): void
|
||||
{
|
||||
$image = new EncodedImage('foo', 'bar');
|
||||
$this->assertEquals('data:bar;base64,Zm9v', $image->toDataUri());
|
||||
}
|
||||
|
||||
public function testToString(): void
|
||||
{
|
||||
$image = new EncodedImage('foo', 'bar');
|
||||
$this->assertEquals('foo', (string) $image);
|
||||
}
|
||||
|
||||
public function testMediaType(): void
|
||||
{
|
||||
$image = new EncodedImage('foo');
|
||||
$this->assertEquals('application/octet-stream', $image->mediaType());
|
||||
|
||||
$image = new EncodedImage('foo', 'image/jpeg');
|
||||
$this->assertEquals('image/jpeg', $image->mediaType());
|
||||
}
|
||||
|
||||
public function testMimetype(): void
|
||||
{
|
||||
$image = new EncodedImage('foo');
|
||||
$this->assertEquals('application/octet-stream', $image->mimetype());
|
||||
|
||||
$image = new EncodedImage('foo', 'image/jpeg');
|
||||
$this->assertEquals('image/jpeg', $image->mimetype());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user