ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilObjStudyProgrammeTest Class Reference

TestCase for the ilObjStudyProgramme. More...

+ Inheritance diagram for ilObjStudyProgrammeTest:
+ Collaboration diagram for ilObjStudyProgrammeTest:

Public Member Functions

 testCreation ()
 Test creation of ilObjStudyProgramme. More...
 
 testDefaults ()
 
 testLoadByObjId ()
 Test loading of ilObjStudyProgramme with obj_id. More...
 
 testLoadByRefId ()
 Test loading of ilObjStudyProgramme with ref_id. More...
 
 testGetInstanceByRefId ()
 Test loading over getInstance. More...
 
 testSettings ()
 Test tings on ilObjStudyProgramme. More...
 
 testDelete ()
 Test deletion of a ilObjStudyProgramme. More...
 
 testTreeCreation ()
 Test creating a small tree. More...
 
 testTreeGetChildren ()
 Test function to get children or information about them. More...
 
 testTreeGetParent ()
 Test getParent on ilObjStudyProgramme. More...
 
 testTreeGetParents ()
 @depends testTreeCreation More...
 
 testTreeDepth ()
 Test getDepth on ilObjStudyProgramme. More...
 
 testTreeGetRoot ()
 Test getRoot on ilObjStudyProgramme. More...
 
 testApplyToSubTreeNodes ()
 Test applyToSubTreeNodes on ilObjStudyProgramme. More...
 
 testAddNode ()
 Test on addNode. More...
 
 testRemoveNode ()
 Test on removeNode. More...
 
 testAddLeaf ()
 Test on addLeaf. More...
 
 testRemoveLeaf ()
 Test on removeLead. More...
 
 testAddWrongChildType ()
 Test whether nodes can only be added when there is no leaf in the parent and vice versa. More...
 
 testMoveTo ()
 Test on moveTo. More...
 
 testCantRemoveNodeWithRelevantProgress ()
 @expectedException ilStudyProgrammeTreeException More...
 
 testCanRemoveNodeWithNotRelevantProgress ()
 
 testCreateableSubObjects ()
 
 testCreatableSubObjectsWithoutRef ()
 
 testCreatableSubObjectsRaisesOnNonProgramRef ()
 @expectedException ilException More...
 
 testDeleteRemovesEntriesInPrgSettings ()
 
 testCreatePermissionExists ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 
 createSmallTree ()
 Creates a small tree, used by various tests. More...
 

Protected Attributes

 $backupGlobals = FALSE
 

Detailed Description

Member Function Documentation

◆ createSmallTree()

ilObjStudyProgrammeTest::createSmallTree ( )
protected

Creates a small tree, used by various tests.

Definition at line 183 of file ilObjStudyProgrammeTest.php.

183 {
187
188 $this->root_object->addNode($first_node);
189 $this->root_object->addNode($second_node);
190 $this->root_object->addNode($third_node);
191
192 $third_first_node = ilObjStudyProgramme::createInstance();
193 $third_node->addNode($third_first_node);
194 }
static createInstance()
Create an instance of ilObjStudyProgramme, put in cache.

References ilObjStudyProgramme\createInstance().

Referenced by testAddLeaf(), testAddNode(), testAddWrongChildType(), testApplyToSubTreeNodes(), testCanRemoveNodeWithNotRelevantProgress(), testCantRemoveNodeWithRelevantProgress(), testCreateableSubObjects(), testMoveTo(), testRemoveNode(), testTreeCreation(), testTreeDepth(), testTreeGetChildren(), testTreeGetParent(), testTreeGetParents(), and testTreeGetRoot().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUp()

ilObjStudyProgrammeTest::setUp ( )
protected

Definition at line 37 of file ilObjStudyProgrammeTest.php.

37 {
38 PHPUnit_Framework_Error_Deprecated::$enabled = FALSE;
39
40 require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
41
42 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
43 ilUnitUtil::performInitialisation();
44
45 $this->root_object = ilObjStudyProgramme::createInstance();
46 $this->root_object_obj_id = $this->root_object->getId();
47 $this->root_object_ref_id = $this->root_object->getRefId();
48 $this->root_object->putInTree(ROOT_FOLDER_ID);
49
50 //
51
52 global $tree;
53 $this->tree = $tree;
54
55 global $objDefinition;
56 $this->obj_definition = $objDefinition;
57 }

References ilObjStudyProgramme\createInstance().

