1
0
mirror of https://github.com/Intervention/image.git synced 2025-09-09 05:30:40 +02:00

added possibility to reset multiple times to a backup

This commit is contained in:
Oliver Vogel
2014-09-18 17:55:33 +02:00
parent ad72919fbc
commit f65e57914f
5 changed files with 61 additions and 2 deletions

View File

@@ -1106,6 +1106,29 @@ class GdSystemTest extends PHPUnit_Framework_TestCase
$this->assertTransparentPosition($img, 0, 0);
}
public function testResetToNamed()
{
$img = $this->manager()->make('tests/images/tile.png');
$img->backup('original');
$img->resize(30, 20);
$img->backup('30x20');
// reset to original
$img->reset('original');
$this->assertEquals(16, $img->getWidth());
$this->assertEquals(16, $img->getHeight());
// reset to 30x20
// $img->reset('30x20');
// $this->assertEquals(30, $img->getWidth());
// $this->assertEquals(20, $img->getHeight());
// reset to original again
$img->reset('original');
$this->assertEquals(16, $img->getWidth());
$this->assertEquals(16, $img->getHeight());
}
public function testLimitColors()
{
$img = $this->manager()->make('tests/images/trim.png');

View File

@@ -1081,6 +1081,29 @@ class ImagickSystemTest extends PHPUnit_Framework_TestCase
$this->assertTransparentPosition($img, 0, 0);
}
public function testResetToNamed()
{
$img = $this->manager()->make('tests/images/tile.png');
$img->backup('original');
$img->resize(30, 20);
$img->backup('30x20');
// reset to original
$img->reset('original');
$this->assertEquals(16, $img->getWidth());
$this->assertEquals(16, $img->getHeight());
// reset to 30x20
$img->reset('30x20');
$this->assertEquals(30, $img->getWidth());
$this->assertEquals(20, $img->getHeight());
// reset to original again
$img->reset('original');
$this->assertEquals(16, $img->getWidth());
$this->assertEquals(16, $img->getHeight());
}
public function testLimitColors()
{
$img = $this->manager()->make('tests/images/trim.png');

View File

@@ -15,7 +15,10 @@ class ResetCommandTest extends PHPUnit_Framework_TestCase
$size = Mockery::mock('Intervention\Image\Size', array(800, 600));
$resource = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
$image = Mockery::mock('Intervention\Image\Image');
$driver = Mockery::mock('Intervention\Image\Gd\Driver');
$driver->shouldReceive('cloneCore')->with($resource)->once()->andReturn($resource);
$image->shouldReceive('getCore')->once()->andReturn($resource);
$image->shouldReceive('getDriver')->once()->andReturn($driver);
$image->shouldReceive('setCore')->once();
$image->shouldReceive('getBackup')->once()->andReturn($resource);
$command = new ResetGd(array());
@@ -28,6 +31,9 @@ class ResetCommandTest extends PHPUnit_Framework_TestCase
$size = Mockery::mock('Intervention\Image\Size', array(800, 600));
$resource = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
$image = Mockery::mock('Intervention\Image\Image');
$driver = Mockery::mock('Intervention\Image\Gd\Driver');
$driver->shouldReceive('cloneCore')->with($resource)->once()->andReturn($resource);
$image->shouldReceive('getDriver')->once()->andReturn($driver);
$image->shouldReceive('getCore')->once()->andReturn($resource);
$image->shouldReceive('setCore')->once();
$image->shouldReceive('getBackup')->once()->withArgs(array('fooBackup'))->andReturn($resource);