. */ declare(strict_types=1); namespace Fisharebest\Webtrees; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(Menu::class)] class MenuTest extends TestCase { public function testConstructorDefaults(): void { $menu = new Menu('Test!'); self::assertSame('Test!', $menu->getLabel()); self::assertSame('#', $menu->getLink()); self::assertSame('', $menu->getClass()); self::assertSame([], $menu->getAttrs()); self::assertSame([], $menu->getSubmenus()); } public function testConstructorNonDefaults(): void { $submenus = [new Menu('Submenu')]; $menu = new Menu('Test!', 'link.html', 'link-class', ['foo' => 'bar'], $submenus); self::assertSame('Test!', $menu->getLabel()); self::assertSame('link.html', $menu->getLink()); self::assertSame('link-class', $menu->getClass()); self::assertSame(['foo' => 'bar'], $menu->getAttrs()); self::assertSame($submenus, $menu->getSubmenus()); } public function testGetterSetterLabel(): void { $menu = new Menu('Test!'); $return = $menu->setLabel('Label'); self::assertSame($return, $menu); self::assertSame('Label', $menu->getLabel()); } public function testGetterSetterLink(): void { $menu = new Menu('Test!'); $return = $menu->setLink('link.html'); self::assertSame($return, $menu); self::assertSame('link.html', $menu->getLink()); } public function testGetterSetterId(): void { $menu = new Menu('Test!'); $return = $menu->setClass('link-class'); self::assertSame($return, $menu); self::assertSame('link-class', $menu->getClass()); } public function testGetterSetterAttrs(): void { $menu = new Menu('Test!'); $return = $menu->setAttrs(['foo' => 'bar']); self::assertSame($return, $menu); self::assertSame(['foo' => 'bar'], $menu->getAttrs()); } public function testGetterSetterSubmenus(): void { $menu = new Menu('Test!'); $submenus = [ new Menu('Sub1'), new Menu('Sub2'), ]; $return = $menu->setSubmenus($submenus); self::assertSame($return, $menu); self::assertSame($submenus, $menu->getSubmenus()); } }