. */ 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 { /** * @return void */ public function testSelectThemeForGuest(): void { $user = $this->createMock(GuestUser::class); $user->expects($this->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()); } /** * @return void */ public function testSelectThemeForUser(): void { $user = $this->createMock(User::class); $user->expects($this->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()); } }