From 495e415c25d14935b3ab059eb124ab2ab1072007 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Tue, 18 Mar 2014 18:57:12 +0100 Subject: [PATCH] added ImageBackupNotAvailableException --- .../Image/Exception/ImageBackupNotAvailableException.php | 8 ++++++++ src/Intervention/Image/Image.php | 2 ++ tests/ImageTest.php | 9 +++++++++ 3 files changed, 19 insertions(+) create mode 100644 src/Intervention/Image/Exception/ImageBackupNotAvailableException.php diff --git a/src/Intervention/Image/Exception/ImageBackupNotAvailableException.php b/src/Intervention/Image/Exception/ImageBackupNotAvailableException.php new file mode 100644 index 00000000..1b9c7214 --- /dev/null +++ b/src/Intervention/Image/Exception/ImageBackupNotAvailableException.php @@ -0,0 +1,8 @@ +isImageResource($this->original)) { is_resource($this->resource) ? imagedestroy($this->resource) : null; $this->initFromResource($this->original); + } else { + throw new Exception\ImageBackupNotAvailableException('backup() must be called first to use reset().'); } return $this; diff --git a/tests/ImageTest.php b/tests/ImageTest.php index 61330ef5..eb4c602c 100644 --- a/tests/ImageTest.php +++ b/tests/ImageTest.php @@ -1419,6 +1419,15 @@ class ImageTest extends PHPUnit_Framework_Testcase $this->assertEquals('#0000ff', $img->pickColor(0, 0, 'hex')); } + /** + * @expectedException Intervention\Image\Exception\ImageBackupNotAvailableException + */ + public function testResetImageWithoutBackup() + { + $img = $this->getTestImage(); + $img->reset(); + } + public function testBackup() { $img = new Image(null, 800, 600, '#0000ff');