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 20*b9fc687eSGreg Roachuse Fisharebest\Localization\Locale\LocaleEnUs; 21*b9fc687eSGreg Roachuse Fisharebest\Webtrees\Http\Controllers\ListController; 22*b9fc687eSGreg Roachuse Fisharebest\Webtrees\Services\IndividualListService; 23*b9fc687eSGreg Roachuse Fisharebest\Webtrees\Services\LocalizationService; 24*b9fc687eSGreg Roachuse Fisharebest\Webtrees\Theme\WebtreesTheme; 25*b9fc687eSGreg Roachuse Symfony\Component\HttpFoundation\Request; 26*b9fc687eSGreg Roachuse Symfony\Component\HttpFoundation\Response; 27*b9fc687eSGreg Roach 28e9e85398SGreg Roach/** 29*b9fc687eSGreg Roach * Test the individual lists. 30e9e85398SGreg Roach * 31e9e85398SGreg Roach * @coversNothing 32e9e85398SGreg Roach */ 33*b9fc687eSGreg Roachclass IndividualListTest extends \Fisharebest\Webtrees\TestCase 34e9e85398SGreg Roach{ 35e9e85398SGreg Roach protected static $uses_database = true; 36e9e85398SGreg Roach 37e9e85398SGreg Roach /** 38*b9fc687eSGreg Roach * @covers \Fisharebest\Webtrees\Http\Controllers\ListController 39e9e85398SGreg Roach * @return void 40e9e85398SGreg Roach */ 41*b9fc687eSGreg Roach public function testIndividualList(): void 42e9e85398SGreg Roach { 43*b9fc687eSGreg Roach // Needed for Date::display() 44*b9fc687eSGreg Roach global $tree; 45e9e85398SGreg Roach 46*b9fc687eSGreg Roach $tree = $this->importTree('demo.ged'); 47*b9fc687eSGreg Roach $user = Auth::user(); 48*b9fc687eSGreg Roach 49*b9fc687eSGreg Roach $localization_service = new LocalizationService(new LocaleEnUs()); 50*b9fc687eSGreg Roach $individual_list_service = new IndividualListService($localization_service, $tree); 51*b9fc687eSGreg Roach $controller = new ListController($individual_list_service, $localization_service); 52*b9fc687eSGreg Roach 53*b9fc687eSGreg Roach $request = new Request(['route' => 'individual-list']); 54*b9fc687eSGreg Roach Theme::theme(new WebtreesTheme())->init(new Request, $tree); 55*b9fc687eSGreg Roach $response = $controller->individualList($request, $tree, $user); 56*b9fc687eSGreg Roach $this->assertSame(Response::HTTP_OK, $response->getStatusCode()); 57*b9fc687eSGreg Roach 58*b9fc687eSGreg Roach $request = new Request(['route' => 'individual-list', 'alpha' => 'B']); 59*b9fc687eSGreg Roach Theme::theme(new WebtreesTheme())->init(new Request, $tree); 60*b9fc687eSGreg Roach $response = $controller->individualList($request, $tree, $user); 61*b9fc687eSGreg Roach $this->assertSame(Response::HTTP_OK, $response->getStatusCode()); 62*b9fc687eSGreg Roach 63*b9fc687eSGreg Roach $request = new Request(['route' => 'individual-list', 'alpha' => ',']); 64*b9fc687eSGreg Roach Theme::theme(new WebtreesTheme())->init(new Request, $tree); 65*b9fc687eSGreg Roach $response = $controller->individualList($request, $tree, $user); 66*b9fc687eSGreg Roach $this->assertSame(Response::HTTP_OK, $response->getStatusCode()); 67*b9fc687eSGreg Roach 68*b9fc687eSGreg Roach $request = new Request(['route' => 'individual-list', 'alpha' => '@']); 69*b9fc687eSGreg Roach Theme::theme(new WebtreesTheme())->init(new Request, $tree); 70*b9fc687eSGreg Roach $response = $controller->individualList($request, $tree, $user); 71*b9fc687eSGreg Roach $this->assertSame(Response::HTTP_OK, $response->getStatusCode()); 72*b9fc687eSGreg Roach 73*b9fc687eSGreg Roach $request = new Request(['route' => 'individual-list', 'surname' => 'BRAUN']); 74*b9fc687eSGreg Roach Theme::theme(new WebtreesTheme())->init(new Request, $tree); 75*b9fc687eSGreg Roach $response = $controller->individualList($request, $tree, $user); 76*b9fc687eSGreg Roach $this->assertSame(Response::HTTP_OK, $response->getStatusCode()); 77e9e85398SGreg Roach } 78e9e85398SGreg Roach} 79