xref: /webtrees/tests/feature/EmbeddedVariablesTest.php (revision fcfa147e10aaa6c7ff580c29bd6e5b88666befc1)
1fd9aba47SGreg Roach<?php
23976b470SGreg Roach
3fd9aba47SGreg Roach/**
4fd9aba47SGreg Roach * webtrees: online genealogy
5fd9aba47SGreg Roach * Copyright (C) 2019 webtrees development team
6fd9aba47SGreg Roach * This program is free software: you can redistribute it and/or modify
7fd9aba47SGreg Roach * it under the terms of the GNU General Public License as published by
8fd9aba47SGreg Roach * the Free Software Foundation, either version 3 of the License, or
9fd9aba47SGreg Roach * (at your option) any later version.
10fd9aba47SGreg Roach * This program is distributed in the hope that it will be useful,
11fd9aba47SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12fd9aba47SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13fd9aba47SGreg Roach * GNU General Public License for more details.
14fd9aba47SGreg Roach * You should have received a copy of the GNU General Public License
15fd9aba47SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
16fd9aba47SGreg Roach */
17*fcfa147eSGreg Roach
18fd9aba47SGreg Roachdeclare(strict_types=1);
19fd9aba47SGreg Roach
20fd9aba47SGreg Roachnamespace Fisharebest\Webtrees;
21fd9aba47SGreg Roach
22e5a6b4d4SGreg Roachuse Fisharebest\Webtrees\Services\ModuleService;
23e5a6b4d4SGreg Roachuse Fisharebest\Webtrees\Services\UserService;
24e5a6b4d4SGreg Roach
25fd9aba47SGreg Roach/**
26fd9aba47SGreg Roach * Test the user functions
2794caf646SGreg Roach *
2827701ab0SGreg Roach * @covers \Fisharebest\Webtrees\Statistics
29f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\BrowserRepository
30f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\ServerRepository
31f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\LatestUserRepository
32f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\FamilyDatesRepository
33f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\HitCountRepository
34f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\NewsRepository
35f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\FavoritesRepository
36f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\IndividualRepository
37f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\MediaRepository
38f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\MessageRepository
39f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\ContactRepository
40f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\GedcomRepository
41f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\FamilyRepository
42f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\EventRepository
43f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\PlaceRepository
44f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\UserRepository
45f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartChildren
46f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartAge
47f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartCommonGiven
48f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartMarriageAge
49f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartCommonSurname
50f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartDistribution
51f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartFamilyLargest
52f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartNoChildrenFamilies
53f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartSex
54f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartMedia
55f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartMarriage
56f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartFamilyWithSources
57f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartMortality
58f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartDeath
59f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartIndividualWithSources
60f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartBirth
61f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartDivorce
62d12c87dfSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Service\CountryService
63d12c87dfSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Service\CenturyService
6494caf646SGreg Roach */
6594caf646SGreg Roachclass EmbeddedVariablesTest extends TestCase
6694caf646SGreg Roach{
6794caf646SGreg Roach    protected static $uses_database = true;
6894caf646SGreg Roach
6994caf646SGreg Roach    /**
70fd9aba47SGreg Roach     * @return void
71fd9aba47SGreg Roach     */
72e5a6b4d4SGreg Roach    public function testAllEmbeddedVariables(): void
73fd9aba47SGreg Roach    {
74fd9aba47SGreg Roach        $tree       = $this->importTree('demo.ged');
75e5a6b4d4SGreg Roach        $statistics = new Statistics(new ModuleService(), $tree, new UserService());
76e5a6b4d4SGreg Roach
77c5e5c1ceSGreg Roach        // For Date::display()
78c5e5c1ceSGreg Roach        app()->instance(Tree::class, $tree);
79c5e5c1ceSGreg Roach
80945057aeSGreg Roach        // As visitor
814a520496SGreg Roach        $text = $statistics->embedTags('#getAllTagsTable#');
82945057aeSGreg Roach        $this->assertNotEquals('#getAllTagsTable#', $text);
83945057aeSGreg Roach
84945057aeSGreg Roach        // As member
85945057aeSGreg Roach        $user = (new UserService())->create('user', 'User', 'user@example.com', 'secret');
86945057aeSGreg Roach        $user->setPreference('canadmin', '1');
87945057aeSGreg Roach        Auth::login($user);
88e5a6b4d4SGreg Roach
8938ef8377SGreg Roach        $text = $statistics->embedTags('#getAllTagsTable#');
904a520496SGreg Roach        $this->assertNotEquals('#getAllTagsTable#', $text);
91e5a6b4d4SGreg Roach    }
92e5a6b4d4SGreg Roach
93e5a6b4d4SGreg Roach    /**
94e5a6b4d4SGreg Roach     * @return void
95e5a6b4d4SGreg Roach     */
96e5a6b4d4SGreg Roach    public function testAllEmbeddedVariablesWithEmptyTree(): void
97e5a6b4d4SGreg Roach    {
98e5a6b4d4SGreg Roach        $tree       = Tree::create('name', 'title');
99e5a6b4d4SGreg Roach        $statistics = new Statistics(new ModuleService(), $tree, new UserService());
100e5a6b4d4SGreg Roach
101c5e5c1ceSGreg Roach        // For Date::display()
102c5e5c1ceSGreg Roach        app()->instance(Tree::class, $tree);
103c5e5c1ceSGreg Roach
104945057aeSGreg Roach        // As visitor
1054a520496SGreg Roach        $text = $statistics->embedTags('#getAllTagsTable#');
106945057aeSGreg Roach        $this->assertNotEquals('#getAllTagsTable#', $text);
107945057aeSGreg Roach
108945057aeSGreg Roach        // As member
109945057aeSGreg Roach        $user = (new UserService())->create('user', 'User', 'user@example.com', 'secret');
110945057aeSGreg Roach        $user->setPreference('canadmin', '1');
111945057aeSGreg Roach        Auth::login($user);
112e5a6b4d4SGreg Roach
11338ef8377SGreg Roach        $text = $statistics->embedTags('#getAllTagsTable#');
1144a520496SGreg Roach        $this->assertNotEquals('#getAllTagsTable#', $text);
115fd9aba47SGreg Roach    }
116fd9aba47SGreg Roach}
117