[BUGFIX] Drag&Drop inside the root page of the pagetree isn't possible
[Packages/TYPO3.CMS.git] / tests / t3lib / tree / pagetree / 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 foreach ($subpages as $subpage) {
75 if (!t3lib_BEfunc::getRecordWSOL('pages', $subpage['uid'])) {
76 $this->markTestSkipped('getNodesSetsIsMountPointField test only available if pages with uid 1, 2 and 3 exist');
77 }
78 }
79
80 $this->fixture = $this->getMock('t3lib_tree_pagetree_DataProvider', array('getSubpages'));
81 $this->fixture->expects($this->once())->method('getSubpages')
82 ->will($this->returnValue($subpages));
83
84 $node = new t3lib_tree_Node();
85 $node->setId(12);
86
87 $nodeCollection = $this->fixture->getNodes($node);
88
89 /** @var $node t3lib_tree_pagetree_Node */
90 $isMountPointResult = array();
91 foreach ($nodeCollection as $node) {
92 $isMountPointResult[] = $node->isMountPoint();
93 }
94 $this->assertSame(array(FALSE, TRUE, FALSE), $isMountPointResult);
95 }
96 }
97
98 ?>