ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTreeTest Class Reference

Unit tests for tree table. More...

+ Inheritance diagram for ilTreeTest:
+ Collaboration diagram for ilTreeTest:

Public Member Functions

 testGetChild ()
 
 testGetPathIdsUsingNestedSet ()
 get path ids using nested set @group IL_Init More...
 
 testGetPathIds ()
 get path ids (adjacenca and nested set) @group IL_Init More...
 
 testGetNodePath ()
 @group IL_Init More...
 
 testMaxDepth ()
 get path ids (adjacenca and nested set) @group IL_Init More...
 
 testAllOthers ()
 get path ids (adjacenca and nested set) @group IL_Init More...
 

Static Public Member Functions

 testGetChildsByType ()
 get childs by type @group IL_Init More...
 
 testGetChildsByTypeFilter ()
 get childs by type filter @group IL_Init More...
 
 testGetSubTree ()
 get childs by type filter @group IL_Init More...
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $backupGlobals = false
 

Detailed Description

Unit tests for tree table.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

@group needsInstalledILIAS

Definition at line 33 of file ilTreeTest.php.

Member Function Documentation

◆ setUp()

ilTreeTest::setUp ( )
protected

Definition at line 37 of file ilTreeTest.php.

38 {
39 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
40 ilUnitUtil::performInitialisation();
41 }

◆ testAllOthers()

ilTreeTest::testAllOthers ( )

get path ids (adjacenca and nested set) @group IL_Init

Parameters

return

Definition at line 163 of file ilTreeTest.php.

164 {
165 $tree = new ilTree(ROOT_FOLDER_ID);
166 $d = $tree->getDepth(24);
167
168 $this->assertEquals($d, 4);
169
170 $node = $tree->getNodeData(24);
171 $this->assertEquals($node['title'], 'Public chat');
172
173 $bool = $tree->isInTree(24);
174 $this->assertEquals($bool, true);
175
176 $bool = $tree->isInTree(24242424);
177 $this->assertEquals($bool, false);
178
179 /* ref_id 14 => obj_id 98 does not exist
180 $node = $tree->getParentNodeData(24);
181 $this->assertEquals($node['title'],'Chat-Server');
182 */
183
184 $bool = $tree->isGrandChild(9, 24);
185 $this->assertEquals($bool, 1);
186
187 /* see above
188 $node = $tree->getNodeDataByType('chac');
189 $this->assertEquals($node[0]['title'],'Chat-Server');
190 */
191
192 $bool = $tree->isDeleted(24);
193 $this->assertEquals($bool, false);
194
195 $id = $tree->getParentId(24);
196 $this->assertEquals($id, 14);
197
198 $lft = $tree->getLeftValue(24);
199 $this->assertEquals($lft, 14);
200
201 $seq = $tree->getChildSequenceNumber($tree->getNodeData(24));
202 $this->assertEquals($seq, 1);
203
204 $tree->getNodePath(9, 1);
205
206 $max_depth = $tree->getMaximumDepth();
207
208 // Round trip
209 $tree = new ilTree(ROOT_FOLDER_ID);
210 $suc = $tree->fetchSuccessorNode(16); // cals
211 $cals = $tree->fetchPredecessorNode($suc['child']);
212 $this->assertEquals($cals['child'], 16);
213 }
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
if(!array_key_exists('StateId', $_REQUEST)) $id

References $d, $id, and $tree.

◆ testGetChild()

ilTreeTest::testGetChild ( )

Definition at line 43 of file ilTreeTest.php.

44 {
45 $tree = new ilTree(ROOT_FOLDER_ID);
46 $childs = $tree->getChilds(14); // Chat settings (contains public chat)
47
48 $this->assertEquals(count($childs), 1);
49 }

References $tree.

◆ testGetChildsByType()

ilTreeTest::testGetChildsByType ( )
static

get childs by type @group IL_Init

Definition at line 56 of file ilTreeTest.php.

