1d403609dSGreg Roach<?php 2d403609dSGreg Roach 3d403609dSGreg Roach/** 4d403609dSGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 6d403609dSGreg Roach * This program is free software: you can redistribute it and/or modify 7d403609dSGreg Roach * it under the terms of the GNU General Public License as published by 8d403609dSGreg Roach * the Free Software Foundation, either version 3 of the License, or 9d403609dSGreg Roach * (at your option) any later version. 10d403609dSGreg Roach * This program is distributed in the hope that it will be useful, 11d403609dSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12d403609dSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13d403609dSGreg Roach * GNU General Public License for more details. 14d403609dSGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 16d403609dSGreg Roach */ 17fcfa147eSGreg Roach 18d403609dSGreg Roachdeclare(strict_types=1); 19d403609dSGreg Roach 20d403609dSGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers; 21d403609dSGreg Roach 2271378461SGreg Roachuse Fig\Http\Message\StatusCodeInterface; 232c685d76SGreg Roachuse Fisharebest\Webtrees\Services\GedcomImportService; 245fb051e9SGreg Roachuse Fisharebest\Webtrees\Services\TreeService; 25d403609dSGreg Roachuse Fisharebest\Webtrees\TestCase; 26d403609dSGreg Roachuse Fisharebest\Webtrees\User; 27*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass; 28d403609dSGreg Roach 29*202c018bSGreg Roach#[CoversClass(LoginPage::class)] 30d403609dSGreg Roachclass LoginPageTest extends TestCase 31d403609dSGreg Roach{ 32a26ec5edSGreg Roach protected static bool $uses_database = true; 33a26ec5edSGreg Roach 34d403609dSGreg Roach public function testLoginPage(): void 35d403609dSGreg Roach { 362c685d76SGreg Roach $gedcom_import_service = new GedcomImportService(); 372c685d76SGreg Roach $tree_service = new TreeService($gedcom_import_service); 38d403609dSGreg Roach $request = self::createRequest(); 395fb051e9SGreg Roach $handler = new LoginPage($tree_service); 40d403609dSGreg Roach $response = $handler->handle($request); 41d403609dSGreg Roach 4271378461SGreg Roach self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); 43d403609dSGreg Roach } 44d403609dSGreg Roach 45d403609dSGreg Roach public function testLoginPageAlreadyLoggedIn(): void 46d403609dSGreg Roach { 472c685d76SGreg Roach $gedcom_import_service = new GedcomImportService(); 482c685d76SGreg Roach $tree_service = new TreeService($gedcom_import_service); 49cd94ca66SGreg Roach $user = $this->createMock(User::class); 50d403609dSGreg Roach $request = self::createRequest()->withAttribute('user', $user); 515fb051e9SGreg Roach $handler = new LoginPage($tree_service); 52d403609dSGreg Roach $response = $handler->handle($request); 53d403609dSGreg Roach 5471378461SGreg Roach self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); 55d403609dSGreg Roach } 56d403609dSGreg Roach} 57