diff --git a/Binary/Loader/GridFSLoader.php b/Binary/Loader/GridFSLoader.php index b6bb67e02..6b020260c 100644 --- a/Binary/Loader/GridFSLoader.php +++ b/Binary/Loader/GridFSLoader.php @@ -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(); } } diff --git a/Tests/Binary/Loader/GridFSLoaderTest.php b/Tests/Binary/Loader/GridFSLoaderTest.php index 627afb4be..8644ca70b 100644 --- a/Tests/Binary/Loader/GridFSLoaderTest.php +++ b/Tests/Binary/Loader/GridFSLoaderTest.php @@ -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')); } @@ -52,4 +60,3 @@ public function testFindWithInValidDocument() $this->loader->find('0123456789abcdef01234567'); } } - \ No newline at end of file