cd26efe887f842e963bce18dfe8f256ad969c7e3
[Packages/TYPO3.CMS.git] / tests / Unit / t3lib / tree / pagetree / class.t3lib_tree_pagetree_dataproviderTest.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2012 Stefan Galinski <stefan.galinski@gmail.com>
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 class t3lib_tree_pagetree_DataProvider.
27 *
28 * @author Stefan Galinski <stefan.galinski@gmail.com>
29 * @package TYPO3
30 * @subpackage t3lib
31 */
32 class t3lib_tree_pagetree_DataProviderTest extends tx_phpunit_testcase {
33 /**
34 * @var PHPUnit_Framework_MockObject_MockObject|t3lib_tree_pagetree_DataProvider
35 */
36 protected $fixture = NULL;
37
38 /**
39 * @var array
40 */
41 protected $backupGlobalVariables = array();
42
43 public function setUp() {
44 $this->backupGlobalVariables['TYPO3_CONF_VARS'] = $GLOBALS['TYPO3_CONF_VARS'];
45 $GLOBALS['TYPO3_CONF_VARS']['BE']['pageTree']['preloadLimit'] = 0;
46 }
47
48 public function tearDown() {
49 unset($this->fixture);
50
51 foreach ($this->backupGlobalVariables as $name => $value) {
52 $GLOBALS[$name] = $value;
53 }
54 }
55
56 /**
57 * @test
58 */
59 public function getNodesSetsIsMountPointField() {
60 $subpages = array(
61 array(
62 'uid' => 1,
63 'isMountPoint' => FALSE,
64 ),
65 array(
66 'uid' => 2,
67 'isMountPoint' => TRUE,
68 ),
69 array(
70 'uid' => 3,
71 ),
72 );
73
74 $subpagesWithWorkspaceOverlay = array(
75 array(
76 'uid' => 1,
77 'title' => 'Home',
78 ),
79 array(
80 'uid' => 2,
81 'title' => 'service',
82 ),
83 array(
84 'uid' => 3,
85 'title' => 'contact',
86 ),
87 );
88
89 $this->fixture = $this->getMock('t3lib_tree_pagetree_DataProvider', array('getSubpages', 'getRecordWithWorkspaceOverlay'));
90 $this->fixture->expects($this->once())->method('getSubpages')
91 ->will($this->returnValue($subpages));
92
93 $this->fixture->expects($this->at(1))->method('getRecordWithWorkspaceOverlay')->with(1)
94 ->will($this->returnValue($subpagesWithWorkspaceOverlay[0]));
95 $this->fixture->expects($this->at(2))->method('getRecordWithWorkspaceOverlay')->with(2)
96 ->will($this->returnValue($subpagesWithWorkspaceOverlay[1]));
97 $this->fixture->expects($this->at(3))->method('getRecordWithWorkspaceOverlay')->with(3)
98 ->will($this->returnValue($subpagesWithWorkspaceOverlay[2]));
99
100 $node = new t3lib_tree_Node();
101 $node->setId(12);
102
103 $nodeCollection = $this->fixture->getNodes($node);
104
105 /** @var $node t3lib_tree_pagetree_Node */
106 $isMountPointResult = array();
107 foreach ($nodeCollection as $node) {
108 $isMountPointResult[] = $node->isMountPoint();
109 }
110 $this->assertSame(array(FALSE, TRUE, FALSE), $isMountPointResult);
111 }
112 }
113
114 ?>