xref: /webtrees/tests/feature/IndividualListTest.php (revision 6ccdf4f0fd1b65a5d54259c969912382ce49629d)
1e9e85398SGreg Roach<?php
2e9e85398SGreg Roach/**
3e9e85398SGreg Roach * webtrees: online genealogy
4e9e85398SGreg Roach * Copyright (C) 2019 webtrees development team
5e9e85398SGreg Roach * This program is free software: you can redistribute it and/or modify
6e9e85398SGreg Roach * it under the terms of the GNU General Public License as published by
7e9e85398SGreg Roach * the Free Software Foundation, either version 3 of the License, or
8e9e85398SGreg Roach * (at your option) any later version.
9e9e85398SGreg Roach * This program is distributed in the hope that it will be useful,
10e9e85398SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
11e9e85398SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12e9e85398SGreg Roach * GNU General Public License for more details.
13e9e85398SGreg Roach * You should have received a copy of the GNU General Public License
14e9e85398SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
15e9e85398SGreg Roach */
16e9e85398SGreg Roachdeclare(strict_types=1);
17e9e85398SGreg Roach
18e9e85398SGreg Roachnamespace Fisharebest\Webtrees;
19e9e85398SGreg Roach
20b9fc687eSGreg Roachuse Fisharebest\Localization\Locale\LocaleEnUs;
21b9fc687eSGreg Roachuse Fisharebest\Webtrees\Http\Controllers\ListController;
2287cca37cSGreg Roachuse Fisharebest\Webtrees\Module\IndividualListModule;
23b9fc687eSGreg Roachuse Fisharebest\Webtrees\Services\IndividualListService;
24b9fc687eSGreg Roachuse Fisharebest\Webtrees\Services\LocalizationService;
25b9fc687eSGreg Roach
26e9e85398SGreg Roach/**
27b9fc687eSGreg Roach * Test the individual lists.
28e9e85398SGreg Roach *
29e9e85398SGreg Roach * @coversNothing
30e9e85398SGreg Roach */
31e5a6b4d4SGreg Roachclass IndividualListTest extends TestCase
32e9e85398SGreg Roach{
33e9e85398SGreg Roach    protected static $uses_database = true;
34e9e85398SGreg Roach
35e9e85398SGreg Roach    /**
36b9fc687eSGreg Roach     * @covers \Fisharebest\Webtrees\Http\Controllers\ListController
37e9e85398SGreg Roach     * @return void
38e9e85398SGreg Roach     */
39b9fc687eSGreg Roach    public function testIndividualList(): void
40e9e85398SGreg Roach    {
41b9fc687eSGreg Roach        $tree = $this->importTree('demo.ged');
42b9fc687eSGreg Roach        $user = Auth::user();
43e11ffd0cSGreg Roach        app()->instance(Tree::class, $tree);
44e11ffd0cSGreg Roach        app()->instance(User::class, $user);
45b9fc687eSGreg Roach
4687cca37cSGreg Roach        $list_module             = new IndividualListModule();
47b9fc687eSGreg Roach        $localization_service    = new LocalizationService(new LocaleEnUs());
48b9fc687eSGreg Roach        $individual_list_service = new IndividualListService($localization_service, $tree);
49b9fc687eSGreg Roach        $controller              = new ListController($individual_list_service, $localization_service);
50b9fc687eSGreg Roach
51*6ccdf4f0SGreg Roach        $request  = self::createRequest('GET', [
52*6ccdf4f0SGreg Roach            'route'  => 'module',
53*6ccdf4f0SGreg Roach            'module' => 'individual_list',
54*6ccdf4f0SGreg Roach            'action' => 'List',
55*6ccdf4f0SGreg Roach        ]);
5687cca37cSGreg Roach        $response = $controller->individualList($request, $tree, $user, $list_module);
57*6ccdf4f0SGreg Roach        $this->assertSame(self::STATUS_OK, $response->getStatusCode());
58b9fc687eSGreg Roach
59*6ccdf4f0SGreg Roach        $request  = self::createRequest('GET', ['route' => 'module', 'module' => 'individual_list', 'action' => 'List', 'alpha' => 'B']);
6087cca37cSGreg Roach        $response = $controller->individualList($request, $tree, $user, $list_module);
61*6ccdf4f0SGreg Roach        $this->assertSame(self::STATUS_OK, $response->getStatusCode());
62b9fc687eSGreg Roach
63*6ccdf4f0SGreg Roach        $request  = self::createRequest('GET', ['route' => 'module', 'module' => 'individual_list', 'action' => 'List', 'alpha' => ',']);
6487cca37cSGreg Roach        $response = $controller->individualList($request, $tree, $user, $list_module);
65*6ccdf4f0SGreg Roach        $this->assertSame(self::STATUS_OK, $response->getStatusCode());
66b9fc687eSGreg Roach
67*6ccdf4f0SGreg Roach        $request  = self::createRequest('GET', ['route' => 'module', 'module' => 'individual_list', 'action' => 'List', 'alpha' => '@']);
6887cca37cSGreg Roach        $response = $controller->individualList($request, $tree, $user, $list_module);
69*6ccdf4f0SGreg Roach        $this->assertSame(self::STATUS_OK, $response->getStatusCode());
70b9fc687eSGreg Roach
71*6ccdf4f0SGreg Roach        $request  = self::createRequest('GET', ['route' => 'module', 'module' => 'individual_list', 'action' => 'List', 'surname' => 'BRAUN']);
7287cca37cSGreg Roach        $response = $controller->individualList($request, $tree, $user, $list_module);
73*6ccdf4f0SGreg Roach        $this->assertSame(self::STATUS_OK, $response->getStatusCode());
74e9e85398SGreg Roach    }
75e9e85398SGreg Roach}
76