‪TYPO3CMS  10.4
MenuContentObjectFactoryTest.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 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪MenuContentObjectFactoryTest extends UnitTestCase
27 {
32  {
33  $this->expectException(NoSuchMenuTypeException::class);
34  $this->expectExceptionCode(1363278130);
35  $factory = new ‪MenuContentObjectFactory();
36  $factory->getMenuObjectByType(‪StringUtility::getUniqueId('foo_'));
37  }
38 
43  {
44  $factory = new ‪MenuContentObjectFactory();
45  self::assertIsObject($factory->getMenuObjectByType('TMENU'));
46  }
47 
52  {
53  $factory = new ‪MenuContentObjectFactory();
54  self::assertIsObject($factory->getMenuObjectByType('tmenu'));
55  }
56 
61  {
62  $factory = new ‪MenuContentObjectFactory();
63  $selfClassName = static::class;
64  $factory->registerMenuType('TMENU', $selfClassName);
65  self::assertInstanceOf($selfClassName, $factory->getMenuObjectByType('TMENU'));
66  }
67 
72  {
73  $factory = new ‪MenuContentObjectFactory();
74  $selfClassName = static::class;
75  $uniqueMenuType = ‪StringUtility::getUniqueId('foo_');
76  $factory->registerMenuType($uniqueMenuType, $selfClassName);
77  self::assertInstanceOf($selfClassName, $factory->getMenuObjectByType($uniqueMenuType));
78  }
79 
84  {
85  $this->expectException(\InvalidArgumentException::class);
86  $this->expectExceptionCode(1363429303);
87  $factory = new ‪MenuContentObjectFactory();
88  $factory->registerMenuType([], 'foo');
89  }
90 
95  {
96  $this->expectException(\InvalidArgumentException::class);
97  $this->expectExceptionCode(1363429303);
98  $factory = new ‪MenuContentObjectFactory();
99  $factory->registerMenuType('foo', []);
100  }
101 }
‪TYPO3\CMS\Frontend\ContentObject\Menu\Exception\NoSuchMenuTypeException
Definition: NoSuchMenuTypeException.php:24
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest\registerMenuTypeThrowsExceptionIfClassNameIsNotOfTypeString
‪registerMenuTypeThrowsExceptionIfClassNameIsNotOfTypeString()
Definition: MenuContentObjectFactoryTest.php:94
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest\getMenuObjectByTypeReturnsObjectWithLowercasedMenuType
‪getMenuObjectByTypeReturnsObjectWithLowercasedMenuType()
Definition: MenuContentObjectFactoryTest.php:51
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest\getMenuObjectByTypeReturnsObjectForRegisteredMenuType
‪getMenuObjectByTypeReturnsObjectForRegisteredMenuType()
Definition: MenuContentObjectFactoryTest.php:42
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest\getMenuObjectByTypeReturnsInstanceOfOwnRegisteredTypeInsteadOfInternalType
‪getMenuObjectByTypeReturnsInstanceOfOwnRegisteredTypeInsteadOfInternalType()
Definition: MenuContentObjectFactoryTest.php:60
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest
Definition: MenuContentObjectFactoryTest.php:27
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest\registerMenuTypeThrowsExceptionIfTypeIsNotOfTypeString
‪registerMenuTypeThrowsExceptionIfTypeIsNotOfTypeString()
Definition: MenuContentObjectFactoryTest.php:83
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest\getMenuObjectByTypeReturnsInstanceOfNewRegisteredType
‪getMenuObjectByTypeReturnsInstanceOfNewRegisteredType()
Definition: MenuContentObjectFactoryTest.php:71
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest\getMenuObjectByTypeThrowsExceptionForUnknownType
‪getMenuObjectByTypeThrowsExceptionForUnknownType()
Definition: MenuContentObjectFactoryTest.php:31
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static string getUniqueId($prefix='')
Definition: StringUtility.php:92
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:22
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu
Definition: AbstractMenuContentObjectTest.php:18
‪TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory
Definition: MenuContentObjectFactory.php:29