mirror of
https://github.com/Intervention/image.git
synced 2025-08-30 09:10:21 +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:
78
tests/Unit/Geometry/LineTest.php
Normal file
78
tests/Unit/Geometry/LineTest.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Intervention\Image\Tests\Unit\Geometry;
|
||||
|
||||
use Intervention\Image\Geometry\Line;
|
||||
use Intervention\Image\Geometry\Point;
|
||||
use Intervention\Image\Tests\BaseTestCase;
|
||||
|
||||
final class LineTest extends BaseTestCase
|
||||
{
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$line = new Line(new Point(1, 2), new Point(3, 4), 10);
|
||||
$this->assertInstanceOf(Line::class, $line);
|
||||
}
|
||||
|
||||
public function testPosition(): void
|
||||
{
|
||||
$line = new Line(new Point(1, 2), new Point(3, 4), 10);
|
||||
$this->assertEquals(1, $line->position()->x());
|
||||
$this->assertEquals(2, $line->position()->y());
|
||||
}
|
||||
|
||||
public function testSetGetStart(): void
|
||||
{
|
||||
$line = new Line(new Point(1, 2), new Point(3, 4), 10);
|
||||
$this->assertEquals(1, $line->start()->x());
|
||||
$this->assertEquals(2, $line->start()->y());
|
||||
$result = $line->setStart(new Point(10, 20));
|
||||
$this->assertInstanceOf(Line::class, $result);
|
||||
$this->assertEquals(10, $line->start()->x());
|
||||
$this->assertEquals(20, $line->start()->y());
|
||||
}
|
||||
|
||||
public function testSetGetEnd(): void
|
||||
{
|
||||
$line = new Line(new Point(1, 2), new Point(3, 4), 10);
|
||||
$this->assertEquals(3, $line->end()->x());
|
||||
$this->assertEquals(4, $line->end()->y());
|
||||
$result = $line->setEnd(new Point(30, 40));
|
||||
$this->assertInstanceOf(Line::class, $result);
|
||||
$this->assertEquals(30, $line->end()->x());
|
||||
$this->assertEquals(40, $line->end()->y());
|
||||
}
|
||||
|
||||
public function setFrom(): void
|
||||
{
|
||||
$line = new Line(new Point(1, 2), new Point(3, 4), 10);
|
||||
$this->assertEquals(1, $line->start()->x());
|
||||
$this->assertEquals(2, $line->start()->y());
|
||||
$result = $line->from(10, 20);
|
||||
$this->assertInstanceOf(Line::class, $result);
|
||||
$this->assertEquals(10, $line->start()->x());
|
||||
$this->assertEquals(20, $line->start()->y());
|
||||
}
|
||||
|
||||
public function setTo(): void
|
||||
{
|
||||
$line = new Line(new Point(1, 2), new Point(3, 4), 10);
|
||||
$this->assertEquals(3, $line->end()->x());
|
||||
$this->assertEquals(4, $line->end()->y());
|
||||
$result = $line->to(30, 40);
|
||||
$this->assertInstanceOf(Line::class, $result);
|
||||
$this->assertEquals(30, $line->end()->x());
|
||||
$this->assertEquals(40, $line->end()->y());
|
||||
}
|
||||
|
||||
public function testSetGetWidth(): void
|
||||
{
|
||||
$line = new Line(new Point(1, 2), new Point(3, 4), 10);
|
||||
$this->assertEquals(10, $line->width());
|
||||
$result = $line->setWidth(20);
|
||||
$this->assertInstanceOf(Line::class, $result);
|
||||
$this->assertEquals(20, $line->width());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user