+ Here is the call graph for this function:

◆ tearDown()

ilObjStudyProgrammeTest::tearDown ( )
protected

Definition at line 59 of file ilObjStudyProgrammeTest.php.

59 {
60 if ($this->root_object) {
61 $this->root_object->delete();
62 }
63 }

◆ testAddLeaf()

ilObjStudyProgrammeTest::testAddLeaf ( )

Test on addLeaf.

@depends testTreeCreation

Definition at line 386 of file ilObjStudyProgrammeTest.php.

386 {
387 $this->createSmallTree();
388 $mock_leaf = new ilStudyProgrammeLeafMock();
389
390 $children = $this->root_object->getChildren();
391 $first_child = $children[0];
392
393 $first_child->addLeaf($mock_leaf);
394
395 // We use our mock factory, since the original factory won't know how
396 // to create our mock leaf.
397 $first_child->object_factory = new ilObjectFactoryWrapperMock();
398
399 $this->assertEquals(3, $this->root_object->getAmountOfChildren(), "getAmountOfChildren()");
400 // Check if StudyProgrammes are not counted as LP-Children
401 $this->assertEquals(0, $this->root_object->getAmountOfLPChildren(), "getAmountOfLPChildren() on root");
402 $this->assertEquals(false, $this->root_object->hasLPChildren(), "hasLPChildren() on root");
403
404 $this->assertEquals(1, $first_child->getAmountOfLPChildren(), "getAmountOfLPChildren() on first child");
405 $this->assertEquals(true, $first_child->hasLPChildren(), "hasLPChildren() on first child");
406 $this->assertEquals($first_child->getLPMode(), ilStudyProgramme::MODE_LP_COMPLETED);
407
408 $lp_children = $first_child->getLPChildren();
409 $this->assertEquals(1, count($lp_children));
410 $this->assertEquals($mock_leaf->getId(), $lp_children[0]->getId());
411 }
createSmallTree()
Creates a small tree, used by various tests.
Mock for object factory.
Definition: mocks.php:66
Mock classes for tests.
Definition: mocks.php:21

References createSmallTree(), and ilStudyProgramme\MODE_LP_COMPLETED.

+ Here is the call graph for this function:

◆ testAddNode()

ilObjStudyProgrammeTest::testAddNode ( )

Test on addNode.

@depends testTreeCreation

Definition at line 329 of file ilObjStudyProgrammeTest.php.

329 {
330 $this->createSmallTree();
331
332 $children = $this->root_object->getChildren();
333 $child = $children[0];
334 $grandchild = new ilObjStudyProgramme();
335 $grandchild->create();
336 $child->addNode($grandchild);
337
338 $this->assertEquals($child->getId(), $grandchild->getParent()->getId());
339 $this->assertEquals($this->root_object->getId(), $grandchild->getRoot()->getId(),
340 "Root of grandchild is root of tree.");
341 $this->assertEquals(1, $child->getAmountOfChildren());
342 $this->assertEquals(2, $grandchild->getDepth());
343 $this->assertEquals($child->getLPMode(), ilStudyProgramme::MODE_POINTS);
344 }
Class ilObjStudyProgramme.

References createSmallTree(), and ilStudyProgramme\MODE_POINTS.

+ Here is the call graph for this function:

◆ testAddWrongChildType()

ilObjStudyProgrammeTest::testAddWrongChildType ( )

Test whether nodes can only be added when there is no leaf in the parent and vice versa.

Definition at line 434 of file ilObjStudyProgrammeTest.php.

434 {
435 $this->createSmallTree();
436 $children = $this->root_object->getChildren();
437 $child_n = $children[0];
438 $child_l = $children[1];
439
440 $mock_leaf1 = new ilStudyProgrammeLeafMock();
441 $mock_leaf2 = new ilStudyProgrammeLeafMock();
442 $node1 = new ilObjStudyProgramme();
443 $node2 = new ilObjStudyProgramme();
444 $node1->create();
445 $node2->create();
446
447 $child_n->addNode($node1);
448 $child_l->addLeaf($mock_leaf1);
449
450 $raised = false;
451 try {
452 $child_n->addLeaf($mock_leaf2);
453 }
455 $raised = true;
456 }
457 $this->assertTrue($raised, "Could add leaf to program containing node.");
458
459 $raised = false;
460 try {
461 $child_n->addLeaf($mock_leaf2);
462 }
464 $raised = true;
465 }
466 $this->assertTrue($raised, "Could add node to program containing leaf.");
467 }
Exception is thrown when invariants on the program tree would be violated by manipulation of tree.

