File tree Expand file tree Collapse file tree 5 files changed +28
-7
lines changed Expand file tree Collapse file tree 5 files changed +28
-7
lines changed File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 17
17
use function fwrite ;
18
18
use function getenv ;
19
19
use function rewind ;
20
+ use function stream_get_contents ;
20
21
21
22
use const PHP_EOL ;
22
- use const STDOUT ;
23
23
24
24
require __DIR__ . '/../vendor/autoload.php ' ;
25
25
38
38
echo 'Inserted file with ID: ' . $ id . PHP_EOL ;
39
39
fclose ($ stream );
40
40
41
- // Download the file and print the contents directly to STDOUT, chunk by chunk
42
- echo 'File contents: ' ;
43
- $ gridfs ->downloadToStreamByName ('hello.txt ' , STDOUT );
44
- echo PHP_EOL ;
41
+ // Download the file and print the contents directly to an in-memory stream, chunk by chunk
42
+ $ stream = fopen ('php://temp ' , 'w+ ' );
43
+ $ gridfs ->downloadToStreamByName ('hello.txt ' , $ stream );
44
+ rewind ($ stream );
45
+ echo 'File contents: ' . stream_get_contents ($ stream ) . PHP_EOL ;
45
46
46
47
// Delete the file
47
48
$ gridfs ->delete ($ id );
Original file line number Diff line number Diff line change 5
5
<code ><![CDATA[ $clientEncryption->decrypt($document->encryptedField)]]> </code >
6
6
</MixedArgument >
7
7
</file >
8
- <file src =" examples/atlas-search .php" >
8
+ <file src =" examples/atlas_search .php" >
9
9
<MixedArgument >
10
10
<code ><![CDATA[ $document['name']]]> </code >
11
11
<code ><![CDATA[ $index->name]]> </code >
Original file line number Diff line number Diff line change @@ -99,6 +99,26 @@ public static function provideExamples(): Generator
99
99
'expectedOutput ' => $ expectedOutput ,
100
100
];
101
101
102
+ $ expectedOutput = <<<'OUTPUT'
103
+ Read a total of 17888890 bytes
104
+ OUTPUT;
105
+
106
+ yield 'gridfs_stream ' => [
107
+ 'file ' => __DIR__ . '/../examples/gridfs_stream.php ' ,
108
+ 'expectedOutput ' => $ expectedOutput ,
109
+ ];
110
+
111
+ $ expectedOutput = <<<'OUTPUT'
112
+ Inserted file with ID: %s
113
+ File contents: Hello world!
114
+
115
+ OUTPUT;
116
+
117
+ yield 'gridfs_upload ' => [
118
+ 'file ' => __DIR__ . '/../examples/gridfs_upload.php ' ,
119
+ 'expectedOutput ' => $ expectedOutput ,
120
+ ];
121
+
102
122
$ expectedOutput = <<<'OUTPUT'
103
123
File exists: no
104
124
Writing file
@@ -243,7 +263,7 @@ public function testAtlasSearch(): void
243
263
244
264
OUTPUT;
245
265
246
- $ this ->assertExampleOutput (__DIR__ . '/../examples/atlas-search .php ' , $ expectedOutput );
266
+ $ this ->assertExampleOutput (__DIR__ . '/../examples/atlas_search .php ' , $ expectedOutput );
247
267
}
248
268
249
269
public function testChangeStream (): void
You can’t perform that action at this time.
0 commit comments