1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-17 11:20:44 +02:00

Add Geometry traits tests

This commit is contained in:
Oliver Vogel
2024-01-15 11:23:03 +01:00
parent 4971984623
commit a5243592ac
2 changed files with 81 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
<?php
namespace Intervention\Image\Tests\Geometry\Traits;
use Intervention\Image\Geometry\Traits\HasBackgroundColor;
use Intervention\Image\Tests\TestCase;
class HasBackgroundColorTest extends TestCase
{
public function getTestObject(): object
{
return new class () {
use HasBackgroundColor;
};
}
public function testSetGetBackgroundColor(): void
{
$object = $this->getTestObject();
$this->assertNull($object->backgroundColor());
$this->assertFalse($object->hasBackgroundColor());
$object->setBackgroundColor('fff');
$this->assertEquals('fff', $object->backgroundColor());
$this->assertTrue($object->hasBackgroundColor());
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace Intervention\Image\Tests\Geometry\Traits;
use Intervention\Image\Geometry\Traits\HasBorder;
use Intervention\Image\Tests\TestCase;
class HasBorderTest extends TestCase
{
public function getTestObject(): object
{
return new class () {
use HasBorder;
};
}
public function testSetBorder(): void
{
$object = $this->getTestObject();
$this->assertNull($object->borderColor());
$this->assertEquals(0, $object->borderSize());
$this->assertFalse($object->hasBorder());
$object->setBorder('fff', 10);
$this->assertEquals('fff', $object->borderColor());
$this->assertEquals(10, $object->borderSize());
$this->assertTrue($object->hasBorder());
}
public function testSetBorderSize(): void
{
$object = $this->getTestObject();
$this->assertEquals(0, $object->borderSize());
$object->setBorderSize(10);
$this->assertEquals(10, $object->borderSize());
}
public function testSetBorderColor(): void
{
$object = $this->getTestObject();
$this->assertNull($object->borderColor());
$object->setBorderColor('fff');
$this->assertEquals('fff', $object->borderColor());
$this->assertFalse($object->hasBorder());
}
public function testHasBorder(): void
{
$object = $this->getTestObject();
$this->assertFalse($object->hasBorder());
$object->setBorderColor('fff');
$this->assertFalse($object->hasBorder());
$object->setBorderSize(1);
$this->assertTrue($object->hasBorder());
}
}