ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 157 of file ilTreeTest.php.

158 {
159 $tree = new ilTree(ROOT_FOLDER_ID);
160 $d = $tree->getDepth(24);
161
162 $this->assertEquals($d,4);
163
164 $node = $tree->getNodeData(24);
165 $this->assertEquals($node['title'],'Public chat');
166
167 $bool = $tree->isInTree(24);
168 $this->assertEquals($bool,true);
169
170 $bool = $tree->isInTree(24242424);
171 $this->assertEquals($bool,false);
172
173 /* ref_id 14 => obj_id 98 does not exist
174 $node = $tree->getParentNodeData(24);
175 $this->assertEquals($node['title'],'Chat-Server');
176 */
177
178 $bool = $tree->isGrandChild(9,24);
179 $this->assertEquals($bool,1);
180
181 /* see above
182 $node = $tree->getNodeDataByType('chac');
183 $this->assertEquals($node[0]['title'],'Chat-Server');
184 */
185
186 $bool = $tree->isDeleted(24);
187 $this->assertEquals($bool,false);
188
189 $id = $tree->getParentId(24);
190 $this->assertEquals($id,14);
191
192 $lft = $tree->getLeftValue(24);
193 $this->assertEquals($lft,14);
194
195 $seq = $tree->getChildSequenceNumber($tree->getNodeData(24));
196 $this->assertEquals($seq,1);
197
198 $tree->getNodePath(9,1);
199
200 $max_depth = $tree->getMaximumDepth();
201
202 // Round trip
203 $tree = new ilTree(ROOT_FOLDER_ID);
204 $suc = $tree->fetchSuccessorNode(16); // cals
205 $cals = $tree->fetchPredecessorNode($suc['child']);
206 $this->assertEquals($cals['child'],16);
207 }
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 133 of file ilTreeTest.php.

134 {
135 $tree = new ilTree(ROOT_FOLDER_ID);
136 $res = $tree->getNodePath(1,29);
137 }

References $res.

◆ testGetPathIds()

ilTreeTest::testGetPathIds ( )

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

Parameters

return

Definition at line 119 of file ilTreeTest.php.

120 {
121 $tree = new ilTree(ROOT_FOLDER_ID);
122 $ids_ns = $tree->getPathIdsUsingNestedSets(24);
123 $ids_al = $tree->getPathIdsUsingAdjacencyMap(24);
124
125 $this->assertEquals($ids_ns,$ids_al);
126 }

◆ testGetPathIdsUsingNestedSet()

ilTreeTest::testGetPathIdsUsingNestedSet ( )

get path ids using nested set @group IL_Init

Parameters

return

Definition at line 99 of file ilTreeTest.php.

100 {
101 $tree = new ilTree(ROOT_FOLDER_ID);
102 $ids = $tree->getPathIdsUsingNestedSets(24,9); // Administration -> Public Chat => should return 9,14,24 (chat server settings)
103
104 $this->assertEquals($ids,array(9,14,24));
105
106 $tree = new ilTree(ROOT_FOLDER_ID);
107 $ids = $tree->getPathIdsUsingNestedSets(24); // Administration -> Public Chat => should return 9,14,24 (chat server settings)
108
109 $this->assertEquals($ids,array(1,9,14,24));
110
111 }

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

146 {
147 $tree = new ilTree(ROOT_FOLDER_ID);
148 $tree->getMaximumDepth();
149 }

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: