test(SearchComposerTest): add test for handling unknown search provider

Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
pull/54120/head
Misha M.-Kupriyanov 2025-07-29 16:42:34 +07:00 committed by Mikhailo Matiyenko-Kupriyanov
parent 75770a00dd
commit d08fe6d6b3
1 changed files with 15 additions and 0 deletions

@ -9,10 +9,13 @@ declare(strict_types=1);
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;
@ -58,4 +61,16 @@ class SearchComposerTest extends TestCase {
$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);
}
}