Skip to content

Commit 4cd5342

Browse files
committed
GridFSDownload expects file document to be stdClass
1 parent c674aac commit 4cd5342

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/GridFS/GridFSStreamTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function testBasic()
2020
$this->assertEquals(1, $this->collectionsWrapper->getFilesCollection()->count());
2121
$this->assertEquals(1, $this->collectionsWrapper->getChunksCollection()->count());
2222

23-
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$id]);
23+
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$id], ['typeMap' => ['root' => 'stdClass']]);
2424

2525
$download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file);
2626
$stream = fopen('php://temp', 'w+');
@@ -46,7 +46,7 @@ public function testBasic()
4646
$this->assertEquals(2, $this->collectionsWrapper->getFilesCollection()->count());
4747
$this->assertEquals(1, $this->collectionsWrapper->getChunksCollection()->count());
4848

49-
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$id]);
49+
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$id], ['typeMap' => ['root' => 'stdClass']]);
5050
$download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file);
5151
$stream = fopen('php://temp', 'w+');
5252
$download->downloadToStream($stream);
@@ -100,7 +100,7 @@ public function testDownloadDefaultOpts()
100100
$upload = new \MongoDB\GridFS\GridFSUpload($this->collectionsWrapper, "test");
101101
$upload->close();
102102

103-
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id" => $upload->getId()]);
103+
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id" => $upload->getId()], ['typeMap' => ['root' => 'stdClass']]);
104104
$download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file);
105105
$download->close();
106106

@@ -124,7 +124,7 @@ public function testDownloadCustomOpts()
124124
$upload->insertChunks("hello world");
125125
$upload->close();
126126

127-
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id" => $upload->getId()]);
127+
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id" => $upload->getId()], ['typeMap' => ['root' => 'stdClass']]);
128128
$download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file);
129129

130130
$this->assertEquals("test", $download->getFile()->filename);
@@ -185,7 +185,7 @@ public function testMultipleReads()
185185
$upload = new \MongoDB\GridFS\GridFSUpload($this->collectionsWrapper, "test", ["chunkSizeBytes"=>3]);
186186
$upload->insertChunks("hello world");
187187
$upload->close();
188-
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$upload->getId()]);
188+
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$upload->getId()], ['typeMap' => ['root' => 'stdClass']]);
189189
$download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file);
190190
$this->assertEquals("he", $download->downloadNumBytes(2));
191191
$this->assertEquals("ll", $download->downloadNumBytes(2));
@@ -205,7 +205,7 @@ public function testProvidedMultipleReads($data)
205205
$upload = new \MongoDB\GridFS\GridFSUpload($this->collectionsWrapper, "test", ["chunkSizeBytes"=>rand(1, 5)]);
206206
$upload->insertChunks($data);
207207
$upload->close();
208-
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$upload->getId()]);
208+
$file = $this->collectionsWrapper->getFilesCollection()->findOne(["_id"=>$upload->getId()], ['typeMap' => ['root' => 'stdClass']]);
209209
$download = new \MongoDB\GridFS\GridFSDownload($this->collectionsWrapper, $file);
210210

211211
$readPos = 0;

0 commit comments

Comments
 (0)