Fixed bug #11224: Special menu directory only renders 1st level if special.value...
[Packages/TYPO3.CMS.git] / tests / t3lib / t3lib_pageselect_testcase.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 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 /**
27 * Testcase for class t3lib_page
28 *
29 * @author Christian Kuhn <lolli@schwarzbu.ch>
30 * @package TYPO3
31 * @subpackage t3lib
32 */
33 class t3lib_pageselect_testcase extends tx_phpunit_testcase {
34
35 /**
36 * @var t3lib_DB
37 */
38 protected $typo3DbBackup;
39
40 /**
41 * @var t3lib_pageSelect
42 */
43 protected $pageSelectObject;
44
45 /**
46 * Sets up this testcase
47 */
48 public function setUp() {
49 $this->typo3DbBackup = $GLOBALS['TYPO3_DB'];
50 $GLOBALS['TYPO3_DB'] = $this->getMock('t3lib_DB', array('exec_SELECTquery', 'sql_fetch_assoc', 'sql_free_result'));
51
52 $this->pageSelectObject = new t3lib_pageSelect();
53 }
54
55 /**
56 * Tears down this testcase
57 */
58 public function tearDown() {
59 $GLOBALS['TYPO3_DB'] = $this->typo3DbBackup;
60 }
61
62 /**
63 * Tests whether the getPage Hook is called correctly.
64 *
65 * @test
66 */
67 public function isGetPageHookCalled() {
68 // Create a hook mock object
69 $className = uniqid('tx_coretest');
70 $getPageHookMock = $this->getMock(
71 't3lib_pageSelect_getPageHook',
72 array('getPage_preProcess'),
73 array(),
74 $className
75 );
76
77 // Register hook mock object
78 $GLOBALS['T3_VAR']['getUserObj'][$className] = $getPageHookMock;
79 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPage'][] = $className;
80
81 // Test if hook is called and register a callback method to check given arguments
82 $getPageHookMock->expects($this->once())->method('getPage_preProcess')
83 ->will($this->returnCallback(array($this, 'isGetPagePreProcessCalledCallback')));
84
85 $this->pageSelectObject->getPage(42, FALSE);
86 }
87
88 /**
89 * Handles the arguments that have been sent to the getPage_preProcess hook
90 */
91 public function isGetPagePreProcessCalledCallback() {
92 list($uid, $disableGroupAccessCheck, $parent) = func_get_args();
93
94 $this->assertEquals(42, $uid);
95 $this->assertFalse($disableGroupAccessCheck);
96 $this->assertTrue($parent instanceof t3lib_pageSelect);
97 }
98 }
99
100 ?>