Skip to content

Commit aed2665

Browse files
committed
Add explanatory comment for ID filling behaviour
1 parent 0be8dd0 commit aed2665

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tests/Collection/CodecCollectionFunctionalTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ public function testInsertMany($expected, $options): void
395395
$result = $this->collection->insertMany($documents, $options);
396396
$this->assertSame(3, $result->getInsertedCount());
397397

398+
// Add missing identifiers. This is relevant for the "No codec" data set, as the encoded document will not have
399+
// an "_id" field and the driver will automatically generate one.
398400
foreach ($expected as $index => &$expectedDocument) {
399401
if ($expectedDocument instanceof BSONDocument && $expectedDocument->_id === null) {
400402
$expectedDocument->_id = $result->getInsertedIds()[$index];
@@ -434,6 +436,8 @@ public function testInsertOne($expected, $options): void
434436
$result = $this->collection->insertOne(TestObject::createForFixture(1), $options);
435437
$this->assertSame(1, $result->getInsertedCount());
436438

439+
// Add missing identifiers. This is relevant for the "No codec" data set, as the encoded document will not have
440+
// an "_id" field and the driver will automatically generate one.
437441
if ($expected instanceof BSONDocument && $expected->_id === null) {
438442
$expected->_id = $result->getInsertedId();
439443
}

0 commit comments

Comments
 (0)