57 {
58 $tree = new ilTree(ROOT_FOLDER_ID);
59 $childs = $tree->getChildsByType(9, 'cals'); // only calendar settings
60
61 $this->assertEquals(count($childs), 1);
62 }

References $tree.

◆ testGetChildsByTypeFilter()

ilTreeTest::testGetChildsByTypeFilter ( )
static

get childs by type filter @group IL_Init

Definition at line 69 of file ilTreeTest.php.

70 {
71 $tree = new ilTree(ROOT_FOLDER_ID);
72 $childs = $tree->getChildsByTypeFilter(9, array('cals','rolf')); // only calendar settings and role folder
73
74 $this->assertEquals(count($childs), 2);
75 }

References $tree.

◆ testGetNodePath()

ilTreeTest::testGetNodePath ( )

@group IL_Init

Parameters

return

Definition at line 139 of file ilTreeTest.php.

140 {
141 $tree = new ilTree(ROOT_FOLDER_ID);
142 $res = $tree->getNodePath(1, 29);
143 }
foreach($_POST as $key=> $value) $res

References $res, and $tree.

◆ testGetPathIds()

ilTreeTest::testGetPathIds ( )

get path ids (adjacenca and nested set) @group IL_Init

Parameters

return

Definition at line 121 of file ilTreeTest.php.

122 {
123 // This test leads to a fatal error, as getPathIdsUsingNestedSets and
124 // getPathIdsUsingAdjacencyMap are not defined on ilTree.
125 $this->assertTrue(false, "Testcase leads to fatal error.");
126
127 $tree = new ilTree(ROOT_FOLDER_ID);
128 $ids_ns = $tree->getPathIdsUsingNestedSets(24);
129 $ids_al = $tree->getPathIdsUsingAdjacencyMap(24);
130
131 $this->assertEquals($ids_ns, $ids_al);
132 }

References $tree.

◆ testGetPathIdsUsingNestedSet()

ilTreeTest::testGetPathIdsUsingNestedSet ( )

get path ids using nested set @group IL_Init

Parameters

return

Definition at line 98 of file ilTreeTest.php.

99 {
100 // This test leads to a fatal error, as getPathIdsUsingNestedSets is
101 // not defined on ilTree.
102 $this->assertTrue(false, "Testcase leads to fatal error.");
103
104 $tree = new ilTree(ROOT_FOLDER_ID);
105 $ids = $tree->getPathIdsUsingNestedSets(24, 9); // Administration -> Public Chat => should return 9,14,24 (chat server settings)
106
107 $this->assertEquals($ids, array(9,14,24));
108
109 $tree = new ilTree(ROOT_FOLDER_ID);
110 $ids = $tree->getPathIdsUsingNestedSets(24); // Administration -> Public Chat => should return 9,14,24 (chat server settings)
111
112 $this->assertEquals($ids, array(1,9,14,24));
113 }

References $tree.

◆ testGetSubTree()

ilTreeTest::testGetSubTree ( )
static

get childs by type filter @group IL_Init

Definition at line 82 of file ilTreeTest.php.

83 {
84 $tree = new ilTree(ROOT_FOLDER_ID);
85
86 $root = $tree->getNodeData(1);
87 $childs = $tree->getSubTree($root, false, 'cals'); // only calendar settings
88
89 $this->assertEquals(count($childs), 1);
90 }
$root
Definition: sabredav.php:45

References $root, and $tree.

◆ testMaxDepth()

ilTreeTest::testMaxDepth ( )

get path ids (adjacenca and nested set) @group IL_Init

Parameters

return

Definition at line 151 of file ilTreeTest.php.

152 {
153 $tree = new ilTree(ROOT_FOLDER_ID);
154 $tree->getMaximumDepth();
155 }

References $tree.

Field Documentation

◆ $backupGlobals

ilTreeTest::$backupGlobals = false
protected

Definition at line 35 of file ilTreeTest.php.


The documentation for this class was generated from the following file: