@@ -344,6 +344,18 @@ public function testFindInheritsBucketCodec(): void
344
344
$ this ->assertSame ('a ' , $ fileDocument ->filename );
345
345
}
346
346
347
+ public function testFindResetsInheritedBucketCodec (): void
348
+ {
349
+ $ bucket = new Bucket ($ this ->manager , $ this ->getDatabaseName (), ['codec ' => new TestFileCodec ()]);
350
+ $ bucket ->uploadFromStream ('a ' , $ this ->createStream ('foo ' ));
351
+
352
+ $ cursor = $ bucket ->find ([], ['codec ' => null ]);
353
+ $ fileDocument = current ($ cursor ->toArray ());
354
+
355
+ $ this ->assertInstanceOf (BSONDocument::class, $ fileDocument );
356
+ $ this ->assertSame ('a ' , $ fileDocument ->filename );
357
+ }
358
+
347
359
public function testFindOne (): void
348
360
{
349
361
$ this ->bucket ->uploadFromStream ('a ' , $ this ->createStream ('foo ' ));
@@ -393,15 +405,33 @@ public function testFindOneInheritsBucketCodec(): void
393
405
$ bucket ->uploadFromStream ('b ' , $ this ->createStream ('foobar ' ));
394
406
$ bucket ->uploadFromStream ('c ' , $ this ->createStream ('foobarbaz ' ));
395
407
408
+ $ fileDocument = $ bucket ->findOne (
409
+ ['length ' => ['$lte ' => 6 ]],
410
+ ['sort ' => ['length ' => -1 ]],
411
+ );
412
+
413
+ $ this ->assertInstanceOf (TestFile::class, $ fileDocument );
414
+ $ this ->assertSame ('b ' , $ fileDocument ->filename );
415
+ $ this ->assertSame (6 , $ fileDocument ->length );
416
+ }
417
+
418
+ public function testFindOneResetsInheritedBucketCodec (): void
419
+ {
420
+ $ bucket = new Bucket ($ this ->manager , $ this ->getDatabaseName (), ['codec ' => new TestFileCodec ()]);
421
+
422
+ $ bucket ->uploadFromStream ('a ' , $ this ->createStream ('foo ' ));
423
+ $ bucket ->uploadFromStream ('b ' , $ this ->createStream ('foobar ' ));
424
+ $ bucket ->uploadFromStream ('c ' , $ this ->createStream ('foobarbaz ' ));
425
+
396
426
$ fileDocument = $ bucket ->findOne (
397
427
['length ' => ['$lte ' => 6 ]],
398
428
[
399
429
'sort ' => ['length ' => -1 ],
400
- 'codec ' => new TestFileCodec () ,
430
+ 'codec ' => null ,
401
431
],
402
432
);
403
433
404
- $ this ->assertInstanceOf (TestFile ::class, $ fileDocument );
434
+ $ this ->assertInstanceOf (BSONDocument ::class, $ fileDocument );
405
435
$ this ->assertSame ('b ' , $ fileDocument ->filename );
406
436
$ this ->assertSame (6 , $ fileDocument ->length );
407
437
}
0 commit comments