1
0
mirror of https://github.com/Intervention/image.git synced 2025-01-17 20:28:21 +01:00
intervention_image/tests/ModifierStackTest.php
2023-10-21 10:00:13 +02:00

44 lines
1.3 KiB
PHP

<?php
namespace Intervention\Image\Tests;
use Intervention\Image\Drivers\Gd\Modifiers\GreyscaleModifier;
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\ModifierInterface;
use Intervention\Image\ModifierStack;
use Mockery;
/**
* @covers \Intervention\Image\ModifierStack
*/
class ModifierStackTest extends TestCase
{
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);
}
}