. */ declare(strict_types=1); use Fisharebest\Webtrees\GuestUser; use Fisharebest\Webtrees\Http\RequestHandlers\SelectTheme; use Fisharebest\Webtrees\Services\UserService; use Fisharebest\Webtrees\TestCase; /** * @covers \Fisharebest\Webtrees\Http\RequestHandlers\SelectTheme */ class SelectThemeTest extends TestCase { protected static $uses_database = true; /** * @return void */ public function testSelectThemeForGuest(): void { $user = new GuestUser(); $handler = new SelectTheme($user); $request = self::createRequest('POST', ['route' => 'theme'], ['theme' => 'FOO']); $response = $handler->handle($request); self::assertSame(self::STATUS_NO_CONTENT, $response->getStatusCode()); self::assertSame('FOO', $user->getPreference('theme')); } /** * @return void */ public function testSelectThemeForUser(): void { $user_service = new UserService(); $user = $user_service->create('user', 'real', 'email', 'pass'); $handler = new SelectTheme($user); $request = self::createRequest('POST', ['route' => 'theme'], ['theme' => 'FOO']); $response = $handler->handle($request); self::assertSame(self::STATUS_NO_CONTENT, $response->getStatusCode()); self::assertSame('FOO', $user->getPreference('theme')); } }