References createSmallTree().

+ Here is the call graph for this function:

◆ testApplyToSubTreeNodes()

ilObjStudyProgrammeTest::testApplyToSubTreeNodes ( )

Test applyToSubTreeNodes on ilObjStudyProgramme.

@depends testTreeCreation

Definition at line 295 of file ilObjStudyProgrammeTest.php.

295 {
296 $this->createSmallTree();
297 $children = $this->root_object->getChildren();
298
299 $val = 0;
300 $this->root_object->applyToSubTreeNodes(function($node) use (&$val) {
301 $val += $node->getPoints();
302 });
303
304 // We didn't make modification on the points of the nodes.
305 $this->assertEquals($val, 5 * ilStudyProgramme::DEFAULT_POINTS);
306
307
308 $this->root_object->setPoints(1);
309 $children[0]->setPoints(2);
310 $children[1]->setPoints(4);
311 $children[2]->setPoints(1);
312
313 $third_level = $children[2]->getChildren();
314 $third_level[0]->setPoints(2);
315
316 $val = 0;
317 $this->root_object->applyToSubTreeNodes(function($node) use (&$val) {
318 $val += $node->getPoints();
319 });
320
321 $this->assertEquals($val, 10);
322 }

References createSmallTree(), and ilStudyProgramme\DEFAULT_POINTS.

+ Here is the call graph for this function:

◆ testCanRemoveNodeWithNotRelevantProgress()

ilObjStudyProgrammeTest::testCanRemoveNodeWithNotRelevantProgress ( )

Definition at line 523 of file ilObjStudyProgrammeTest.php.

523 {
524 $this->createSmallTree();
525 $children = $this->root_object->getChildren();
526 $child_l = $children[0];
527 $child_r = $children[1];
528 $this->root_object->setStatus(ilStudyProgramme::STATUS_ACTIVE);
529 $child_l->setStatus(ilStudyProgramme::STATUS_ACTIVE);
530 $child_r->setStatus(ilStudyProgramme::STATUS_OUTDATED);
531
532 $user = new ilObjUser();
533 $user->create();
534
535 $this->root_object->assignUser($user->getId());
536 $this->root_object->removeNode($child_r);
537 }

References createSmallTree(), ilStudyProgramme\STATUS_ACTIVE, and ilStudyProgramme\STATUS_OUTDATED.

+ Here is the call graph for this function:

◆ testCantRemoveNodeWithRelevantProgress()

ilObjStudyProgrammeTest::testCantRemoveNodeWithRelevantProgress ( )

@expectedException ilStudyProgrammeTreeException

Definition at line 507 of file ilObjStudyProgrammeTest.php.

507 {
508 $this->createSmallTree();
509 $children = $this->root_object->getChildren();
510 $child_l = $children[0];
511 $child_r = $children[1];
512 $this->root_object->setStatus(ilStudyProgramme::STATUS_ACTIVE);
513 $child_l->setStatus(ilStudyProgramme::STATUS_ACTIVE);
514 $child_r->setStatus(ilStudyProgramme::STATUS_ACTIVE);
515
516 $user = new ilObjUser();
517 $user->create();
518
519 $child_l->assignUser($user->getId());
520 $this->root_object->removeNode($child_l);
521 }

