mirror of
https://github.com/Intervention/image.git
synced 2025-02-23 13:52:20 +01:00
64 lines
2.4 KiB
PHP
64 lines
2.4 KiB
PHP
<?php
|
|
|
|
use Intervention\Image\Gd\Commands\BackupCommand as BackupGd;
|
|
use Intervention\Image\Imagick\Commands\BackupCommand as BackupImagick;
|
|
|
|
class BackupCommandTest extends PHPUnit_Framework_TestCase
|
|
{
|
|
public function tearDown()
|
|
{
|
|
Mockery::close();
|
|
}
|
|
|
|
public function testGdWithoutName()
|
|
{
|
|
$driver = Mockery::mock('Intervention\Image\Gd\Driver');
|
|
$driver->shouldReceive('cloneCore')->once();
|
|
$resource = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
|
|
$image = Mockery::mock('Intervention\Image\Image', [$driver]);
|
|
$image->shouldReceive('getCore')->once()->andReturn($resource);
|
|
$image->shouldReceive('setBackup')->once();
|
|
$command = new BackupGd([]);
|
|
$result = $command->execute($image);
|
|
$this->assertTrue($result);
|
|
}
|
|
|
|
public function testGdWithName()
|
|
{
|
|
$driver = Mockery::mock('Intervention\Image\Gd\Driver');
|
|
$driver->shouldReceive('cloneCore')->once();
|
|
$resource = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
|
|
$image = Mockery::mock('Intervention\Image\Image', [$driver]);
|
|
$image->shouldReceive('getCore')->once()->andReturn($resource);
|
|
$image->shouldReceive('setBackup')->once();
|
|
$command = new BackupGd(['name' => 'fooBackup']);
|
|
$result = $command->execute($image);
|
|
$this->assertTrue($result);
|
|
}
|
|
|
|
public function testImagickWithoutName()
|
|
{
|
|
$driver = Mockery::mock('Intervention\Image\Imagick\Driver');
|
|
$driver->shouldReceive('cloneCore')->once();
|
|
$imagick = Mockery::mock('Imagick');
|
|
$image = Mockery::mock('Intervention\Image\Image', [$driver]);
|
|
$image->shouldReceive('getCore')->once()->andReturn($imagick);
|
|
$image->shouldReceive('setBackup')->once();
|
|
$command = new BackupImagick([]);
|
|
$result = $command->execute($image);
|
|
$this->assertTrue($result);
|
|
}
|
|
|
|
public function testImagickWithName()
|
|
{
|
|
$driver = Mockery::mock('Intervention\Image\Imagick\Driver');
|
|
$driver->shouldReceive('cloneCore')->once();
|
|
$imagick = Mockery::mock('Imagick');
|
|
$image = Mockery::mock('Intervention\Image\Image', [$driver]);
|
|
$image->shouldReceive('getCore')->once()->andReturn($imagick);
|
|
$image->shouldReceive('setBackup')->once();
|
|
$command = new BackupImagick(['name' => 'fooBackup']);
|
|
$result = $command->execute($image);
|
|
$this->assertTrue($result);
|
|
}
|
|
} |