mirror of
https://github.com/Intervention/image.git
synced 2025-08-30 01:00:06 +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:
45
tests/Unit/Typography/FontFactoryTest.php
Normal file
45
tests/Unit/Typography/FontFactoryTest.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Tests\Unit\Typography;
|
||||
|
||||
use Intervention\Image\Interfaces\FontInterface;
|
||||
use Intervention\Image\Tests\BaseTestCase;
|
||||
use Intervention\Image\Typography\Font;
|
||||
use Intervention\Image\Typography\FontFactory;
|
||||
|
||||
final class FontFactoryTest extends BaseTestCase
|
||||
{
|
||||
public function testBuildWithFont(): void
|
||||
{
|
||||
$factory = new FontFactory(new Font('foo.ttf'));
|
||||
$result = $factory();
|
||||
$this->assertInstanceOf(FontInterface::class, $result);
|
||||
$this->assertEquals('foo.ttf', $result->filename());
|
||||
}
|
||||
|
||||
public function testBuildWithCallback(): void
|
||||
{
|
||||
$factory = new FontFactory(function ($font) {
|
||||
$font->filename('foo.ttf');
|
||||
$font->file('bar.ttf');
|
||||
$font->color('#b01735');
|
||||
$font->size(70);
|
||||
$font->align('center');
|
||||
$font->valign('middle');
|
||||
$font->lineHeight(1.6);
|
||||
$font->angle(10);
|
||||
});
|
||||
|
||||
$result = $factory();
|
||||
$this->assertInstanceOf(FontInterface::class, $result);
|
||||
$this->assertEquals('bar.ttf', $result->filename());
|
||||
$this->assertEquals('#b01735', $result->color());
|
||||
$this->assertEquals(70, $result->size());
|
||||
$this->assertEquals('center', $result->alignment());
|
||||
$this->assertEquals('middle', $result->valignment());
|
||||
$this->assertEquals(1.6, $result->lineHeight());
|
||||
$this->assertEquals(10, $result->angle());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user