. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\ResetHandlers; 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); View::share('tree', null); $request = self::createRequest(); $handler = new PasswordResetPage($user_service); $response = $handler->handle($request); self::assertSame(self::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(self::STATUS_FOUND, $response->getStatusCode()); } }