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