ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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$

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 164 of file ilTreeTest.php.

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

References $d.

◆ 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 }

◆ 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 }

◆ 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 }

◆ testGetNodePath()

ilTreeTest::testGetNodePath ( )

@group IL_Init

Parameters

return

Definition at line 140 of file ilTreeTest.php.

141 {
142 $tree = new ilTree(ROOT_FOLDER_ID);
143 $res = $tree->getNodePath(1,29);
144 }

References $res.

◆ testGetPathIds()

ilTreeTest::testGetPathIds ( )

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

Parameters

return

Definition at line 122 of file ilTreeTest.php.

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

◆ testGetPathIdsUsingNestedSet()

ilTreeTest::testGetPathIdsUsingNestedSet ( )

get path ids using nested set @group IL_Init

Parameters

return

Definition at line 99 of file ilTreeTest.php.

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

◆ 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
91 }

◆ testMaxDepth()

ilTreeTest::testMaxDepth ( )

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

Parameters

return

Definition at line 152 of file ilTreeTest.php.

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

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: