Skip to content

Commit 073ecdf

Browse files
committed
Fix return type of getSearchIndex
1 parent fc78500 commit 073ecdf

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tests/SchemaTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Support\Facades\DB;
88
use Illuminate\Support\Facades\Schema;
99
use MongoDB\BSON\Binary;
10+
use MongoDB\BSON\Document;
1011
use MongoDB\BSON\UTCDateTime;
1112
use MongoDB\Collection;
1213
use MongoDB\Laravel\Schema\Blueprint;
@@ -541,7 +542,7 @@ public function testSearchIndex(): void
541542
});
542543

543544
$index = $this->getSearchIndex('newcollection', 'default');
544-
self::assertNotFalse($index);
545+
self::assertNotNull($index);
545546

546547
self::assertSame('default', $index['name']);
547548
self::assertSame('search', $index['type']);
@@ -562,7 +563,7 @@ public function testVectorSearchIndex()
562563
});
563564

564565
$index = $this->getSearchIndex('newcollection', 'vector');
565-
self::assertNotFalse($index);
566+
self::assertNotNull($index);
566567

567568
self::assertSame('vector', $index['name']);
568569
self::assertSame('vectorSearch', $index['type']);
@@ -583,15 +584,15 @@ protected function getIndex(string $collection, string $name)
583584
return false;
584585
}
585586

586-
protected function getSearchIndex(string $collection, string $name)
587+
protected function getSearchIndex(string $collection, string $name): ?Document
587588
{
588589
$collection = DB::getCollection($collection);
589590
assert($collection instanceof Collection);
590591

591-
foreach ($collection->listSearchIndexes(['name' => $name]) as $index) {
592+
foreach ($collection->listSearchIndexes(['name' => $name, 'typeMap' => ['root' => 'bson']]) as $index) {
592593
return $index;
593594
}
594595

595-
return false;
596+
return null;
596597
}
597598
}

0 commit comments

Comments
 (0)