xref: /webtrees/tests/app/SiteTest.php (revision a34b54dc84837d4fd1e3b55dfaf41e1761acb658)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2019 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16declare(strict_types=1);
17
18namespace Fisharebest\Webtrees;
19
20use function str_repeat;
21
22/**
23 * Test the site functions
24 */
25class SiteTest extends TestCase
26{
27    protected static $uses_database = true;
28
29    /**
30     * @covers \Fisharebest\Webtrees\Site
31     *
32     * @return void
33     */
34    public function testDefault(): void
35    {
36        $this->assertSame('foo', Site::getPreference('no-such-setting', 'foo'));
37        $this->assertSame('bar', Site::getPreference('no-such-setting', 'bar'));
38    }
39
40    /**
41     * @covers \Fisharebest\Webtrees\Site
42     *
43     * @return void
44     */
45    public function testSetAndGetPreference(): void
46    {
47        Site::setPreference('setting', 'foo');
48
49        $this->assertSame('foo', Site::getPreference('setting'));
50    }
51
52    /**
53     * @covers \Fisharebest\Webtrees\Site
54     *
55     * @return void
56     */
57    public function test2000CharacterLimit(): void
58    {
59        $too_long = str_repeat('x', 3000);
60        $expected = str_repeat('x', 2000);
61
62        Site::setPreference('setting', $too_long);
63
64        $this->assertSame($expected, Site::getPreference('setting'));
65    }
66}
67