Commit 4cd5342e authored by Jeremy Mikola's avatar Jeremy Mikola

GridFSDownload expects file document to be stdClass

parent c674aac2
...@@ -20,7 +20,7 @@ class GridFSStreamTest extends FunctionalTestCase ...@@ -20,7 +20,7 @@ class GridFSStreamTest extends FunctionalTestCase
$this->assertEquals(1, $this->collectionsWrapper->getFilesCollection()->count()); $this->assertEquals(1, $this->collectionsWrapper->getFilesCollection()->count());
$this->assertEquals(1, $this->collectionsWrapper->getChunksCollection()->count()); $this->assertEquals(1, $this->collectionsWrapper->getChunksCollection()->count());
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$id]); $file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$id], ['typeMap' => ['root' => 'stdClass']]);
$download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file); $download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file);
$stream = fopen('php://temp', 'w+'); $stream = fopen('php://temp', 'w+');
...@@ -46,7 +46,7 @@ class GridFSStreamTest extends FunctionalTestCase ...@@ -46,7 +46,7 @@ class GridFSStreamTest extends FunctionalTestCase
$this->assertEquals(2, $this->collectionsWrapper->getFilesCollection()->count()); $this->assertEquals(2, $this->collectionsWrapper->getFilesCollection()->count());
$this->assertEquals(1, $this->collectionsWrapper->getChunksCollection()->count()); $this->assertEquals(1, $this->collectionsWrapper->getChunksCollection()->count());
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$id]); $file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$id], ['typeMap' => ['root' => 'stdClass']]);
$download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file); $download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file);
$stream = fopen('php://temp', 'w+'); $stream = fopen('php://temp', 'w+');
$download->downloadToStream($stream); $download->downloadToStream($stream);
...@@ -100,7 +100,7 @@ class GridFSStreamTest extends FunctionalTestCase ...@@ -100,7 +100,7 @@ class GridFSStreamTest extends FunctionalTestCase
$upload = new \MongoDB\GridFS\GridFSUpload($this->collectionsWrapper, "test"); $upload = new \MongoDB\GridFS\GridFSUpload($this->collectionsWrapper, "test");
$upload->close(); $upload->close();
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id" => $upload->getId()]); $file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id" => $upload->getId()], ['typeMap' => ['root' => 'stdClass']]);
$download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file); $download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file);
$download->close(); $download->close();
...@@ -124,7 +124,7 @@ class GridFSStreamTest extends FunctionalTestCase ...@@ -124,7 +124,7 @@ class GridFSStreamTest extends FunctionalTestCase
$upload->insertChunks("hello world"); $upload->insertChunks("hello world");
$upload->close(); $upload->close();
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id" => $upload->getId()]); $file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id" => $upload->getId()], ['typeMap' => ['root' => 'stdClass']]);
$download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file); $download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file);
$this->assertEquals("test", $download->getFile()->filename); $this->assertEquals("test", $download->getFile()->filename);
...@@ -185,7 +185,7 @@ class GridFSStreamTest extends FunctionalTestCase ...@@ -185,7 +185,7 @@ class GridFSStreamTest extends FunctionalTestCase
$upload = new \MongoDB\GridFS\GridFSUpload($this->collectionsWrapper, "test", ["chunkSizeBytes"=>3]); $upload = new \MongoDB\GridFS\GridFSUpload($this->collectionsWrapper, "test", ["chunkSizeBytes"=>3]);
$upload->insertChunks("hello world"); $upload->insertChunks("hello world");
$upload->close(); $upload->close();
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$upload->getId()]); $file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$upload->getId()], ['typeMap' => ['root' => 'stdClass']]);
$download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file); $download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file);
$this->assertEquals("he", $download->downloadNumBytes(2)); $this->assertEquals("he", $download->downloadNumBytes(2));
$this->assertEquals("ll", $download->downloadNumBytes(2)); $this->assertEquals("ll", $download->downloadNumBytes(2));
...@@ -205,7 +205,7 @@ class GridFSStreamTest extends FunctionalTestCase ...@@ -205,7 +205,7 @@ class GridFSStreamTest extends FunctionalTestCase
$upload = new \MongoDB\GridFS\GridFSUpload($this->collectionsWrapper, "test", ["chunkSizeBytes"=>rand(1, 5)]); $upload = new \MongoDB\GridFS\GridFSUpload($this->collectionsWrapper, "test", ["chunkSizeBytes"=>rand(1, 5)]);
$upload->insertChunks($data); $upload->insertChunks($data);
$upload->close(); $upload->close();
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$upload->getId()]); $file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$upload->getId()], ['typeMap' => ['root' => 'stdClass']]);
$download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file); $download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file);
$readPos = 0; $readPos = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment