Skip to content

Commit 3f65868

Browse files
committed
Add comments and assertions to testExistingIndexIsReused
1 parent 0365984 commit 3f65868

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tests/GridFS/BucketFunctionalTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,13 +814,22 @@ public function testUploadingFirstFileCreatesIndexes(): void
814814

815815
public function testExistingIndexIsReused(): void
816816
{
817-
// The collections may exist from other tests, ensure they are removed before and after the test
817+
// The collections may exist from other tests, ensure they are removed
818+
// before and after to avoid potential conflicts.
818819
$this->dropCollection($this->getDatabaseName(), 'fs.chunks');
819820
$this->dropCollection($this->getDatabaseName(), 'fs.files');
820821

822+
// Create indexes with different numeric types before interacting with
823+
// GridFS to assert that the library respects the existing indexes and
824+
// does not attempt to create its own.
821825
$this->filesCollection->createIndex(['filename' => 1.0, 'uploadDate' => 1], ['name' => 'test']);
822826
$this->chunksCollection->createIndex(['files_id' => 1.0, 'n' => 1], ['name' => 'test', 'unique' => true]);
823827

828+
$this->assertIndexExists('fs.files', 'test');
829+
$this->assertIndexExists('fs.chunks', 'test', function (IndexInfo $info): void {
830+
$this->assertTrue($info->isUnique());
831+
});
832+
824833
$this->bucket->uploadFromStream('filename', self::createStream('foo'));
825834

826835
$this->assertIndexNotExists($this->filesCollection->getCollectionName(), 'filename_1_uploadDate_1');

0 commit comments

Comments
 (0)