Skip to content

Commit 21797a8

Browse files
committed
Fix return type of getSearchIndex
1 parent b74b077 commit 21797a8

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;
@@ -520,7 +521,7 @@ public function testSearchIndex(): void
520521
});
521522

522523
$index = $this->getSearchIndex('newcollection', 'default');
523-
self::assertNotFalse($index);
524+
self::assertNotNull($index);
524525

525526
self::assertSame('default', $index['name']);
526527
self::assertSame('search', $index['type']);
@@ -541,7 +542,7 @@ public function testVectorSearchIndex()
541542
});
542543

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

546547
self::assertSame('vector', $index['name']);
547548
self::assertSame('vectorSearch', $index['type']);
@@ -562,15 +563,15 @@ protected function getIndex(string $collection, string $name)
562563
return false;
563564
}
564565

565-
protected function getSearchIndex(string $collection, string $name)
566+
protected function getSearchIndex(string $collection, string $name): ?Document
566567
{
567568
$collection = DB::getCollection($collection);
568569
assert($collection instanceof Collection);
569570

570-
foreach ($collection->listSearchIndexes(['name' => $name]) as $index) {
571+
foreach ($collection->listSearchIndexes(['name' => $name, 'typeMap' => ['root' => 'bson']]) as $index) {
571572
return $index;
572573
}
573574

574-
return false;
575+
return null;
575576
}
576577
}

0 commit comments

Comments
 (0)