Skip to content
Prev Previous commit
Next Next commit
test(SearchComposerTest): add test for handling unknown search provider
Signed-off-by: Misha M.-Kupriyanov <[email protected]>
  • Loading branch information
printminion-co authored and backportbot[bot] committed Aug 14, 2025
commit 09172cfe690f8b0d4178af21da8126c87055bfae
15 changes: 15 additions & 0 deletions tests/lib/Search/SearchComposerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@

namespace Test\Search;

use InvalidArgumentException;
use OC\AppFramework\Bootstrap\Coordinator;
use OC\Search\SearchComposer;
use OCP\IAppConfig;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\Search\ISearchQuery;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -58,4 +61,16 @@ public function testGetProvidersWithNoRegisteredProviders(): void {
$this->assertIsArray($providers);
$this->assertEmpty($providers);
}

public function testSearchWithUnknownProvider(): void {
$this->setupEmptyRegistrationContext();

$user = $this->createMock(IUser::class);
$query = $this->createMock(ISearchQuery::class);

$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Provider unknown_provider is unknown');

$this->searchComposer->search($user, 'unknown_provider', $query);
}
}