public function delete($user, $imageIdentifier)
{
if (($file = $this->getImageObject($user, $imageIdentifier)) === false) {
throw new StorageException('File not found', 404);
}
$this->getGrid()->delete($file->file['_id']);
return true;
}
/** * @covers Imbo\Storage\GridFS::delete * @covers Imbo\Storage\GridFS::imageExists */ public function testDeleteFile() { $file = $this->getMockBuilder('MongoGridFSFile')->disableOriginalConstructor()->getMock(); $cursor = $this->getMockBuilder('MongoGridFSCursor')->disableOriginalConstructor()->getMock(); $cursor->expects($this->once())->method('count')->will($this->returnValue(1)); $cursor->expects($this->once())->method('getNext')->will($this->returnValue($file)); $this->grid->expects($this->once())->method('find')->will($this->returnValue($cursor)); $this->grid->expects($this->once())->method('delete'); $this->driver->delete($this->publicKey, $this->imageIdentifier); }