. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\ResetHandlers; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Http\RequestHandlers\PasswordResetPage; use Fisharebest\Webtrees\Services\UserService; use Fisharebest\Webtrees\TestCase; use Fisharebest\Webtrees\User; use Fisharebest\Webtrees\View; /** * @covers \Fisharebest\Webtrees\Http\RequestHandlers\PasswordResetPage */ class PasswordResetPageTest extends TestCase { /** * @return void */ public function testPasswordResetPageWithValidToken(): void { $user = $this->createMock(User::class); $user_service = $this->createMock(UserService::class); $user_service->expects($this->once())->method('findByToken')->willReturn($user); $request = self::createRequest()->withAttribute('tree', null); $handler = new PasswordResetPage($user_service); $response = $handler->handle($request); self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode()); } /** * @return void */ public function testPasswordResetPageWithoutValidToken(): void { $user_service = $this->createMock(UserService::class); $user_service->expects($this->once())->method('findByToken')->willReturn(null); $request = self::createRequest(); $handler = new PasswordResetPage($user_service); $response = $handler->handle($request); self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode()); } }