mirror of
https://github.com/Intervention/image.git
synced 2025-08-10 07:53:58 +02:00
Add LineTest
This commit is contained in:
76
tests/Geometry/LineTest.php
Normal file
76
tests/Geometry/LineTest.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Tests\Geometry;
|
||||
|
||||
use Intervention\Image\Geometry\Line;
|
||||
use Intervention\Image\Geometry\Point;
|
||||
use Intervention\Image\Tests\TestCase;
|
||||
|
||||
class LineTest extends TestCase
|
||||
{
|
||||
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