insertImage() public method

Insert an image
public insertImage ( Imbo\EventManager\EventInterface $event )
$event Imbo\EventManager\EventInterface An event instance
Example #1
0
 /**
  * @expectedException Imbo\Exception\StorageException
  * @expectedExceptionMessage Could not store image
  * @expectedExceptionCode 500
  * @covers Imbo\EventListener\StorageOperations::insertImage
  */
 public function testWillDeleteImageFromDatabaseAndThrowExceptionWhenStoringFails()
 {
     $image = $this->getMock('Imbo\\Model\\Image');
     $image->expects($this->once())->method('getBlob')->will($this->returnValue('image data'));
     $image->expects($this->once())->method('getChecksum')->will($this->returnValue('checksum'));
     $this->request->expects($this->once())->method('getImage')->will($this->returnValue($image));
     $this->storage->expects($this->once())->method('store')->with($this->publicKey, 'checksum', 'image data')->will($this->throwException(new StorageException('Could not store image', 500)));
     $database = $this->getMock('Imbo\\Database\\DatabaseInterface');
     $database->expects($this->once())->method('deleteImage')->with($this->publicKey, 'checksum');
     $this->event->expects($this->once())->method('getDatabase')->will($this->returnValue($database));
     $this->listener->insertImage($this->event);
 }