Skip to content

Commit

Permalink
Fix return type of getSearchIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Dec 23, 2024
1 parent b74b077 commit 21797a8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use MongoDB\BSON\Binary;
use MongoDB\BSON\Document;
use MongoDB\BSON\UTCDateTime;
use MongoDB\Collection;
use MongoDB\Laravel\Schema\Blueprint;
Expand Down Expand Up @@ -520,7 +521,7 @@ public function testSearchIndex(): void
});

$index = $this->getSearchIndex('newcollection', 'default');
self::assertNotFalse($index);
self::assertNotNull($index);

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

$index = $this->getSearchIndex('newcollection', 'vector');
self::assertNotFalse($index);
self::assertNotNull($index);

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

protected function getSearchIndex(string $collection, string $name)
protected function getSearchIndex(string $collection, string $name): ?Document
{
$collection = DB::getCollection($collection);
assert($collection instanceof Collection);

foreach ($collection->listSearchIndexes(['name' => $name]) as $index) {
foreach ($collection->listSearchIndexes(['name' => $name, 'typeMap' => ['root' => 'bson']]) as $index) {
return $index;
}

return false;
return null;
}
}

0 comments on commit 21797a8

Please sign in to comment.