xref: /webtrees/tests/app/Services/SearchServiceTest.php (revision 73f6d2b56f07f42ca02190f0dfc40653a1e91834)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2023 webtrees development team
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\Services;
21
22use Fisharebest\Webtrees\TestCase;
23use Illuminate\Support\Collection;
24use PHPUnit\Framework\Attributes\CoversClass;
25
26#[CoversClass(SearchService::class)]
27class SearchServiceTest extends TestCase
28{
29    protected static bool $uses_database = true;
30
31    public function testSearchesReturnCollections(): void
32    {
33        $tree_service = new TreeService(new GedcomImportService());
34        $search_service = new SearchService($tree_service);
35        $tree = $this->importTree('demo.ged');
36
37        $result = $search_service->searchFamilies([$tree], ['windsor']);
38        self::assertInstanceOf(Collection::class, $result);
39
40        $result = $search_service->searchFamilyNames([$tree], ['charles', 'diana']);
41        self::assertInstanceOf(Collection::class, $result);
42
43        $result = $search_service->searchIndividuals([$tree], ['windsor']);
44        self::assertInstanceOf(Collection::class, $result);
45
46        $result = $search_service->searchIndividualNames([$tree], ['windsor']);
47        self::assertInstanceOf(Collection::class, $result);
48
49        $result = $search_service->searchMedia([$tree], ['windsor']);
50        self::assertInstanceOf(Collection::class, $result);
51
52        $result = $search_service->searchNotes([$tree], ['windsor']);
53        self::assertInstanceOf(Collection::class, $result);
54
55        $result = $search_service->searchRepositories([$tree], ['national']);
56        self::assertInstanceOf(Collection::class, $result);
57
58        $result = $search_service->searchSources([$tree], ['england']);
59        self::assertInstanceOf(Collection::class, $result);
60
61        $result = $search_service->searchSourcesByName([$tree], ['england']);
62        self::assertInstanceOf(Collection::class, $result);
63
64        $result = $search_service->searchSubmitters([$tree], ['greg']);
65        self::assertInstanceOf(Collection::class, $result);
66
67        $result = $search_service->searchPlaces($tree, 'England');
68        self::assertInstanceOf(Collection::class, $result);
69    }
70}
71