TYPO3 CMS  TYPO3_8-7
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 
23 class MenuContentObjectFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
24 {
29  {
30  $this->expectException(NoSuchMenuTypeException::class);
31  $this->expectExceptionCode(1363278130);
32  $factory = new MenuContentObjectFactory;
33  $factory->getMenuObjectByType($this->getUniqueId('foo_'));
34  }
35 
40  {
41  $factory = new MenuContentObjectFactory;
42  $this->assertInternalType('object', $factory->getMenuObjectByType('GMENU'));
43  }
44 
49  {
50  $factory = new MenuContentObjectFactory;
51  $this->assertInternalType('object', $factory->getMenuObjectByType('gmenu'));
52  }
53 
58  {
59  $factory = new MenuContentObjectFactory;
60  $selfClassName = get_class($this);
61  $factory->registerMenuType('GMENU', $selfClassName);
62  $this->assertInstanceOf($selfClassName, $factory->getMenuObjectByType('GMENU'));
63  }
64 
69  {
70  $factory = new MenuContentObjectFactory;
71  $selfClassName = get_class($this);
72  $uniqueMenuType = $this->getUniqueId('foo_');
73  $factory->registerMenuType($uniqueMenuType, $selfClassName);
74  $this->assertInstanceOf($selfClassName, $factory->getMenuObjectByType($uniqueMenuType));
75  }
76 
81  {
82  $this->expectException(\InvalidArgumentException::class);
83  $this->expectExceptionCode(1363429303);
84  $factory = new MenuContentObjectFactory;
85  $factory->registerMenuType([], 'foo');
86  }
87 
92  {
93  $this->expectException(\InvalidArgumentException::class);
94  $this->expectExceptionCode(1363429303);
95  $factory = new MenuContentObjectFactory;
96  $factory->registerMenuType('foo', []);
97  }
98 }