[TASK] Move unit test to logical places
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tests / tslib / class.tslib_adminpanelTest.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2011 Christian Kuhn <lolli@schwarzbu.ch>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 /**
26 * Testcase for the "tslib_AdminPanel" class in the TYPO3 Core.
27 *
28 * @package TYPO3
29 * @subpackage tslib
30 * @author Christian Kuhn <lolli@schwarzbu.ch>
31 */
32 class tslib_AdminPanelTest extends tx_phpunit_testcase {
33
34 /**
35 * Enable backup of global and system variables
36 *
37 * @var boolean
38 */
39 protected $backupGlobals = TRUE;
40
41 /**
42 * Exclude TYPO3_DB from backup/ restore of $GLOBALS
43 * because resource types cannot be handled during serializing
44 *
45 * @var array
46 */
47 protected $backupGlobalsBlacklist = array('TYPO3_DB');
48
49 /////////////////////////////////////////////
50 // Test concerning extendAdminPanel hook
51 /////////////////////////////////////////////
52
53 /**
54 * @test
55 * @expectedException UnexpectedValueException
56 */
57 public function extendAdminPanelHookThrowsExceptionIfHookClassDoesNotImplementInterface() {
58 $hookClass = uniqid('tx_coretest');
59 eval('class ' . $hookClass . ' {}');
60
61 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'][] = $hookClass;
62
63 $adminPanelMock = $this->getMock('tslib_AdminPanel', array('dummy'), array(), '', FALSE);
64 $adminPanelMock->display();
65 }
66
67 /**
68 * @test
69 */
70 public function extendAdminPanelHookCallsExtendAdminPanelMethodOfHook() {
71 $hookClass = uniqid('tx_coretest');
72 $hookMock = $this->getMock(
73 'tslib_adminPanelHook',
74 array(),
75 array(),
76 $hookClass
77 );
78 $GLOBALS['T3_VAR']['getUserObj'][$hookClass] = $hookMock;
79 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'][] = $hookClass;
80
81 $adminPanelMock = $this->getMock('tslib_AdminPanel', array('dummy'), array(), '', FALSE);
82
83 $hookMock->expects($this->once())
84 ->method('extendAdminPanel')
85 ->with($this->isType('string'), $this->isInstanceOf('tslib_AdminPanel'));
86
87 $adminPanelMock->display();
88 }
89 }
90 ?>