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 */ 17fcfa147eSGreg Roach 18fd9aba47SGreg Roachdeclare(strict_types=1); 19fd9aba47SGreg Roach 20fd9aba47SGreg Roachnamespace Fisharebest\Webtrees; 21fd9aba47SGreg Roach 22e5a6b4d4SGreg Roachuse Fisharebest\Webtrees\Services\ModuleService; 231e653452SGreg Roachuse Fisharebest\Webtrees\Services\TreeService; 24e5a6b4d4SGreg Roachuse Fisharebest\Webtrees\Services\UserService; 25e5a6b4d4SGreg Roach 26fd9aba47SGreg Roach/** 27fd9aba47SGreg Roach * Test the user functions 2894caf646SGreg Roach * 2927701ab0SGreg Roach * @covers \Fisharebest\Webtrees\Statistics 30f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\BrowserRepository 31f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\ServerRepository 32f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\LatestUserRepository 33f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\FamilyDatesRepository 34f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\HitCountRepository 35f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\NewsRepository 36f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\FavoritesRepository 37f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\IndividualRepository 38f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\MediaRepository 39f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\MessageRepository 40f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\ContactRepository 41f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\GedcomRepository 42f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\FamilyRepository 43f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\EventRepository 44f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\PlaceRepository 45f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Repository\UserRepository 46f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartChildren 47f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartAge 48f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartCommonGiven 49f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartMarriageAge 50f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartCommonSurname 51f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartDistribution 52f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartFamilyLargest 53f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartNoChildrenFamilies 54f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartSex 55f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartMedia 56f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartMarriage 57f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartFamilyWithSources 58f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartMortality 59f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartDeath 60f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartIndividualWithSources 61f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartBirth 62f389d81eSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Google\ChartDivorce 63d12c87dfSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Service\CountryService 64d12c87dfSGreg Roach * @covers \Fisharebest\Webtrees\Statistics\Service\CenturyService 6594caf646SGreg Roach */ 6694caf646SGreg Roachclass EmbeddedVariablesTest extends TestCase 6794caf646SGreg Roach{ 6894caf646SGreg Roach protected static $uses_database = true; 6994caf646SGreg Roach 7094caf646SGreg Roach /** 71fd9aba47SGreg Roach * @return void 72fd9aba47SGreg Roach */ 73e5a6b4d4SGreg Roach public function testAllEmbeddedVariables(): void 74fd9aba47SGreg Roach { 75fd9aba47SGreg Roach $tree = $this->importTree('demo.ged'); 76e5a6b4d4SGreg Roach $statistics = new Statistics(new ModuleService(), $tree, new UserService()); 77e5a6b4d4SGreg Roach 78945057aeSGreg Roach // As visitor 794a520496SGreg Roach $text = $statistics->embedTags('#getAllTagsTable#'); 80945057aeSGreg Roach $this->assertNotEquals('#getAllTagsTable#', $text); 81945057aeSGreg Roach 82945057aeSGreg Roach // As member 83945057aeSGreg Roach $user = (new UserService())->create('user', 'User', 'user@example.com', 'secret'); 84*7c4add84SGreg Roach $user->setPreference(User::PREF_IS_ADMINISTRATOR, '1'); 85945057aeSGreg Roach Auth::login($user); 86e5a6b4d4SGreg Roach 8738ef8377SGreg Roach $text = $statistics->embedTags('#getAllTagsTable#'); 884a520496SGreg Roach $this->assertNotEquals('#getAllTagsTable#', $text); 89e5a6b4d4SGreg Roach } 90e5a6b4d4SGreg Roach 91e5a6b4d4SGreg Roach /** 92e5a6b4d4SGreg Roach * @return void 93e5a6b4d4SGreg Roach */ 94e5a6b4d4SGreg Roach public function testAllEmbeddedVariablesWithEmptyTree(): void 95e5a6b4d4SGreg Roach { 961e653452SGreg Roach $tree_service = new TreeService(); 971e653452SGreg Roach $tree = $tree_service->create('name', 'title'); 98e5a6b4d4SGreg Roach $statistics = new Statistics(new ModuleService(), $tree, new UserService()); 99e5a6b4d4SGreg Roach 100945057aeSGreg Roach // As visitor 1014a520496SGreg Roach $text = $statistics->embedTags('#getAllTagsTable#'); 102945057aeSGreg Roach $this->assertNotEquals('#getAllTagsTable#', $text); 103945057aeSGreg Roach 104945057aeSGreg Roach // As member 105945057aeSGreg Roach $user = (new UserService())->create('user', 'User', 'user@example.com', 'secret'); 106*7c4add84SGreg Roach $user->setPreference(User::PREF_IS_ADMINISTRATOR, '1'); 107945057aeSGreg Roach Auth::login($user); 108e5a6b4d4SGreg Roach 10938ef8377SGreg Roach $text = $statistics->embedTags('#getAllTagsTable#'); 1104a520496SGreg Roach $this->assertNotEquals('#getAllTagsTable#', $text); 111fd9aba47SGreg Roach } 112fd9aba47SGreg Roach} 113