1
0
mirror of https://github.com/Intervention/image.git synced 2025-01-17 20:28:21 +01:00
intervention_image/tests/DestroyCommandTest.php
2015-01-20 18:10:23 +01:00

46 lines
1.5 KiB
PHP

<?php
use Intervention\Image\Gd\Commands\DestroyCommand as DestroyGd;
use Intervention\Image\Imagick\Commands\DestroyCommand as DestroyImagick;
class DestroyCommandTest extends PHPUnit_Framework_TestCase
{
public function tearDown()
{
Mockery::close();
}
public function testGd()
{
$resource = imagecreatefrompng(__DIR__.'/images/tile.png');
$backups = array(
imagecreatefrompng(__DIR__.'/images/tile.png'),
imagecreatefrompng(__DIR__.'/images/tile.png')
);
$image = Mockery::mock('Intervention\Image\Image');
$image->shouldReceive('getCore')->once()->andReturn($resource);
$image->shouldReceive('getBackups')->once()->andReturn($backups);
$command = new DestroyGd(array());
$result = $command->execute($image);
$this->assertTrue($result);
}
public function testImagick()
{
$imagick = Mockery::mock('Imagick');
$imagick->shouldReceive('clear')->with()->andReturn(true);
$backup = Mockery::mock('Imagick');
$backup->shouldReceive('clear')->with()->andReturn(true);
$backups = array($backup);
$image = Mockery::mock('Intervention\Image\Image');
$image->shouldReceive('getCore')->once()->andReturn($imagick);
$image->shouldReceive('getBackups')->once()->andReturn($backups);
$command = new DestroyImagick(array());
$result = $command->execute($image);
$this->assertTrue($result);
}
}