‪TYPO3CMS  10.4
MenuTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
21 
25 class ‪MenuTest extends UnitTestCase
26 {
33  {
34  $menu = new ‪Menu();
35  $isValid = $menu->isValid($menu);
36  self::assertFalse($isValid);
37  }
38 
45  {
46  $menu = new ‪Menu();
47  $menu->setIdentifier('husel');
48  $isValid = $menu->isValid($menu);
49  self::assertTrue($isValid);
50  }
51 
57  public function ‪makeMenuAllGoodExpectTrue()
58  {
59  $menuRegistry = new ‪MenuRegistry();
60  $result = $menuRegistry->makeMenu()->setLabel('MenuLabel')->setIdentifier('MenuIdent');
61  $expected = new ‪Menu();
62  $expected->setIdentifier('MenuIdent');
63  $expected->setLabel('MenuLabel');
64  self::assertEquals($expected, $result);
65  }
66 
73  {
74  $menuRegistry = new ‪MenuRegistry();
75 
76  $menu1 = $menuRegistry->makeMenu();
77  $menu1->setIdentifier('husel');
78  $menu1->setLabel('Label of an empty Menu');
79  $menuRegistry->addMenu($menu1);
80 
81  $menu2 = $menuRegistry->makeMenu()->setIdentifier('Foo');
82  $item = $menu2->makeMenuItem()->setHref('#')->setTitle('Husel');
83  $menu2->addMenuItem($item);
84 
85  $menuRegistry->addMenu($menu2);
86 
87  $result = $menuRegistry->getMenus();
88  $expected = [
89  'Foo' => $menu2
90  ];
91 
92  self::assertEquals($expected, $result);
93  }
94 }
‪TYPO3\CMS\Backend\Tests\Unit\Template\Components\MenuTest\makeMenuAllGoodExpectTrue
‪makeMenuAllGoodExpectTrue()
Definition: MenuTest.php:57
‪TYPO3\CMS\Backend\Tests\Unit\Template\Components\MenuTest
Definition: MenuTest.php:26
‪TYPO3\CMS\Backend\Template\Components\MenuRegistry
Definition: MenuRegistry.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Template\Components\MenuTest\isMenuValidBlankCallExpectFalse
‪isMenuValidBlankCallExpectFalse()
Definition: MenuTest.php:32
‪TYPO3\CMS\Backend\Tests\Unit\Template\Components\MenuTest\isMenuValidValidMenuWithDefaultsExpectTrue
‪isMenuValidValidMenuWithDefaultsExpectTrue()
Definition: MenuTest.php:44
‪TYPO3\CMS\Backend\Template\Components\Menu\Menu
Definition: Menu.php:24
‪TYPO3\CMS\Backend\Tests\Unit\Template\Components\MenuTest\getMenusRemovedEmptyMenusExpectsEquals
‪getMenusRemovedEmptyMenusExpectsEquals()
Definition: MenuTest.php:72
‪TYPO3\CMS\Backend\Tests\Unit\Template\Components