TYPO3 CMS  TYPO3_8-7
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 
23 class MenuTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
24 {
31  {
32  $menu = new Menu();
33  $isValid = $menu->isValid($menu);
34  $this->assertFalse($isValid);
35  }
36 
43  {
44  $menu = new Menu();
45  $menu->setIdentifier('husel');
46  $isValid = $menu->isValid($menu);
47  $this->assertTrue($isValid);
48  }
49 
55  public function makeMenuAllGoodExpectTrue()
56  {
57  $menuRegistry = new MenuRegistry();
58  $result = $menuRegistry->makeMenu()->setLabel('MenuLabel')->setIdentifier('MenuIdent');
59  $expected = new Menu();
60  $expected->setIdentifier('MenuIdent');
61  $expected->setLabel('MenuLabel');
62  $this->assertEquals($expected, $result);
63  }
64 
71  {
72  $menuRegistry = new MenuRegistry();
73 
74  $menu1 = $menuRegistry->makeMenu();
75  $menu1->setIdentifier('husel');
76  $menu1->setLabel('Label of an empty Menu');
77  $menuRegistry->addMenu($menu1);
78 
79  $menu2 = $menuRegistry->makeMenu()->setIdentifier('Foo');
80  $item = $menu2->makeMenuItem()->setHref('#')->setTitle('Husel');
81  $menu2->addMenuItem($item);
82 
83  $menuRegistry->addMenu($menu2);
84 
85  $result = $menuRegistry->getMenus();
86  $expected = [
87  'Foo' => $menu2
88  ];
89 
90  $this->assertEquals($expected, $result);
91  }
92 }