‪TYPO3CMS  9.5
MenuContentObjectFactoryTest.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 ‪MenuContentObjectFactoryTest extends UnitTestCase
25 {
30  {
31  $this->expectException(NoSuchMenuTypeException::class);
32  $this->expectExceptionCode(1363278130);
33  $factory = new ‪MenuContentObjectFactory;
34  $factory->‪getMenuObjectByType($this->getUniqueId('foo_'));
35  }
36 
41  {
42  $factory = new ‪MenuContentObjectFactory;
43  $this->assertInternalType('object', $factory->getMenuObjectByType('TMENU'));
44  }
45 
50  {
51  $factory = new ‪MenuContentObjectFactory;
52  $this->assertInternalType('object', $factory->getMenuObjectByType('tmenu'));
53  }
54 
59  {
60  $factory = new ‪MenuContentObjectFactory;
61  $selfClassName = static::class;
62  $factory->‪registerMenuType('TMENU', $selfClassName);
63  $this->assertInstanceOf($selfClassName, $factory->getMenuObjectByType('TMENU'));
64  }
65 
70  {
71  $factory = new ‪MenuContentObjectFactory;
72  $selfClassName = static::class;
73  $uniqueMenuType = $this->getUniqueId('foo_');
74  $factory->registerMenuType($uniqueMenuType, $selfClassName);
75  $this->assertInstanceOf($selfClassName, $factory->getMenuObjectByType($uniqueMenuType));
76  }
77 
82  {
83  $this->expectException(\InvalidArgumentException::class);
84  $this->expectExceptionCode(1363429303);
85  $factory = new ‪MenuContentObjectFactory;
86  $factory->‪registerMenuType([], 'foo');
87  }
88 
93  {
94  $this->expectException(\InvalidArgumentException::class);
95  $this->expectExceptionCode(1363429303);
96  $factory = new ‪MenuContentObjectFactory;
97  $factory->‪registerMenuType('foo', []);
98  }
99 }
‪TYPO3\CMS\Frontend\ContentObject\Menu\Exception\NoSuchMenuTypeException
Definition: NoSuchMenuTypeException.php:21
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest\registerMenuTypeThrowsExceptionIfClassNameIsNotOfTypeString
‪registerMenuTypeThrowsExceptionIfClassNameIsNotOfTypeString()
Definition: MenuContentObjectFactoryTest.php:92
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest\getMenuObjectByTypeReturnsObjectWithLowercasedMenuType
‪getMenuObjectByTypeReturnsObjectWithLowercasedMenuType()
Definition: MenuContentObjectFactoryTest.php:49
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest\getMenuObjectByTypeReturnsObjectForRegisteredMenuType
‪getMenuObjectByTypeReturnsObjectForRegisteredMenuType()
Definition: MenuContentObjectFactoryTest.php:40
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest\getMenuObjectByTypeReturnsInstanceOfOwnRegisteredTypeInsteadOfInternalType
‪getMenuObjectByTypeReturnsInstanceOfOwnRegisteredTypeInsteadOfInternalType()
Definition: MenuContentObjectFactoryTest.php:58
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest
Definition: MenuContentObjectFactoryTest.php:25
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest\registerMenuTypeThrowsExceptionIfTypeIsNotOfTypeString
‪registerMenuTypeThrowsExceptionIfTypeIsNotOfTypeString()
Definition: MenuContentObjectFactoryTest.php:81
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest\getMenuObjectByTypeReturnsInstanceOfNewRegisteredType
‪getMenuObjectByTypeReturnsInstanceOfNewRegisteredType()
Definition: MenuContentObjectFactoryTest.php:69
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu\MenuContentObjectFactoryTest\getMenuObjectByTypeThrowsExceptionForUnknownType
‪getMenuObjectByTypeThrowsExceptionForUnknownType()
Definition: MenuContentObjectFactoryTest.php:29
‪TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory\getMenuObjectByType
‪AbstractMenuContentObject getMenuObjectByType($type='')
Definition: MenuContentObjectFactory.php:45
‪TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory\registerMenuType
‪registerMenuType($type, $className)
Definition: MenuContentObjectFactory.php:66
‪TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu
Definition: AbstractMenuContentObjectTest.php:3
‪TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory
Definition: MenuContentObjectFactory.php:27