References createSmallTree(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testCreatableSubObjectsRaisesOnNonProgramRef()

ilObjStudyProgrammeTest::testCreatableSubObjectsRaisesOnNonProgramRef ( )

@expectedException ilException

Definition at line 587 of file ilObjStudyProgrammeTest.php.

587 {
589 }
static getCreatableSubObjects($a_subobjects, $a_ref_id)
Filter the list of possible subobjects for the objects that actually could be created on a concrete n...

References ilObjStudyProgramme\getCreatableSubObjects().

+ Here is the call graph for this function:

◆ testCreatableSubObjectsWithoutRef()

ilObjStudyProgrammeTest::testCreatableSubObjectsWithoutRef ( )

Definition at line 575 of file ilObjStudyProgrammeTest.php.

575 {
576 $all_possible_subobjects = $this->obj_definition->getSubObjects("prg");
577 // don't take rolfs into account, we don't need rolf anymore
578 unset($all_possible_subobjects["rolf"]);
579 $this->assertEquals( $all_possible_subobjects
580 , ilObjStudyProgramme::getCreatableSubObjects($all_possible_subobjects, null)
581 );
582 }

References ilObjStudyProgramme\getCreatableSubObjects().

+ Here is the call graph for this function:

◆ testCreateableSubObjects()

ilObjStudyProgrammeTest::testCreateableSubObjects ( )

Definition at line 539 of file ilObjStudyProgrammeTest.php.

539 {
540 $this->createSmallTree();
541 $children = $this->root_object->getChildren();
542 $child_l = $children[0];
543
544 $all_possible_subobjects = $this->root_object->getPossibleSubObjects();
545 // don't take rolfs into account, we don't need rolf anymore
546 unset($all_possible_subobjects["rolf"]);
547
548 // this is course reference and training programme
549 $this->assertCount(2, $all_possible_subobjects);
550 $this->assertArrayHasKey("prg", $all_possible_subobjects);
551 $this->assertArrayHasKey("crsr", $all_possible_subobjects);
552
553 // root already contains program nodes, so course ref is forbidden
554 $subobjs = ilObjStudyProgramme::getCreatableSubObjects($all_possible_subobjects, $this->root_object->getRefId());
555 $this->assertCount(1, $subobjs);
556 $this->assertArrayHasKey("prg", $subobjs);
557
558 // first node contains nothing, so course ref and program node are allowed
559 $subobjs = ilObjStudyProgramme::getCreatableSubObjects($all_possible_subobjects, $child_l->getRefId());
560 $this->assertCount(2, $subobjs);
561 $this->assertArrayHasKey("prg", $subobjs);
562 $this->assertArrayHasKey("crsr", $subobjs);
563
564 $mock_leaf = new ilStudyProgrammeLeafMock();
565 $children = $this->root_object->getChildren();
566 $child_l->object_factory = new ilObjectFactoryWrapperMock();
567 $child_l->addLeaf($mock_leaf);
568
569 // Now we added a leaf, so no program nodes are allowed anymore.
570 $subobjs = ilObjStudyProgramme::getCreatableSubObjects($all_possible_subobjects, $child_l->getRefId());
571 $this->assertCount(1, $subobjs);
572 $this->assertArrayHasKey("crsr", $subobjs);
573 }

References createSmallTree(), and ilObjStudyProgramme\getCreatableSubObjects().

+ Here is the call graph for this function:

◆ testCreatePermissionExists()

ilObjStudyProgrammeTest::testCreatePermissionExists ( )

Definition at line 604 of file ilObjStudyProgrammeTest.php.

604 {
605 // Ask for permission id for creation of "foobar" to check assumption
606 // that lookupCreateOperationIds just drops unknown object types.
607 $op_ids = ilRbacReview::lookupCreateOperationIds(array("prg", "foobar"));
608 $this->assertCount(1, $op_ids);
609 }
static lookupCreateOperationIds($a_type_arr)
Lookup operation ids.

References ilRbacReview\lookupCreateOperationIds().

+ Here is the call graph for this function:

◆ testCreation()

ilObjStudyProgrammeTest::testCreation ( )

Test creation of ilObjStudyProgramme.

Definition at line 68 of file ilObjStudyProgrammeTest.php.

68 {
69 $this->assertNotEmpty($this->root_object_obj_id);
70 $this->assertGreaterThan(0, $this->root_object_obj_id);
71
72 $this->assertNotEmpty($this->root_object_ref_id);
73 $this->assertGreaterThan(0, $this->root_object_ref_id);
74
75 $this->assertTrue($this->tree->isInTree($this->root_object_ref_id));
76 }

◆ testDefaults()

ilObjStudyProgrammeTest::testDefaults ( )

Definition at line 78 of file ilObjStudyProgrammeTest.php.

78 {
79 $this->assertEquals($this->root_object->getStatus(), ilStudyProgramme::STATUS_DRAFT);
80 }

References ilStudyProgramme\STATUS_DRAFT.

◆ testDelete()

ilObjStudyProgrammeTest::testDelete ( )

Test deletion of a ilObjStudyProgramme.

@depends testCreation

Definition at line 174 of file ilObjStudyProgrammeTest.php.

174 {
175 $deleted_object = ilObjStudyProgramme::getInstanceByRefId($this->root_object_ref_id);
176
177 $this->assertTrue($deleted_object->delete());
178 }
static getInstanceByRefId($a_ref_id)
Get an instance of ilObjStudyProgramme, use cache.

References ilObjStudyProgramme\getInstanceByRefId().

+ Here is the call graph for this function:

◆ testDeleteRemovesEntriesInPrgSettings()

ilObjStudyProgrammeTest::testDeleteRemovesEntriesInPrgSettings ( )

Definition at line 591 of file ilObjStudyProgrammeTest.php.

591 {
592 $this->root_object->delete();
593 $this->root_object = null;
594
595 global $ilDB;
596 $res = $ilDB->query( "SELECT COUNT(*) cnt "
598 ." WHERE obj_id = ".$this->root_object_obj_id
599 );
600 $rec = $ilDB->fetchAssoc($res);
601 $this->assertEquals(0, $rec["cnt"]);
602 }
global $ilDB

References $ilDB, $res, and ilStudyProgramme\returnDbTableName().

+ Here is the call graph for this function:

◆ testGetInstanceByRefId()

ilObjStudyProgrammeTest::testGetInstanceByRefId ( )

Test loading over getInstance.

@depends testCreation

Definition at line 128 of file ilObjStudyProgrammeTest.php.

128 {
129 require_once("Modules/StudyProgramme/classes/class.ilObjStudyProgrammeCache.php");
130
132 $this->assertTrue(ilObjStudyProgrammeCache::singleton()->test_isEmpty());
133
134 $loaded = ilObjStudyProgramme::getInstanceByRefId($this->root_object_ref_id);
135 $orig = $this->root_object;
136
137 $this->assertNotNull($loaded);
138 $this->assertGreaterThan(0, $loaded->getId());
139 $this->assertEquals( $orig->getId(), $loaded->getId());
140 $this->assertEquals( $orig->getLastChange()->get(IL_CAL_DATETIME)
141 , $loaded->getLastChange()->get(IL_CAL_DATETIME)
142 );
143 $this->assertEquals( $orig->getPoints(), $loaded->getPoints());
144 $this->assertEquals( $orig->getLPMode(), $loaded->getLPMode());
145 $this->assertEquals( $orig->getStatus(), $loaded->getStatus());
146 }
const IL_CAL_DATETIME

References ilObjStudyProgramme\getInstanceByRefId(), IL_CAL_DATETIME, and ilObjStudyProgrammeCache\singleton().

+ Here is the call graph for this function:

◆ testLoadByObjId()

ilObjStudyProgrammeTest::testLoadByObjId ( )

Test loading of ilObjStudyProgramme with obj_id.

and ref_id

@depends testCreation

Definition at line 87 of file ilObjStudyProgrammeTest.php.

87 {
88 $loaded = new ilObjStudyProgramme($this->root_object_obj_id, false);
89 $orig = $this->root_object;
90 $load_ref_id = ilObjStudyProgramme::getInstanceByRefId($this->root_object_ref_id);
91
92 $this->assertNotNull($loaded);
93 $this->assertGreaterThan(0, $loaded->getId());
94 $this->assertEquals( $orig->getId(), $loaded->getId());
95 $this->assertEquals( $orig->getLastChange()->get(IL_CAL_DATETIME)
96 , $loaded->getLastChange()->get(IL_CAL_DATETIME)
97 );
98 $this->assertEquals( $orig->getPoints(), $loaded->getPoints());
99 $this->assertEquals( $orig->getLPMode(), $loaded->getLPMode());
100 $this->assertEquals( $orig->getStatus(), $loaded->getStatus());
101 }

References ilObjStudyProgramme\getInstanceByRefId(), and IL_CAL_DATETIME.

+ Here is the call graph for this function:

◆ testLoadByRefId()

ilObjStudyProgrammeTest::testLoadByRefId ( )

Test loading of ilObjStudyProgramme with ref_id.

@depends testCreation

Definition at line 108 of file ilObjStudyProgrammeTest.php.

108 {
109 $loaded = new ilObjStudyProgramme($this->root_object_ref_id);
110 $orig = $this->root_object;
111
112 $this->assertNotNull($loaded);
113 $this->assertGreaterThan(0, $loaded->getId());
114 $this->assertEquals( $orig->getId(), $loaded->getId());
115 $this->assertEquals( $orig->getLastChange()->get(IL_CAL_DATETIME)
116 , $loaded->getLastChange()->get(IL_CAL_DATETIME)
117 );
118 $this->assertEquals( $orig->getPoints(), $loaded->getPoints());
119 $this->assertEquals( $orig->getLPMode(), $loaded->getLPMode());
120 $this->assertEquals( $orig->getStatus(), $loaded->getStatus());
121 }

References IL_CAL_DATETIME.

◆ testMoveTo()

ilObjStudyProgrammeTest::testMoveTo ( )

Test on moveTo.

Definition at line 472 of file ilObjStudyProgrammeTest.php.

472 {
473 $this->createSmallTree();
474 $children = $this->root_object->getChildren();
475 $child_l = $children[0];
476 $child_r = $children[1];
477 $child_m = $children[2];
478
479 $child_r->moveTo($child_l);
480
481 $this->assertEquals(2, $child_r->getDepth());
482 $this->assertEquals($child_l->getId(), $child_r->getParent()->getId());
483 $this->assertEquals(2, $this->root_object->getAmountOfChildren());
484 $this->assertEquals(1, $child_l->getAmountOfChildren());
485
486 // test recursive moving
487 $this->assertEquals(1, $child_m->getAmountOfChildren());
488
489 $child_m->moveTo($child_r);
490
491 $m_children = $child_m->getChildren();
492 $first_third_node = $m_children[0];
493
494 $this->assertEquals(3, $child_m->getDepth());
495 $this->assertEquals(1, $child_m->getAmountOfChildren());
496 $this->assertNotNull($first_third_node);
497 $this->assertEquals(4, $first_third_node->getDepth());
498 $this->assertEquals($child_m->getId(), $first_third_node->getParent()->getId());
499
500 $this->assertEquals(1, $this->root_object->getAmountOfChildren());
501 $this->assertEquals(3, count(ilObjStudyProgramme::getAllChildren($child_l->getRefId())));
502 }
static getAllChildren($a_ref_id)
Get a list of all ilObjStudyProgrammes in the subtree starting at $a_ref_id.

References createSmallTree(), and ilObjStudyProgramme\getAllChildren().

+ Here is the call graph for this function:

◆ testRemoveLeaf()

ilObjStudyProgrammeTest::testRemoveLeaf ( )

Test on removeLead.

@depends testAddLeaf

Definition at line 418 of file ilObjStudyProgrammeTest.php.

418 {
419 $mock_leaf = new ilStudyProgrammeLeafMock();
420 $this->root_object->addLeaf($mock_leaf);
421
422 $this->root_object->removeLeaf($mock_leaf);
423 $this->assertEquals(0, $this->root_object->getAmountOfChildren(), "getAmountOfChildren()");
424 $this->assertEquals(0, $this->root_object->getAmountOfLPChildren(), "getAmountOfLPChildren()");
425
426 $lp_children = $this->root_object->getLPChildren();
427 $this->assertEquals(0, count($lp_children));
428 }

◆ testRemoveNode()

ilObjStudyProgrammeTest::testRemoveNode ( )

Test on removeNode.

@depends testTreeCreation

Definition at line 351 of file ilObjStudyProgrammeTest.php.

351 {
352 $this->createSmallTree();
353
354 $children = $this->root_object->getChildren();
355 $child = $children[0];
356 $this->root_object->removeNode($child);
357
358 // Is not in tree anymore...
359 $raised = false;
360 try {
361 $child->getParent();
362 }
364 $raised = true;
365 }
366 $this->assertTrue($raised, "Child does not raise on getParent after it is removed.");
367
368 $this->assertEquals(2, $this->root_object->getAmountOfChildren());
369
370 // Can't be removed a second time...
371 $raised = false;
372 try {
373 $this->root_object->removeNode($child);
374 }
376 $raised = true;
377 }
378 $this->assertTrue($raised, "Child can be removed two times.");
379 }

