1a25f0a04SGreg Roach<?php 2*3976b470SGreg Roach 3a25f0a04SGreg Roach/** 4a25f0a04SGreg Roach * webtrees: online genealogy 58fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team 6a25f0a04SGreg Roach * This program is free software: you can redistribute it and/or modify 7a25f0a04SGreg Roach * it under the terms of the GNU General Public License as published by 8a25f0a04SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9a25f0a04SGreg Roach * (at your option) any later version. 10a25f0a04SGreg Roach * This program is distributed in the hope that it will be useful, 11a25f0a04SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12a25f0a04SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13a25f0a04SGreg Roach * GNU General Public License for more details. 14a25f0a04SGreg Roach * You should have received a copy of the GNU General Public License 15a25f0a04SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 16a25f0a04SGreg Roach */ 17e7f56f2aSGreg Roachdeclare(strict_types=1); 18e7f56f2aSGreg Roach 1984e2cf4eSGreg Roachnamespace Fisharebest\Webtrees; 20a25f0a04SGreg Roach 21a25f0a04SGreg Roach/** 22a25f0a04SGreg Roach * Test harness for the class Menu 23a25f0a04SGreg Roach */ 24e5a6b4d4SGreg Roachclass MenuTest extends TestCase 25c1010edaSGreg Roach{ 26a25f0a04SGreg Roach /** 279b802b22SGreg Roach * @covers \Fisharebest\Webtrees\Menu::__construct 2818d7a90dSGreg Roach * 2918d7a90dSGreg Roach * @return void 30a25f0a04SGreg Roach */ 319b802b22SGreg Roach public function testConstructorDefaults(): void 32c1010edaSGreg Roach { 33a25f0a04SGreg Roach $menu = new Menu('Test!'); 34a25f0a04SGreg Roach 35a25f0a04SGreg Roach $this->assertSame('Test!', $menu->getLabel()); 36a25f0a04SGreg Roach $this->assertSame('#', $menu->getLink()); 377820e4d7SGreg Roach $this->assertSame('', $menu->getClass()); 3813abd6f3SGreg Roach $this->assertSame([], $menu->getAttrs()); 3913abd6f3SGreg Roach $this->assertSame([], $menu->getSubmenus()); 40a25f0a04SGreg Roach } 41a25f0a04SGreg Roach 42a25f0a04SGreg Roach /** 439b802b22SGreg Roach * @covers \Fisharebest\Webtrees\Menu::__construct 4418d7a90dSGreg Roach * 4518d7a90dSGreg Roach * @return void 46a25f0a04SGreg Roach */ 479b802b22SGreg Roach public function testConstructorNonDefaults(): void 48c1010edaSGreg Roach { 4913abd6f3SGreg Roach $submenus = [new Menu('Submenu')]; 5013abd6f3SGreg Roach $menu = new Menu('Test!', 'link.html', 'link-class', ['foo' => 'bar'], $submenus); 51a25f0a04SGreg Roach 52a25f0a04SGreg Roach $this->assertSame('Test!', $menu->getLabel()); 53a25f0a04SGreg Roach $this->assertSame('link.html', $menu->getLink()); 54794c6b5bSGreg Roach $this->assertSame('link-class', $menu->getClass()); 5513abd6f3SGreg Roach $this->assertSame(['foo' => 'bar'], $menu->getAttrs()); 56a25f0a04SGreg Roach $this->assertSame($submenus, $menu->getSubmenus()); 57a25f0a04SGreg Roach } 58a25f0a04SGreg Roach 59a25f0a04SGreg Roach /** 609b802b22SGreg Roach * @covers \Fisharebest\Webtrees\Menu::getLabel 619b802b22SGreg Roach * @covers \Fisharebest\Webtrees\Menu::setLabel 6218d7a90dSGreg Roach * 6318d7a90dSGreg Roach * @return void 64a25f0a04SGreg Roach */ 659b802b22SGreg Roach public function testGetterSetterLabel(): void 66c1010edaSGreg Roach { 67a25f0a04SGreg Roach $menu = new Menu('Test!'); 68a25f0a04SGreg Roach 69a25f0a04SGreg Roach $return = $menu->setLabel('Label'); 70a25f0a04SGreg Roach 71a25f0a04SGreg Roach $this->assertSame($return, $menu); 72a25f0a04SGreg Roach $this->assertSame('Label', $menu->getLabel()); 73a25f0a04SGreg Roach } 74a25f0a04SGreg Roach 75a25f0a04SGreg Roach /** 769b802b22SGreg Roach * @covers \Fisharebest\Webtrees\Menu::getLink 779b802b22SGreg Roach * @covers \Fisharebest\Webtrees\Menu::setLink 7818d7a90dSGreg Roach * 7918d7a90dSGreg Roach * @return void 80a25f0a04SGreg Roach */ 819b802b22SGreg Roach public function testGetterSetterLink(): void 82c1010edaSGreg Roach { 83a25f0a04SGreg Roach $menu = new Menu('Test!'); 84a25f0a04SGreg Roach 85a25f0a04SGreg Roach $return = $menu->setLink('link.html'); 86a25f0a04SGreg Roach 87a25f0a04SGreg Roach $this->assertSame($return, $menu); 88a25f0a04SGreg Roach $this->assertSame('link.html', $menu->getLink()); 89a25f0a04SGreg Roach } 90a25f0a04SGreg Roach 91a25f0a04SGreg Roach /** 929b802b22SGreg Roach * @covers \Fisharebest\Webtrees\Menu::getClass 939b802b22SGreg Roach * @covers \Fisharebest\Webtrees\Menu::setClass 9418d7a90dSGreg Roach * 9518d7a90dSGreg Roach * @return void 96a25f0a04SGreg Roach */ 979b802b22SGreg Roach public function testGetterSetterId(): void 98c1010edaSGreg Roach { 99a25f0a04SGreg Roach $menu = new Menu('Test!'); 100a25f0a04SGreg Roach 101794c6b5bSGreg Roach $return = $menu->setClass('link-class'); 102a25f0a04SGreg Roach 103a25f0a04SGreg Roach $this->assertSame($return, $menu); 104794c6b5bSGreg Roach $this->assertSame('link-class', $menu->getClass()); 105a25f0a04SGreg Roach } 106a25f0a04SGreg Roach 107a25f0a04SGreg Roach /** 1089b802b22SGreg Roach * @covers \Fisharebest\Webtrees\Menu::getAttrs 1099b802b22SGreg Roach * @covers \Fisharebest\Webtrees\Menu::setAttrs 11018d7a90dSGreg Roach * 11118d7a90dSGreg Roach * @return void 112a25f0a04SGreg Roach */ 1139b802b22SGreg Roach public function testGetterSetterAttrs(): void 114c1010edaSGreg Roach { 115a25f0a04SGreg Roach $menu = new Menu('Test!'); 116a25f0a04SGreg Roach 11713abd6f3SGreg Roach $return = $menu->setAttrs(['foo' => 'bar']); 118a25f0a04SGreg Roach 119a25f0a04SGreg Roach $this->assertSame($return, $menu); 12013abd6f3SGreg Roach $this->assertSame(['foo' => 'bar'], $menu->getAttrs()); 121a25f0a04SGreg Roach } 122a25f0a04SGreg Roach 123a25f0a04SGreg Roach /** 1249b802b22SGreg Roach * @covers \Fisharebest\Webtrees\Menu::getSubmenus 1259b802b22SGreg Roach * @covers \Fisharebest\Webtrees\Menu::setSubmenus 12618d7a90dSGreg Roach * 12718d7a90dSGreg Roach * @return void 128a25f0a04SGreg Roach */ 1299b802b22SGreg Roach public function testGetterSetterSubmenus(): void 130c1010edaSGreg Roach { 131a25f0a04SGreg Roach $menu = new Menu('Test!'); 13213abd6f3SGreg Roach $submenus = [ 133a25f0a04SGreg Roach new Menu('Sub1'), 134a25f0a04SGreg Roach new Menu('Sub2'), 13513abd6f3SGreg Roach ]; 136a25f0a04SGreg Roach 137a25f0a04SGreg Roach $return = $menu->setSubmenus($submenus); 138a25f0a04SGreg Roach 139a25f0a04SGreg Roach $this->assertSame($return, $menu); 140a25f0a04SGreg Roach $this->assertSame($submenus, $menu->getSubmenus()); 141a25f0a04SGreg Roach } 142a25f0a04SGreg Roach} 143