TYPO3 CMS  TYPO3_7-6
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 
20 
24 class MenuTest extends UnitTestCase
25 {
33  {
34  $menu = new Menu();
35  $isValid = $menu->isValid($menu);
36  $this->assertFalse($isValid);
37  }
38 
46  {
47  $menu = new Menu();
48  $menu->setIdentifier('husel');
49  $isValid = $menu->isValid($menu);
50  $this->assertTrue($isValid);
51  }
52 
59  public function makeMenuAllGoodExpectTrue()
60  {
61  $menuRegistry = new MenuRegistry();
62  $result = $menuRegistry->makeMenu()->setLabel('MenuLabel')->setIdentifier('MenuIdent');
63  $expected = new Menu();
64  $expected->setIdentifier('MenuIdent');
65  $expected->setLabel('MenuLabel');
66  $this->assertEquals($expected, $result);
67  }
68 
76  {
77  $menuRegistry = new MenuRegistry();
78 
79  $menu1 = $menuRegistry->makeMenu();
80  $menu1->setIdentifier('husel');
81  $menu1->setLabel('Label of an empty Menu');
82  $menuRegistry->addMenu($menu1);
83 
84  $menu2 = $menuRegistry->makeMenu()->setIdentifier('Foo');
85  $item = $menu2->makeMenuItem()->setHref('#')->setTitle('Husel');
86  $menu2->addMenuItem($item);
87 
88  $menuRegistry->addMenu($menu2);
89 
90  $result = $menuRegistry->getMenus();
91  $expected = [
92  'Foo' => $menu2
93  ];
94 
95  $this->assertEquals($expected, $result);
96  }
97 }