1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-06 13:56:30 +02:00

added getBackups method

This commit is contained in:
Oliver Vogel
2015-01-20 17:44:25 +01:00
parent bd654f9ca2
commit b3ccde879d
2 changed files with 17 additions and 3 deletions

View File

@@ -219,6 +219,16 @@ class Image extends File
return $this->backups[$name]; return $this->backups[$name];
} }
/**
* Returns all backups attached to image
*
* @return array
*/
public function getBackups()
{
return $this->backups;
}
/** /**
* Sets current image backup * Sets current image backup
* *

View File

@@ -80,20 +80,24 @@ class ImageTest extends PHPUnit_Framework_TestCase
$this->assertEquals('foo', $backup); $this->assertEquals('foo', $backup);
} }
public function testGetAllBackups() public function testGetBackups()
{ {
$image = $this->getTestImage();
$backups = $image->getBackups();
$this->assertEquals(array(), $backups);
$image = $this->getTestImage(); $image = $this->getTestImage();
$image->setBackup('foo'); $image->setBackup('foo');
$image->setBackup('bar'); $image->setBackup('bar');
$image->setBackup('baz'); $image->setBackup('baz');
$backups = $image->getAllBackups(); $backups = $image->getBackups();
$this->assertEquals(array('default' => 'baz'), $backups); $this->assertEquals(array('default' => 'baz'), $backups);
$image = $this->getTestImage(); $image = $this->getTestImage();
$image->setBackup('foo', 'a'); $image->setBackup('foo', 'a');
$image->setBackup('bar', 'b'); $image->setBackup('bar', 'b');
$image->setBackup('baz', 'c'); $image->setBackup('baz', 'c');
$backups = $image->getAllBackups(); $backups = $image->getBackups();
$this->assertEquals(array('a' => 'foo', 'b' => 'bar', 'c' => 'baz'), $backups); $this->assertEquals(array('a' => 'foo', 'b' => 'bar', 'c' => 'baz'), $backups);
} }