References createSmallTree().

+ Here is the call graph for this function:

◆ testSettings()

ilObjStudyProgrammeTest::testSettings ( )

Test tings on ilObjStudyProgramme.

@depends testCreation

Definition at line 153 of file ilObjStudyProgrammeTest.php.

153 {
154 $obj = ilObjStudyProgramme::getInstanceByRefId($this->root_object_ref_id);
155
156 $obj->setPoints(10);
157 $obj->setStatus(ilStudyProgramme::STATUS_ACTIVE);
158 $obj->update();
159
160 $obj = ilObjStudyProgramme::getInstanceByRefId($this->root_object_ref_id);
161
162 $this->assertEquals(10, $obj->getPoints());
163 $this->assertEquals(ilStudyProgramme::STATUS_ACTIVE, $obj->getStatus());
164
165 $midnight = strtotime("today midnight");
166 $this->assertGreaterThan($midnight, $obj->getLastChange()->getUnixTime());
167 }

References ilObjStudyProgramme\getInstanceByRefId(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testTreeCreation()

ilObjStudyProgrammeTest::testTreeCreation ( )

Test creating a small tree.

@depends testCreation

Definition at line 201 of file ilObjStudyProgrammeTest.php.

201 {
202 $this->createSmallTree();
203 $this->assertEquals(3, $this->root_object->getAmountOfChildren());
204 }

References createSmallTree().

+ Here is the call graph for this function:

◆ testTreeDepth()

ilObjStudyProgrammeTest::testTreeDepth ( )

Test getDepth on ilObjStudyProgramme.

@depends testTreeCreation

Definition at line 268 of file ilObjStudyProgrammeTest.php.

268 {
269 $this->createSmallTree();
270 $children = $this->root_object->getChildren();
271
272 $child = $children[0];
273
274 $this->assertEquals(1, $child->getDepth());
275 }

References createSmallTree().

+ Here is the call graph for this function:

◆ testTreeGetChildren()

ilObjStudyProgrammeTest::testTreeGetChildren ( )

Test function to get children or information about them.

@depends testTreeCreation @depends testGetInstanceByRefId

Definition at line 212 of file ilObjStudyProgrammeTest.php.

212 {
213 $this->createSmallTree();
214
215 $children = $this->root_object->getChildren();
216 $this->assertEquals(3, count($children), "getChildren()");
217
218 $children = ilObjStudyProgramme::getAllChildren($this->root_object_ref_id);
219 $this->assertEquals(4, count($children), "ilObjStudyProgramme::getAllChildren(".$this->root_object_ref_id.")");
220
221 $this->assertTrue($this->root_object->hasChildren(), "hasChildren()");
222 $this->assertEquals(3, $this->root_object->getAmountOfChildren(), "getAmountOfChildren()");
223
224 $this->assertFalse($children[0]->hasChildren(), "hasChildren()");
225 $this->assertEquals(0, $children[0]->getAmountOfChildren(), "getAmountOfChildren()");
226 $this->assertEquals(0, count($children[0]->getChildren()));
227 }

References createSmallTree(), and ilObjStudyProgramme\getAllChildren().

+ Here is the call graph for this function:

◆ testTreeGetParent()

ilObjStudyProgrammeTest::testTreeGetParent ( )

Test getParent on ilObjStudyProgramme.

@depends testTreeCreation

Definition at line 234 of file ilObjStudyProgrammeTest.php.

234 {
235 $this->createSmallTree();
236 $children = $this->root_object->getChildren();
237
238 $child = $children[0];
239 $this->assertNotNull($child->getParent());
240 $this->assertNull($this->root_object->getParent());
241 }

References createSmallTree().

+ Here is the call graph for this function:

◆ testTreeGetParents()

ilObjStudyProgrammeTest::testTreeGetParents ( )

@depends testTreeCreation

Definition at line 246 of file ilObjStudyProgrammeTest.php.

246 {
247 $this->createSmallTree();
249 $children = $this->root_object->getChildren();
250 $children[0]->addNode($node3);
251
252 $parents = $node3->getParents();
253 $parent_ids = array_map(function($node) {
254 return $node->getId();
255 }, $parents);
256 $parent_ids_expected = array( $this->root_object->getId()
257 , $children[0]->getId()
258 );
259
260 $this->assertEquals($parent_ids_expected, $parent_ids);
261 }

References ilObjStudyProgramme\createInstance(), and createSmallTree().

+ Here is the call graph for this function:

◆ testTreeGetRoot()

ilObjStudyProgrammeTest::testTreeGetRoot ( )

Test getRoot on ilObjStudyProgramme.

@depends testTreeCreation

Definition at line 282 of file ilObjStudyProgrammeTest.php.

282 {
283 $this->createSmallTree();
284 $children = $this->root_object->getChildren();
285 $child = $children[0];
286
287 $this->assertEquals($this->root_object->getId(), $child->getRoot()->getId());
288 }

References createSmallTree().

+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilObjStudyProgrammeTest::$backupGlobals = FALSE
protected

Definition at line 35 of file ilObjStudyProgrammeTest.php.


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