Skip to content

Commit

Permalink
Merge pull request #461 from upro/gridfs-fix
Browse files Browse the repository at this point in the history
Fix GridFSLoader
  • Loading branch information
makasim committed Sep 17, 2014
2 parents 334653c + aeb8d48 commit 017bd45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Binary/Loader/GridFSLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public function find($id)
throw new NotLoadableException(sprintf('Source image was not found with id "%s"', $id));
}

return $image['file']->getBytes();
return $image->getFile()->getBytes();
}
}
10 changes: 9 additions & 1 deletion Tests/Binary/Loader/GridFSLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,15 @@ public function testFindWithValidDocument()
$image = new GridFSFile();
$image->setBytes('01010101');

$this->repo->expects($this->atLeastOnce())->method('find')->with($this->isInstanceOf('\MongoId'))->will($this->returnValue(array('file'=>$image)));
$imageDocument = $this->getMock('ImageDocument', array('getFile'));
$imageDocument
->expects($this->any())
->method('getFile')
->with()
->will($this->returnValue($image))
;

$this->repo->expects($this->atLeastOnce())->method('find')->with($this->isInstanceOf('\MongoId'))->will($this->returnValue($imageDocument));

$this->assertEquals('01010101', $this->loader->find('0123456789abcdef01234567'));
}
Expand Down

0 comments on commit 017bd45

Please sign in to comment.