Skip to content

Commit

Permalink
Dont throw runtime exception if no affected gambits
Browse files Browse the repository at this point in the history
  • Loading branch information
askvortsov1 committed Apr 9, 2021
1 parent 9a2351d commit dc07338
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/Search/SearchServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public function boot()
}
}

throw new \RuntimeException('You cannot add gambits to searchers that do not have fulltext gambits. The following searchers have this issue: '.implode(', ', $affectedGambits));
if (count($affectedGambits)) {
throw new \RuntimeException('You cannot add gambits to searchers that do not have fulltext gambits. The following searchers have this issue: '.implode(', ', $affectedGambits));
}
}

foreach ($fullTextGambits as $searcher => $fullTextGambitClass) {
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/extenders/SimpleFlarumSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function can_add_gambit_to_nonexistent_searcher_class_without_fulltext()

try {
$this->app();
} catch (RuntimeException $e) {
} catch (\RuntimeException $e) {
$anExceptionWasThrown = true;
}

Expand All @@ -195,9 +195,9 @@ public function can_add_gambit_to_nonexistent_searcher_class_without_fulltext()
*/
public function cant_add_gambit_to_existent_searcher_class_without_fulltext()
{
$this->extend((new Extend\SimpleFlarumSearch(AbstractSearcher::class))->addGambit(NoResultFilterGambit::class));

$this->expectException(\RuntimeException::class);

$this->extend((new Extend\SimpleFlarumSearch(AbstractSearcher::class))->addGambit(NoResultFilterGambit::class));
$this->app();
}
}
Expand Down

0 comments on commit dc07338

Please sign in to comment.