1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-24 06:22:57 +02:00
Files
intervention_image/tests/Unit/ModifierStackTest.php
Oliver Vogel b9a16d4df6 Optimize tests
2024-12-07 11:38:33 +01:00

46 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace Intervention\Image\Tests\Unit;
use PHPUnit\Framework\Attributes\CoversClass;
use Intervention\Image\Modifiers\GreyscaleModifier;
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\ModifierInterface;
use Intervention\Image\ModifierStack;
use Intervention\Image\Tests\BaseTestCase;
use Mockery;
#[CoversClass(ModifierStack::class)]
final class ModifierStackTest extends BaseTestCase
{
public function testConstructor(): void
{
$stack = new ModifierStack([]);
$this->assertInstanceOf(ModifierStack::class, $stack);
}
public function testPush(): void
{
$stack = new ModifierStack([]);
$result = $stack->push(new GreyscaleModifier());
$this->assertInstanceOf(ModifierStack::class, $result);
}
public function testApply(): void
{
$image = Mockery::mock(ImageInterface::class);
$modifier1 = Mockery::mock(ModifierInterface::class)->makePartial();
$modifier1->shouldReceive('apply')->once()->with($image);
$modifier2 = Mockery::mock(ModifierInterface::class)->makePartial();
$modifier2->shouldReceive('apply')->once()->with($image);
$stack = new ModifierStack([$modifier1, $modifier2]);
$result = $stack->apply($image);
$this->assertInstanceOf(ImageInterface::class, $result);
}
}