xref: /webtrees/tests/app/Services/SearchServiceTest.php (revision 9b93b7c342a543e7bd55b5a09d97ba0c39fc32b0)
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\Webtrees\TestCase;
21use Illuminate\Support\Collection;
22
23/**
24 * Test harness for the class SearchService
25 *
26 * @covers \Fisharebest\Webtrees\Services\SearchService
27 */
28class SearchServiceTest extends TestCase
29{
30    protected static $uses_database = true;
31
32    /**
33     * @return void
34     */
35    public function testSearchesReturnCollections(): void
36    {
37        $search_service = new SearchService();
38        $tree           = $this->importTree('demo.ged');
39
40        $result = $search_service->searchFamilies([$tree], ['windsor']);
41        $this->assertInstanceOf(Collection::class, $result);
42
43        $result = $search_service->searchFamilyNames([$tree], ['charles', 'diana']);
44        $this->assertInstanceOf(Collection::class, $result);
45
46        $result = $search_service->searchIndividuals([$tree], ['windsor']);
47        $this->assertInstanceOf(Collection::class, $result);
48
49        $result = $search_service->searchIndividualNames([$tree], ['windsor']);
50        $this->assertInstanceOf(Collection::class, $result);
51
52        $result = $search_service->searchMedia([$tree], ['windsor']);
53        $this->assertInstanceOf(Collection::class, $result);
54
55        $result = $search_service->searchNotes([$tree], ['windsor']);
56        $this->assertInstanceOf(Collection::class, $result);
57
58        $result = $search_service->searchRepositories([$tree], ['national']);
59        $this->assertInstanceOf(Collection::class, $result);
60
61        $result = $search_service->searchSources([$tree], ['england']);
62        $this->assertInstanceOf(Collection::class, $result);
63
64        $result = $search_service->searchSourcesByName([$tree], ['england']);
65        $this->assertInstanceOf(Collection::class, $result);
66
67        $result = $search_service->searchSubmitters([$tree], ['greg']);
68        $this->assertInstanceOf(Collection::class, $result);
69
70        $result = $search_service->searchPlaces($tree, 'England');
71        $this->assertInstanceOf(Collection::class, $result);
72    }
73}
74