xref: /webtrees/tests/app/SiteUserTest.php (revision fcfa147e10aaa6c7ff580c29bd6e5b88666befc1)
12ab46aafSGreg Roach<?php
23976b470SGreg Roach
32ab46aafSGreg Roach/**
42ab46aafSGreg Roach * webtrees: online genealogy
52ab46aafSGreg Roach * Copyright (C) 2019 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
152ab46aafSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
162ab46aafSGreg Roach */
17*fcfa147eSGreg 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{
292ab46aafSGreg Roach    protected static $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();
412ab46aafSGreg Roach
422ab46aafSGreg Roach        $this->assertInstanceOf(UserInterface::class, $user);
432ab46aafSGreg Roach        $this->assertSame(0, $user->id());
44502cab90SGreg Roach        $this->assertSame('', $user->email());
452ab46aafSGreg Roach        $this->assertSame('webtrees', $user->realName());
462ab46aafSGreg Roach        $this->assertSame('', $user->userName());
472ab46aafSGreg Roach    }
482ab46aafSGreg Roach
492ab46aafSGreg Roach    /**
502ab46aafSGreg Roach     * @covers \Fisharebest\Webtrees\SiteUser::getPreference
512ab46aafSGreg Roach     * @covers \Fisharebest\Webtrees\SiteUser::setPreference
522ab46aafSGreg Roach     * @return void
532ab46aafSGreg Roach     */
542ab46aafSGreg Roach    public function testPreferences(): void
552ab46aafSGreg Roach    {
562ab46aafSGreg Roach        $user = new SiteUser();
572ab46aafSGreg Roach
582ab46aafSGreg Roach        $this->assertSame('', $user->getPreference('foo'));
592ab46aafSGreg Roach        $this->assertSame('', $user->getPreference('foo', ''));
602ab46aafSGreg Roach        $this->assertSame('bar', $user->getPreference('foo', 'bar'));
612ab46aafSGreg Roach
622ab46aafSGreg Roach        // Site users do not have preferences
632ab46aafSGreg Roach        $user->setPreference('foo', 'bar');
642ab46aafSGreg Roach
652ab46aafSGreg Roach        $this->assertSame('', $user->getPreference('foo'));
662ab46aafSGreg Roach    }
672ab46aafSGreg Roach}
68