1e9e85398SGreg Roach<?php 2*3976b470SGreg Roach 3e9e85398SGreg Roach/** 4e9e85398SGreg Roach * webtrees: online genealogy 5e9e85398SGreg Roach * Copyright (C) 2019 webtrees development team 6e9e85398SGreg Roach * This program is free software: you can redistribute it and/or modify 7e9e85398SGreg Roach * it under the terms of the GNU General Public License as published by 8e9e85398SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9e9e85398SGreg Roach * (at your option) any later version. 10e9e85398SGreg Roach * This program is distributed in the hope that it will be useful, 11e9e85398SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12e9e85398SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13e9e85398SGreg Roach * GNU General Public License for more details. 14e9e85398SGreg Roach * You should have received a copy of the GNU General Public License 15e9e85398SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 16e9e85398SGreg Roach */ 17e9e85398SGreg Roachdeclare(strict_types=1); 18e9e85398SGreg Roach 19e9e85398SGreg Roachnamespace Fisharebest\Webtrees; 20e9e85398SGreg Roach 21b9fc687eSGreg Roachuse Fisharebest\Localization\Locale\LocaleEnUs; 22b9fc687eSGreg Roachuse Fisharebest\Webtrees\Http\Controllers\ListController; 2387cca37cSGreg Roachuse Fisharebest\Webtrees\Module\IndividualListModule; 24b9fc687eSGreg Roachuse Fisharebest\Webtrees\Services\IndividualListService; 25b9fc687eSGreg Roachuse Fisharebest\Webtrees\Services\LocalizationService; 26b9fc687eSGreg Roach 27e9e85398SGreg Roach/** 28b9fc687eSGreg Roach * Test the individual lists. 29e9e85398SGreg Roach * 30e9e85398SGreg Roach * @coversNothing 31e9e85398SGreg Roach */ 32e5a6b4d4SGreg Roachclass IndividualListTest extends TestCase 33e9e85398SGreg Roach{ 34e9e85398SGreg Roach protected static $uses_database = true; 35e9e85398SGreg Roach 36e9e85398SGreg Roach /** 37b9fc687eSGreg Roach * @covers \Fisharebest\Webtrees\Http\Controllers\ListController 38e9e85398SGreg Roach * @return void 39e9e85398SGreg Roach */ 40b9fc687eSGreg Roach public function testIndividualList(): void 41e9e85398SGreg Roach { 42b9fc687eSGreg Roach $tree = $this->importTree('demo.ged'); 43b9fc687eSGreg Roach $user = Auth::user(); 44e11ffd0cSGreg Roach app()->instance(Tree::class, $tree); 45e11ffd0cSGreg Roach app()->instance(User::class, $user); 46b9fc687eSGreg Roach 4787cca37cSGreg Roach $list_module = new IndividualListModule(); 48b9fc687eSGreg Roach $localization_service = new LocalizationService(new LocaleEnUs()); 49b9fc687eSGreg Roach $individual_list_service = new IndividualListService($localization_service, $tree); 50b9fc687eSGreg Roach $controller = new ListController($individual_list_service, $localization_service); 51b9fc687eSGreg Roach 526ccdf4f0SGreg Roach $request = self::createRequest('GET', [ 536ccdf4f0SGreg Roach 'route' => 'module', 546ccdf4f0SGreg Roach 'module' => 'individual_list', 556ccdf4f0SGreg Roach 'action' => 'List', 5657ab2231SGreg Roach ])->withAttribute('tree', $tree) 5757ab2231SGreg Roach ->withAttribute('user', $user); 5857ab2231SGreg Roach $response = $controller->individualList($request, $list_module); 596ccdf4f0SGreg Roach $this->assertSame(self::STATUS_OK, $response->getStatusCode()); 60b9fc687eSGreg Roach 6157ab2231SGreg Roach $request = self::createRequest('GET', ['route' => 'module', 'module' => 'individual_list', 'action' => 'List', 'alpha' => 'B']) 6257ab2231SGreg Roach ->withAttribute('tree', $tree) 6357ab2231SGreg Roach ->withAttribute('user', $user); 6457ab2231SGreg Roach $response = $controller->individualList($request, $list_module); 656ccdf4f0SGreg Roach $this->assertSame(self::STATUS_OK, $response->getStatusCode()); 66b9fc687eSGreg Roach 6757ab2231SGreg Roach $request = self::createRequest('GET', ['route' => 'module', 'module' => 'individual_list', 'action' => 'List', 'alpha' => ',']) 6857ab2231SGreg Roach ->withAttribute('tree', $tree) 6957ab2231SGreg Roach ->withAttribute('user', $user); 7057ab2231SGreg Roach $response = $controller->individualList($request, $list_module); 716ccdf4f0SGreg Roach $this->assertSame(self::STATUS_OK, $response->getStatusCode()); 72b9fc687eSGreg Roach 7357ab2231SGreg Roach $request = self::createRequest('GET', ['route' => 'module', 'module' => 'individual_list', 'action' => 'List', 'alpha' => '@']) 7457ab2231SGreg Roach ->withAttribute('tree', $tree) 7557ab2231SGreg Roach ->withAttribute('user', $tree); 7657ab2231SGreg Roach $response = $controller->individualList($request, $list_module); 776ccdf4f0SGreg Roach $this->assertSame(self::STATUS_OK, $response->getStatusCode()); 78b9fc687eSGreg Roach 7957ab2231SGreg Roach $request = self::createRequest('GET', ['route' => 'module', 'module' => 'individual_list', 'action' => 'List', 'surname' => 'BRAUN']) 8057ab2231SGreg Roach ->withAttribute('tree', $tree) 8157ab2231SGreg Roach ->withAttribute('user', $user); 8257ab2231SGreg Roach $response = $controller->individualList($request, $list_module); 836ccdf4f0SGreg Roach $this->assertSame(self::STATUS_OK, $response->getStatusCode()); 84e9e85398SGreg Roach } 85e9e85398SGreg Roach} 86