12ab46aafSGreg Roach<?php 23976b470SGreg Roach 32ab46aafSGreg Roach/** 42ab46aafSGreg Roach * webtrees: online genealogy 5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 62ab46aafSGreg Roach * This program is free software: you can redistribute it and/or modify 72ab46aafSGreg Roach * it under the terms of the GNU General Public License as published by 82ab46aafSGreg Roach * the Free Software Foundation, either version 3 of the License, or 92ab46aafSGreg Roach * (at your option) any later version. 102ab46aafSGreg Roach * This program is distributed in the hope that it will be useful, 112ab46aafSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 122ab46aafSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 132ab46aafSGreg Roach * GNU General Public License for more details. 142ab46aafSGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 162ab46aafSGreg Roach */ 17fcfa147eSGreg Roach 182ab46aafSGreg Roachdeclare(strict_types=1); 192ab46aafSGreg Roach 202ab46aafSGreg Roachnamespace Fisharebest\Webtrees; 212ab46aafSGreg Roach 222ab46aafSGreg Roachuse Fisharebest\Webtrees\Contracts\UserInterface; 232ab46aafSGreg Roach 242ab46aafSGreg Roach/** 252ab46aafSGreg Roach * Test the SiteUser class 262ab46aafSGreg Roach */ 272ab46aafSGreg Roachclass SiteUserTest extends TestCase 282ab46aafSGreg Roach{ 29cd94ca66SGreg Roach protected static bool $uses_database = true; 302ab46aafSGreg Roach 312ab46aafSGreg Roach /** 322ab46aafSGreg Roach * @covers \Fisharebest\Webtrees\SiteUser::id 332ab46aafSGreg Roach * @covers \Fisharebest\Webtrees\SiteUser::email 342ab46aafSGreg Roach * @covers \Fisharebest\Webtrees\SiteUser::realName 352ab46aafSGreg Roach * @covers \Fisharebest\Webtrees\SiteUser::userName 362ab46aafSGreg Roach * @return void 372ab46aafSGreg Roach */ 382ab46aafSGreg Roach public function testConstructor(): void 392ab46aafSGreg Roach { 402ab46aafSGreg Roach $user = new SiteUser(); 41cdf1da30SGreg Roach Site::setPreference('SMTP_FROM_NAME', 'email@example.com'); 42cdf1da30SGreg Roach Site::setPreference('SMTP_DISP_NAME', 'My site'); 432ab46aafSGreg Roach 445e933c21SGreg Roach self::assertInstanceOf(UserInterface::class, $user); 455e933c21SGreg Roach self::assertSame(0, $user->id()); 46cdf1da30SGreg Roach self::assertSame('email@example.com', $user->email()); 47cdf1da30SGreg Roach self::assertSame('My site', $user->realName()); 485e933c21SGreg Roach self::assertSame('', $user->userName()); 492ab46aafSGreg Roach } 502ab46aafSGreg Roach 512ab46aafSGreg Roach /** 522ab46aafSGreg Roach * @covers \Fisharebest\Webtrees\SiteUser::getPreference 532ab46aafSGreg Roach * @covers \Fisharebest\Webtrees\SiteUser::setPreference 542ab46aafSGreg Roach * @return void 552ab46aafSGreg Roach */ 562ab46aafSGreg Roach public function testPreferences(): void 572ab46aafSGreg Roach { 582ab46aafSGreg Roach $user = new SiteUser(); 592ab46aafSGreg Roach 605e933c21SGreg Roach self::assertSame('', $user->getPreference('foo')); 615e933c21SGreg Roach self::assertSame('', $user->getPreference('foo')); 625e933c21SGreg Roach self::assertSame('bar', $user->getPreference('foo', 'bar')); 632ab46aafSGreg Roach 642ab46aafSGreg Roach // Site users do not have preferences 652ab46aafSGreg Roach $user->setPreference('foo', 'bar'); 662ab46aafSGreg Roach 675e933c21SGreg Roach self::assertSame('', $user->getPreference('foo')); 682ab46aafSGreg Roach } 692ab46aafSGreg Roach} 70