mirror of
https://github.com/Intervention/image.git
synced 2025-08-28 08:09:54 +02:00
Fixed bug in ModifierStack, Added tests for apply method
This commit is contained in:
@@ -17,6 +17,8 @@ class ModifierStack implements ModifierInterface
|
||||
foreach ($this->modifiers as $modifier) {
|
||||
$modifier->apply($image);
|
||||
}
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
public function push(ModifierInterface $modifier): self
|
||||
|
@@ -3,7 +3,9 @@
|
||||
namespace Intervention\Image\Tests;
|
||||
|
||||
use Intervention\Image\Drivers\Gd\Modifiers\GreyscaleModifier;
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
use Intervention\Image\ModifierStack;
|
||||
use Mockery;
|
||||
|
||||
/**
|
||||
* @covers \Intervention\Image\ModifierStack
|
||||
@@ -22,4 +24,19 @@ class ModifierStackTest extends TestCase
|
||||
$result = $stack->push(new GreyscaleModifier());
|
||||
$this->assertInstanceOf(ModifierStack::class, $result);
|
||||
}
|
||||
|
||||
public function testApply(): void
|
||||
{
|
||||
$image = Mockery::mock(ImageInterface::class);
|
||||
|
||||
$modifier1 = Mockery::mock(AbstractColor::class)->makePartial();
|
||||
$modifier1->shouldReceive('apply')->once()->with($image);
|
||||
|
||||
$modifier2 = Mockery::mock(AbstractColor::class)->makePartial();
|
||||
$modifier2->shouldReceive('apply')->once()->with($image);
|
||||
|
||||
$stack = new ModifierStack([$modifier1, $modifier2]);
|
||||
$result = $stack->apply($image);
|
||||
$this->assertInstanceOf(ImageInterface::class, $image);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user