public function getImage($user, $imageIdentifier) { if (($file = $this->getImageObject($user, $imageIdentifier)) === false) { throw new StorageException('File not found', 404); } return $file->getBytes(); }
/** * @covers Imbo\Storage\GridFS::getImage * @covers Imbo\Storage\GridFS::imageExists */ public function testGetImage() { $data = 'file contents'; $file = $this->getMockBuilder('MongoGridFSFile')->disableOriginalConstructor()->getMock(); $file->expects($this->once())->method('getBytes')->will($this->returnValue($data)); $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->assertSame($data, $this->driver->getImage($this->publicKey, $this->imageIdentifier)); }