. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\GuestUser; use Fisharebest\Webtrees\TestCase; use Fisharebest\Webtrees\User; /** * @covers \Fisharebest\Webtrees\Http\RequestHandlers\SelectTheme */ class SelectThemeTest extends TestCase { public function testSelectThemeForGuest(): void { $user = $this->createMock(GuestUser::class); $user->expects(self::once())->method('setPreference')->with('theme', 'FOO'); $request = self::createRequest() ->withAttribute('theme', 'FOO') ->withAttribute('user', $user); $handler = new SelectTheme(); $response = $handler->handle($request); self::assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode()); } public function testSelectThemeForUser(): void { $user = $this->createMock(User::class); $user->expects(self::once())->method('setPreference')->with('theme', 'FOO'); $request = self::createRequest() ->withAttribute('user', $user) ->withAttribute('theme', 'FOO'); $handler = new SelectTheme(); $response = $handler->handle($request); self::assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode()); } }