protected function setUpNodeTestData() { $fixture = new \TYPO3\CMS\Backend\Tree\TreeNode(); $fixture->setId('Root'); $nodeCollection = new \TYPO3\CMS\Backend\Tree\TreeNodeCollection(); for ($i = 0; $i < 10; ++$i) { $node = new \TYPO3\CMS\Backend\Tree\TreeNode(); $node->setId($i); $node->setParentNode($fixture); $subNodeCollection = new \TYPO3\CMS\Backend\Tree\TreeNodeCollection(); for ($j = 0; $j < 5; ++$j) { $subNode = new \TYPO3\CMS\Backend\Tree\TreeRepresentationNode(); $subNode->setId($j); $subNode->setLabel('SubTest'); $subNode->setType('Type'); $subNode->setClass('Class'); $subNode->setIcon('Icon'); $subNode->setCallbackAction('Callback Action'); $subNode->setParentNode($node); $subNodeCollection->append($subNode); } $node->setChildNodes($subNodeCollection); $nodeCollection->append($node); } $fixture->setChildNodes($nodeCollection); return $fixture; }
/** * @test */ public function sortNodes() { $nodeCollection = new \TYPO3\CMS\Backend\Tree\TreeNodeCollection(array(array('serializeClassName' => 'TYPO3\\CMS\\Backend\\Tree\\TreeNode', 'id' => 15), array('serializeClassName' => 'TYPO3\\CMS\\Backend\\Tree\\TreeNode', 'id' => 25), array('serializeClassName' => 'TYPO3\\CMS\\Backend\\Tree\\TreeNode', 'id' => 5), array('serializeClassName' => 'TYPO3\\CMS\\Backend\\Tree\\TreeNode', 'id' => 2), array('serializeClassName' => 'TYPO3\\CMS\\Backend\\Tree\\TreeNode', 'id' => 150), array('serializeClassName' => 'TYPO3\\CMS\\Backend\\Tree\\TreeNode', 'id' => 67))); $nodeCollection->asort(); $expected = array(2, 5, 15, 25, 67, 150); $ids = array(); foreach ($nodeCollection as $node) { $ids[] = $node->getId(); } $this->assertSame($expected, $ids); }