. */ declare(strict_types=1); namespace Fisharebest\Webtrees; 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(); app()->instance(Tree::class, $tree); app()->instance(User::class, $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('GET', [ 'route' => 'module', 'module' => 'individual_list', 'action' => 'List', ])->withAttribute('tree', $tree) ->withAttribute('user', $user); $response = $controller->individualList($request, $list_module); $this->assertSame(self::STATUS_OK, $response->getStatusCode()); $request = self::createRequest('GET', ['route' => 'module', 'module' => 'individual_list', 'action' => 'List', 'alpha' => 'B']) ->withAttribute('tree', $tree) ->withAttribute('user', $user); $response = $controller->individualList($request, $list_module); $this->assertSame(self::STATUS_OK, $response->getStatusCode()); $request = self::createRequest('GET', ['route' => 'module', 'module' => 'individual_list', 'action' => 'List', 'alpha' => ',']) ->withAttribute('tree', $tree) ->withAttribute('user', $user); $response = $controller->individualList($request, $list_module); $this->assertSame(self::STATUS_OK, $response->getStatusCode()); $request = self::createRequest('GET', ['route' => 'module', 'module' => 'individual_list', 'action' => 'List', 'alpha' => '@']) ->withAttribute('tree', $tree) ->withAttribute('user', $tree); $response = $controller->individualList($request, $list_module); $this->assertSame(self::STATUS_OK, $response->getStatusCode()); $request = self::createRequest('GET', ['route' => 'module', 'module' => 'individual_list', 'action' => 'List', 'surname' => 'BRAUN']) ->withAttribute('tree', $tree) ->withAttribute('user', $user); $response = $controller->individualList($request, $list_module); $this->assertSame(self::STATUS_OK, $response->getStatusCode()); } }