|
8 | 8 | use MongoDB\Collection;
|
9 | 9 | use MongoDB\Driver\BulkWrite;
|
10 | 10 | use MongoDB\Exception\InvalidArgumentException;
|
| 11 | +use MongoDB\Exception\UnsupportedValueException; |
11 | 12 | use MongoDB\Model\BSONDocument;
|
12 | 13 | use MongoDB\Operation\FindOneAndReplace;
|
13 | 14 | use MongoDB\Tests\Fixtures\Codec\TestDocumentCodec;
|
@@ -264,6 +265,12 @@ public function testFindOneAndReplaceWithCodecAndTypemap(): void
|
264 | 265 | $this->collection->findOneAndReplace(['_id' => 1], TestObject::createForFixture(1), $options);
|
265 | 266 | }
|
266 | 267 |
|
| 268 | + public function testFindOneAndReplaceWithArray(): void |
| 269 | + { |
| 270 | + $this->expectExceptionObject(UnsupportedValueException::invalidEncodableValue([])); |
| 271 | + $this->collection->findOneAndReplace(['_id' => 1], ['foo' => 'bar']); |
| 272 | + } |
| 273 | + |
267 | 274 | public static function provideFindOptions(): Generator
|
268 | 275 | {
|
269 | 276 | yield 'Default codec' => [
|
@@ -413,6 +420,12 @@ public function testInsertMany($expected, $options): void
|
413 | 420 | $this->assertEquals($expected, $this->collection->find([], $options)->toArray());
|
414 | 421 | }
|
415 | 422 |
|
| 423 | + public function testInsertManyWithArray(): void |
| 424 | + { |
| 425 | + $this->expectExceptionObject(UnsupportedValueException::invalidEncodableValue([])); |
| 426 | + $this->collection->insertMany([['foo' => 'bar']]); |
| 427 | + } |
| 428 | + |
416 | 429 | public static function provideInsertOneOptions(): Generator
|
417 | 430 | {
|
418 | 431 | yield 'Default codec' => [
|
@@ -452,6 +465,12 @@ public function testInsertOne($expected, $options): void
|
452 | 465 | $this->assertEquals($expected, $this->collection->findOne([], $options));
|
453 | 466 | }
|
454 | 467 |
|
| 468 | + public function testInsertOneWithArray(): void |
| 469 | + { |
| 470 | + $this->expectExceptionObject(UnsupportedValueException::invalidEncodableValue([])); |
| 471 | + $this->collection->insertOne(['foo' => 'bar']); |
| 472 | + } |
| 473 | + |
455 | 474 | public static function provideReplaceOneOptions(): Generator
|
456 | 475 | {
|
457 | 476 | $replacedObject = TestObject::createDecodedForFixture(1);
|
@@ -499,7 +518,13 @@ public function testReplaceOneWithCodecAndTypemap(): void
|
499 | 518 | ];
|
500 | 519 |
|
501 | 520 | $this->expectExceptionObject(InvalidArgumentException::cannotCombineCodecAndTypeMap());
|
502 |
| - $this->collection->replaceOne(['_id' => 1], ['foo' => 'bar'], $options); |
| 521 | + $this->collection->replaceOne(['_id' => 1], (object) ['foo' => 'bar'], $options); |
| 522 | + } |
| 523 | + |
| 524 | + public function testReplaceOneWithArray(): void |
| 525 | + { |
| 526 | + $this->expectExceptionObject(UnsupportedValueException::invalidEncodableValue([])); |
| 527 | + $this->collection->replaceOne(['_id' => 1], ['foo' => 'bar']); |
503 | 528 | }
|
504 | 529 |
|
505 | 530 | /**
|
|
0 commit comments