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