. */ declare(strict_types=1); namespace Fisharebest\Webtrees; use Fisharebest\Webtrees\Contracts\UserInterface; use Fisharebest\Webtrees\Services\GedcomImportService; use Fisharebest\Webtrees\Services\TreeService; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(TreeUser::class)] class TreeUserTest extends TestCase { protected static bool $uses_database = true; public function testConstructor(): void { $gedcom_import_service = new GedcomImportService(); $tree_service = new TreeService($gedcom_import_service); $tree = $tree_service->create('name', 'title'); $user = new TreeUser($tree); self::assertInstanceOf(UserInterface::class, $user); self::assertSame(0, $user->id()); self::assertSame('', $user->email()); self::assertSame('title', $user->realName()); self::assertSame('', $user->userName()); } public function testPreferences(): void { $gedcom_import_service = new GedcomImportService(); $tree_service = new TreeService($gedcom_import_service); $tree = $tree_service->create('name', 'title'); $user = new TreeUser($tree); self::assertSame('', $user->getPreference('foo')); self::assertSame('', $user->getPreference('foo')); self::assertSame('bar', $user->getPreference('foo', 'bar')); // Tree users do not have preferences $user->setPreference('foo', 'bar'); self::assertSame('', $user->getPreference('foo')); } }