From bd654f9ca22b515d869e0f508a0f130afaa21431 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Tue, 20 Jan 2015 17:43:49 +0100 Subject: [PATCH] added tests --- tests/ImageTest.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/ImageTest.php b/tests/ImageTest.php index ace7546d..184844d7 100644 --- a/tests/ImageTest.php +++ b/tests/ImageTest.php @@ -63,6 +63,40 @@ class ImageTest extends PHPUnit_Framework_TestCase $this->assertEquals('./tmp/foo.png', $image->basePath()); } + /** + * @expectedException \Intervention\Image\Exception\RuntimeException + */ + public function testGetBackupWithoutBackuo() + { + $image = $this->getTestImage(); + $image->getBackup(); + } + + public function testSetGetBackup() + { + $image = $this->getTestImage(); + $image->setBackup('foo'); + $backup = $image->getBackup(); + $this->assertEquals('foo', $backup); + } + + public function testGetAllBackups() + { + $image = $this->getTestImage(); + $image->setBackup('foo'); + $image->setBackup('bar'); + $image->setBackup('baz'); + $backups = $image->getAllBackups(); + $this->assertEquals(array('default' => 'baz'), $backups); + + $image = $this->getTestImage(); + $image->setBackup('foo', 'a'); + $image->setBackup('bar', 'b'); + $image->setBackup('baz', 'c'); + $backups = $image->getAllBackups(); + $this->assertEquals(array('a' => 'foo', 'b' => 'bar', 'c' => 'baz'), $backups); + } + private function getTestImage() { $size = Mockery::mock('\Intervention\Image\Size', array(800, 600));