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