xref: /webtrees/tests/app/NoReplyUserTest.php (revision 5a8afed46297e8105e3e5a33ce37e6a8e88bc79d)
14c9729fbSGreg Roach<?php
23976b470SGreg Roach
34c9729fbSGreg Roach/**
44c9729fbSGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
64c9729fbSGreg Roach * This program is free software: you can redistribute it and/or modify
74c9729fbSGreg Roach * it under the terms of the GNU General Public License as published by
84c9729fbSGreg Roach * the Free Software Foundation, either version 3 of the License, or
94c9729fbSGreg Roach * (at your option) any later version.
104c9729fbSGreg Roach * This program is distributed in the hope that it will be useful,
114c9729fbSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
124c9729fbSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
134c9729fbSGreg Roach * GNU General Public License for more details.
144c9729fbSGreg 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/>.
164c9729fbSGreg Roach */
17fcfa147eSGreg Roach
184c9729fbSGreg Roachdeclare(strict_types=1);
194c9729fbSGreg Roach
204c9729fbSGreg Roachnamespace Fisharebest\Webtrees;
214c9729fbSGreg Roach
224c9729fbSGreg Roachuse Fisharebest\Webtrees\Contracts\UserInterface;
23*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass;
244c9729fbSGreg Roach
25*202c018bSGreg Roach#[CoversClass(NoReplyUser::class)]
264c9729fbSGreg Roachclass NoReplyUserTest extends TestCase
274c9729fbSGreg Roach{
28cd94ca66SGreg Roach    protected static bool $uses_database = true;
294c9729fbSGreg Roach
304c9729fbSGreg Roach    public function testConstructor(): void
314c9729fbSGreg Roach    {
324c9729fbSGreg Roach        $user = new NoReplyUser();
334c9729fbSGreg Roach
345e933c21SGreg Roach        self::assertInstanceOf(UserInterface::class, $user);
355e933c21SGreg Roach        self::assertSame(0, $user->id());
365e933c21SGreg Roach        self::assertSame('no-reply@localhost', $user->email());
375e933c21SGreg Roach        self::assertSame(Webtrees::NAME, $user->realName());
385e933c21SGreg Roach        self::assertSame('', $user->userName());
394c9729fbSGreg Roach    }
404c9729fbSGreg Roach
414c9729fbSGreg Roach    public function testPreferences(): void
424c9729fbSGreg Roach    {
434c9729fbSGreg Roach        $user = new NoReplyUser();
444c9729fbSGreg Roach
455e933c21SGreg Roach        self::assertSame('', $user->getPreference('foo'));
465e933c21SGreg Roach        self::assertSame('', $user->getPreference('foo'));
475e933c21SGreg Roach        self::assertSame('bar', $user->getPreference('foo', 'bar'));
484c9729fbSGreg Roach
494c9729fbSGreg Roach        // No reply users do not have preferences
504c9729fbSGreg Roach        $user->setPreference('foo', 'bar');
514c9729fbSGreg Roach
525e933c21SGreg Roach        self::assertSame('', $user->getPreference('foo'));
534c9729fbSGreg Roach    }
544c9729fbSGreg Roach}
55