. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\RequestMethodInterface; 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(RequestMethodInterface::METHOD_POST, [], ['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(RequestMethodInterface::METHOD_POST, [], ['theme' => 'FOO']) ->withAttribute('user', $user); $handler = new SelectTheme(); $response = $handler->handle($request); self::assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode()); } }