mirror of
https://github.com/Intervention/image.git
synced 2025-08-01 11:30:16 +02:00
Add geometry factory tests
This commit is contained in:
30
tests/Geometry/Factories/CircleFactoryTest.php
Normal file
30
tests/Geometry/Factories/CircleFactoryTest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Tests\Geometry\Factories;
|
||||
|
||||
use Intervention\Image\Geometry\Ellipse;
|
||||
use Intervention\Image\Geometry\Factories\CircleFactory;
|
||||
use Intervention\Image\Geometry\Point;
|
||||
use Intervention\Image\Tests\TestCase;
|
||||
|
||||
class CircleFactoryTest extends TestCase
|
||||
{
|
||||
public function testFactoryCallback(): void
|
||||
{
|
||||
$factory = new CircleFactory(new Point(1, 2), function ($circle) {
|
||||
$circle->background('fff');
|
||||
$circle->border('ccc', 10);
|
||||
$circle->radius(100);
|
||||
$circle->diameter(1000);
|
||||
});
|
||||
|
||||
$circle = $factory();
|
||||
$this->assertInstanceOf(Ellipse::class, $circle);
|
||||
$this->assertTrue($circle->hasBackgroundColor());
|
||||
$this->assertEquals('fff', $circle->backgroundColor());
|
||||
$this->assertEquals('ccc', $circle->borderColor());
|
||||
$this->assertEquals(10, $circle->borderSize());
|
||||
$this->assertEquals(1000, $circle->width());
|
||||
$this->assertEquals(1000, $circle->height());
|
||||
}
|
||||
}
|
31
tests/Geometry/Factories/EllipseFactoryTest.php
Normal file
31
tests/Geometry/Factories/EllipseFactoryTest.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Tests\Geometry\Factories;
|
||||
|
||||
use Intervention\Image\Geometry\Ellipse;
|
||||
use Intervention\Image\Geometry\Factories\EllipseFactory;
|
||||
use Intervention\Image\Geometry\Point;
|
||||
use Intervention\Image\Tests\TestCase;
|
||||
|
||||
class EllipseFactoryTest extends TestCase
|
||||
{
|
||||
public function testFactoryCallback(): void
|
||||
{
|
||||
$factory = new EllipseFactory(new Point(1, 2), function ($ellipse) {
|
||||
$ellipse->background('fff');
|
||||
$ellipse->border('ccc', 10);
|
||||
$ellipse->width(100);
|
||||
$ellipse->height(200);
|
||||
$ellipse->size(1000, 2000);
|
||||
});
|
||||
|
||||
$ellipse = $factory();
|
||||
$this->assertInstanceOf(Ellipse::class, $ellipse);
|
||||
$this->assertTrue($ellipse->hasBackgroundColor());
|
||||
$this->assertEquals('fff', $ellipse->backgroundColor());
|
||||
$this->assertEquals('ccc', $ellipse->borderColor());
|
||||
$this->assertEquals(10, $ellipse->borderSize());
|
||||
$this->assertEquals(1000, $ellipse->width());
|
||||
$this->assertEquals(2000, $ellipse->height());
|
||||
}
|
||||
}
|
32
tests/Geometry/Factories/LineFactoryTest.php
Normal file
32
tests/Geometry/Factories/LineFactoryTest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Tests\Geometry\Factories;
|
||||
|
||||
use Intervention\Image\Geometry\Factories\LineFactory;
|
||||
use Intervention\Image\Geometry\Line;
|
||||
use Intervention\Image\Tests\TestCase;
|
||||
|
||||
class LineFactoryTest extends TestCase
|
||||
{
|
||||
public function testFactoryCallback(): void
|
||||
{
|
||||
$factory = new LineFactory(function ($line) {
|
||||
$line->color('fff');
|
||||
$line->background('fff');
|
||||
$line->border('fff', 10);
|
||||
$line->width(10);
|
||||
$line->from(100, 200);
|
||||
$line->to(300, 400);
|
||||
});
|
||||
|
||||
$line = $factory();
|
||||
$this->assertInstanceOf(Line::class, $line);
|
||||
$this->assertTrue($line->hasBackgroundColor());
|
||||
$this->assertEquals('fff', $line->backgroundColor());
|
||||
$this->assertEquals(100, $line->start()->x());
|
||||
$this->assertEquals(200, $line->start()->y());
|
||||
$this->assertEquals(300, $line->end()->x());
|
||||
$this->assertEquals(400, $line->end()->y());
|
||||
$this->assertEquals(10, $line->width());
|
||||
}
|
||||
}
|
29
tests/Geometry/Factories/PolygonFactoryTest.php
Normal file
29
tests/Geometry/Factories/PolygonFactoryTest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Tests\Geometry\Factories;
|
||||
|
||||
use Intervention\Image\Geometry\Factories\PolygonFactory;
|
||||
use Intervention\Image\Geometry\Polygon;
|
||||
use Intervention\Image\Tests\TestCase;
|
||||
|
||||
class PolygonFactoryTest extends TestCase
|
||||
{
|
||||
public function testFactoryCallback(): void
|
||||
{
|
||||
$factory = new PolygonFactory(function ($polygon) {
|
||||
$polygon->background('fff');
|
||||
$polygon->border('ccc', 10);
|
||||
$polygon->point(1, 2);
|
||||
$polygon->point(3, 4);
|
||||
$polygon->point(5, 6);
|
||||
});
|
||||
|
||||
$polygon = $factory();
|
||||
$this->assertInstanceOf(Polygon::class, $polygon);
|
||||
$this->assertTrue($polygon->hasBackgroundColor());
|
||||
$this->assertEquals('fff', $polygon->backgroundColor());
|
||||
$this->assertEquals('ccc', $polygon->borderColor());
|
||||
$this->assertEquals(10, $polygon->borderSize());
|
||||
$this->assertEquals(3, $polygon->count());
|
||||
}
|
||||
}
|
31
tests/Geometry/Factories/RectangleFactoryTest.php
Normal file
31
tests/Geometry/Factories/RectangleFactoryTest.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Tests\Geometry\Factories;
|
||||
|
||||
use Intervention\Image\Geometry\Factories\RectangleFactory;
|
||||
use Intervention\Image\Geometry\Point;
|
||||
use Intervention\Image\Geometry\Rectangle;
|
||||
use Intervention\Image\Tests\TestCase;
|
||||
|
||||
class RectangleFactoryTest extends TestCase
|
||||
{
|
||||
public function testFactoryCallback(): void
|
||||
{
|
||||
$factory = new RectangleFactory(new Point(1, 2), function ($rectangle) {
|
||||
$rectangle->background('fff');
|
||||
$rectangle->border('ccc', 10);
|
||||
$rectangle->width(100);
|
||||
$rectangle->height(200);
|
||||
$rectangle->size(1000, 2000);
|
||||
});
|
||||
|
||||
$rectangle = $factory();
|
||||
$this->assertInstanceOf(Rectangle::class, $rectangle);
|
||||
$this->assertTrue($rectangle->hasBackgroundColor());
|
||||
$this->assertEquals('fff', $rectangle->backgroundColor());
|
||||
$this->assertEquals('ccc', $rectangle->borderColor());
|
||||
$this->assertEquals(10, $rectangle->borderSize());
|
||||
$this->assertEquals(1000, $rectangle->width());
|
||||
$this->assertEquals(2000, $rectangle->height());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user