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