. */ declare(strict_types=1); namespace Fisharebest\Webtrees; use Fig\Http\Message\RequestMethodInterface; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Localization\Locale\LocaleEnUs; use Fisharebest\Webtrees\Http\Controllers\ListController; use Fisharebest\Webtrees\Module\IndividualListModule; use Fisharebest\Webtrees\Services\IndividualListService; use Fisharebest\Webtrees\Services\LocalizationService; /** * Test the individual lists. * * @coversNothing */ class IndividualListTest extends TestCase { protected static $uses_database = true; /** * @covers \Fisharebest\Webtrees\Http\Controllers\ListController * @return void */ public function testIndividualList(): void { $tree = $this->importTree('demo.ged'); $user = Auth::user(); $list_module = new IndividualListModule(); $localization_service = new LocalizationService(new LocaleEnUs()); $individual_list_service = new IndividualListService($localization_service, $tree); $controller = new ListController($individual_list_service, $localization_service); $request = self::createRequest() ->withAttribute('tree', $tree) ->withAttribute('user', $user); $response = $controller->individualList($request, $list_module); $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['alpha' => 'B']) ->withAttribute('tree', $tree) ->withAttribute('user', $user); $response = $controller->individualList($request, $list_module); $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['alpha' => ',']) ->withAttribute('tree', $tree) ->withAttribute('user', $user); $response = $controller->individualList($request, $list_module); $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['alpha' => '@']) ->withAttribute('tree', $tree) ->withAttribute('user', $tree); $response = $controller->individualList($request, $list_module); $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['surname' => 'BRAUN']) ->withAttribute('tree', $tree) ->withAttribute('user', $user); $response = $controller->individualList($request, $list_module); $this->assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } }