. */ declare(strict_types=1); namespace Fisharebest\Webtrees; use Fisharebest\Webtrees\Contracts\UserInterface; /** * Test the SiteUser class */ class SiteUserTest extends TestCase { protected static bool $uses_database = true; /** * @covers \Fisharebest\Webtrees\SiteUser::id * @covers \Fisharebest\Webtrees\SiteUser::email * @covers \Fisharebest\Webtrees\SiteUser::realName * @covers \Fisharebest\Webtrees\SiteUser::userName */ public function testConstructor(): void { $user = new SiteUser(); Site::setPreference('SMTP_FROM_NAME', 'email@example.com'); Site::setPreference('SMTP_DISP_NAME', 'My site'); self::assertInstanceOf(UserInterface::class, $user); self::assertSame(0, $user->id()); self::assertSame('email@example.com', $user->email()); self::assertSame('My site', $user->realName()); self::assertSame('', $user->userName()); } /** * @covers \Fisharebest\Webtrees\SiteUser::getPreference * @covers \Fisharebest\Webtrees\SiteUser::setPreference */ 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')); } }