. */ declare(strict_types=1); namespace Fisharebest\Webtrees; use Fisharebest\Webtrees\Contracts\UserInterface; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(SiteUser::class)] class SiteUserTest extends TestCase { protected static bool $uses_database = true; 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()); } 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')); } }