ILIAS  release_7 Revision v7.30-3-g800a261c036
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 35 of file ilTreeTest.php.

Member Function Documentation

◆ setUp()

ilTreeTest::setUp ( )
protected

Definition at line 39 of file ilTreeTest.php.

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

◆ testAllOthers()

ilTreeTest::testAllOthers ( )

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

Parameters

return

Definition at line 165 of file ilTreeTest.php.

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

References $d, and ROOT_FOLDER_ID.

◆ testGetChild()

ilTreeTest::testGetChild ( )

Definition at line 45 of file ilTreeTest.php.

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

References ROOT_FOLDER_ID.

◆ testGetChildsByType()

ilTreeTest::testGetChildsByType ( )
static

get childs by type @group IL_Init

Definition at line 58 of file ilTreeTest.php.

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

References ROOT_FOLDER_ID.

◆ testGetChildsByTypeFilter()

ilTreeTest::testGetChildsByTypeFilter ( )
static

get childs by type filter @group IL_Init

Definition at line 71 of file ilTreeTest.php.

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

References ROOT_FOLDER_ID.

◆ testGetNodePath()

ilTreeTest::testGetNodePath ( )

@group IL_Init

Parameters

return

Definition at line 141 of file ilTreeTest.php.

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

References $res, and ROOT_FOLDER_ID.

◆ testGetPathIds()

ilTreeTest::testGetPathIds ( )

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

Parameters

return

Definition at line 123 of file ilTreeTest.php.

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

References ROOT_FOLDER_ID.

◆ testGetPathIdsUsingNestedSet()

ilTreeTest::testGetPathIdsUsingNestedSet ( )

get path ids using nested set @group IL_Init

Parameters

return

Definition at line 100 of file ilTreeTest.php.

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

References ROOT_FOLDER_ID.

◆ testGetSubTree()

ilTreeTest::testGetSubTree ( )
static

get childs by type filter @group IL_Init

Definition at line 84 of file ilTreeTest.php.

85 {
86 $tree = new ilTree(ROOT_FOLDER_ID);
87
88 $root = $tree->getNodeData(1);
89 $childs = $tree->getSubTree($root, false, 'cals'); // only calendar settings
90
91 $this->assertEquals(count($childs), 1);
92 }

References ROOT_FOLDER_ID.

◆ testMaxDepth()

ilTreeTest::testMaxDepth ( )

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

Parameters

return

Definition at line 153 of file ilTreeTest.php.

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

References ROOT_FOLDER_ID.

Field Documentation

◆ $backupGlobals

ilTreeTest::$backupGlobals = false
protected

Definition at line 37 of file ilTreeTest.php.


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