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 committed Aug 11, 2025
commit c7aa401935d9fcb21cfee2d005473a009f4bd6f8
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);
}
}