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