[FEATURE] Control visibility of modules in the BE
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Tests / Unit / View / ModuleMenuViewTest.php
1 <?php
2 namespace TYPO3\CMS\Backend\Tests\Unit\View;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Fabien Udriot <fabien.udriot@typo3.org>
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 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 /**
31 * Test for TYPO3\CMS\Backend\ModuleMenuView
32 */
33 class ModuleMenuViewTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
34
35 /**
36 * @test
37 */
38 public function unsetHiddenModulesUnsetsHiddenModules() {
39 /** @var \TYPO3\CMS\Backend\View\ModuleMenuView|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $moduleMenuViewMock */
40 $moduleMenuViewMock = $this->getAccessibleMock(
41 'TYPO3\\CMS\\Backend\\View\\ModuleMenuView',
42 array('dummy'),
43 array(),
44 '',
45 FALSE
46 );
47
48 $loadedModulesFixture = array(
49 'file' => array(),
50 'tools' => array(),
51 'web' => array(
52 'sub' => array(
53 'list' => array(),
54 'func' => array(),
55 'info' => array(),
56 ),
57 ),
58 'user' => array(
59 'sub' => array(
60 'task' => array(),
61 'settings' => array(),
62 ),
63 ),
64 );
65 $moduleMenuViewMock->_set('loadedModules', $loadedModulesFixture);
66
67 $userTsFixture = array(
68 'value' => 'file,help',
69 'properties' => array(
70 'web' => 'list,func',
71 'user' => 'task',
72 ),
73 );
74
75 $GLOBALS['BE_USER'] = $this->getMock('TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication', array(), array(), '', FALSE);
76 $GLOBALS['BE_USER']->expects($this->any())->method('getTSConfig')->will($this->returnValue($userTsFixture));
77
78 $expectedResult = array(
79 'tools' => array(),
80 'web' => array(
81 'sub' => array(
82 'info' => array(),
83 ),
84 ),
85 'user' => array(
86 'sub' => array(
87 'settings' => array(),
88 ),
89 ),
90 );
91
92 $moduleMenuViewMock->_call('unsetHiddenModules');
93 $actualResult = $moduleMenuViewMock->_get('loadedModules');
94 $this->assertSame($expectedResult, $actualResult);
95 }
96 }