[TASK] Separate ext:statictemplates code from core
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Tests / Unit / ContentObject / Menu / MenuContentObjectFactoryTest.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Testcase
29 *
30 * @author Christian Kuhn <lolli@schwarzbu.ch
31 */
32 class MenuContentObjectFactoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
33
34 /**
35 * @test
36 * @expectedException \TYPO3\CMS\Frontend\ContentObject\Menu\Exception\NoSuchMenuTypeException
37 */
38 public function getMenuObjectByTypeThrowsExceptionForUnknownType() {
39 $factory = new \TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory;
40 $factory->getMenuObjectByType(uniqid('foo_'));
41 }
42
43 /**
44 * @test
45 */
46 public function getMenuObjectByTypeReturnsObjectForRegisteredMenuType() {
47 $factory = new \TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory;
48 $this->assertInternalType('object', $factory->getMenuObjectByType('GMENU'));
49 }
50
51 /**
52 * @test
53 */
54 public function getMenuObjectByTypeReturnsObjectWithLowercasedMenuType() {
55 $factory = new \TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory;
56 $this->assertInternalType('object', $factory->getMenuObjectByType('gmenu'));
57 }
58
59 /**
60 * @test
61 */
62 public function getMenuObjectByTypeReturnsInstanceOfOwnRegisteredTypeInsteadOfInternalType() {
63 $factory = new \TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory;
64 $selfClassName = get_class($this);
65 $factory->registerMenuType('GMENU', $selfClassName);
66 $this->assertInstanceOf($selfClassName, $factory->getMenuObjectByType('GMENU'));
67 }
68
69 /**
70 * @test
71 */
72 public function getMenuObjectByTypeReturnsInstanceOfNewRegisteredType() {
73 $factory = new \TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory;
74 $selfClassName = get_class($this);
75 $uniqueMenuType = uniqid('foo_');
76 $factory->registerMenuType($uniqueMenuType, $selfClassName);
77 $this->assertInstanceOf($selfClassName, $factory->getMenuObjectByType($uniqueMenuType));
78 }
79
80 /**
81 * @test
82 * @expectedException \InvalidArgumentException
83 */
84 public function registerMenuTypeThrowsExceptionIfTypeIsNotOfTypeString() {
85 $factory = new \TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory;
86 $factory->registerMenuType(array(), 'foo');
87 }
88
89 /**
90 * @test
91 * @expectedException \InvalidArgumentException
92 */
93 public function registerMenuTypeThrowsExceptionIfClassNameIsNotOfTypeString() {
94 $factory = new \TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory;
95 $factory->registerMenuType('foo', array());
96 }
97 }
98
99 ?>