diff options
| author | Greg Roach <fisharebest@webtrees.net> | 2019-02-05 22:22:51 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@webtrees.net> | 2019-02-05 22:22:51 +0000 |
| commit | 2ab46aafe73c31ca78c52d01d7ffa67256a575b2 (patch) | |
| tree | b026dbc212abb2e2b6143383db19931e9f2825c2 /tests/app | |
| parent | 2fac69ae59ac8400c2f346f4ab416caaf7635521 (diff) | |
| download | webtrees-2ab46aafe73c31ca78c52d01d7ffa67256a575b2.tar.gz webtrees-2ab46aafe73c31ca78c52d01d7ffa67256a575b2.tar.bz2 webtrees-2ab46aafe73c31ca78c52d01d7ffa67256a575b2.zip | |
Tests
Diffstat (limited to 'tests/app')
| -rw-r--r-- | tests/app/SiteUserTest.php | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/app/SiteUserTest.php b/tests/app/SiteUserTest.php new file mode 100644 index 0000000000..499bf698ee --- /dev/null +++ b/tests/app/SiteUserTest.php @@ -0,0 +1,69 @@ +<?php +/** + * webtrees: online genealogy + * Copyright (C) 2019 webtrees development team + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ +declare(strict_types=1); + +namespace Fisharebest\Webtrees; + +use Fisharebest\Webtrees\Contracts\UserInterface; + +/** + * Test the SiteUser class + */ +class SiteUserTest extends TestCase +{ + protected static $uses_database = true; + + /** + * @covers \Fisharebest\Webtrees\SiteUser::__construct + * @covers \Fisharebest\Webtrees\SiteUser::id + * @covers \Fisharebest\Webtrees\SiteUser::email + * @covers \Fisharebest\Webtrees\SiteUser::realName + * @covers \Fisharebest\Webtrees\SiteUser::userName + * @return void + */ + public function testConstructor(): void + { + $user = new SiteUser(); + + $this->assertInstanceOf(UserInterface::class, $user); + $this->assertSame(0, $user->id()); + $this->assertSame('no-reply@localhost', $user->email()); + $this->assertSame('webtrees', $user->realName()); + $this->assertSame('', $user->userName()); + + Site::setPreference('SMTP_FROM_NAME', 'foo@example.com'); + $this->assertSame('foo@example.com', $user->email()); + } + + /** + * @covers \Fisharebest\Webtrees\SiteUser::getPreference + * @covers \Fisharebest\Webtrees\SiteUser::setPreference + * @return void + */ + public function testPreferences(): void + { + $user = new SiteUser(); + + $this->assertSame('', $user->getPreference('foo')); + $this->assertSame('', $user->getPreference('foo', '')); + $this->assertSame('bar', $user->getPreference('foo', 'bar')); + + // Site users do not have preferences + $user->setPreference('foo', 'bar'); + + $this->assertSame('', $user->getPreference('foo')); + } +} |
