. */ declare(strict_types=1); namespace Fisharebest\Webtrees; use Fisharebest\Webtrees\Contracts\UserInterface; /** * Test the SiteUser class */ class SiteUserTest extends TestCase { protected static $uses_database = true; /** * @covers \Fisharebest\Webtrees\SiteUser::id * @covers \Fisharebest\Webtrees\SiteUser::email * @covers \Fisharebest\Webtrees\SiteUser::realName * @covers \Fisharebest\Webtrees\SiteUser::userName * @return void */ public function testConstructor(): void { $user = new SiteUser(); self::assertInstanceOf(UserInterface::class, $user); self::assertSame(0, $user->id()); self::assertSame('', $user->email()); self::assertSame('webtrees', $user->realName()); self::assertSame('', $user->userName()); } /** * @covers \Fisharebest\Webtrees\SiteUser::getPreference * @covers \Fisharebest\Webtrees\SiteUser::setPreference * @return void */ public function testPreferences(): void { $user = new SiteUser(); self::assertSame('', $user->getPreference('foo')); self::assertSame('', $user->getPreference('foo')); self::assertSame('bar', $user->getPreference('foo', 'bar')); // Site users do not have preferences $user->setPreference('foo', 'bar'); self::assertSame('', $user->getPreference('foo')); } }