ILIAS  release_7 Revision v7.30-3-g800a261c036
ilObjStudyProgrammeTest Class Reference

TestCase for the ilObjStudyProgramme @group needsInstalledILIAS. 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 settings 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...
 
 testTreeGetAllPrgChildren ()
 
 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 261 of file ilObjStudyProgrammeTest.php.

262 {
266
267 $this->root_object->addNode($first_node);
268 $this->root_object->addNode($second_node);
269 $this->root_object->addNode($third_node);
270
271 $third_first_node = ilObjStudyProgramme::createInstance();
272 $third_node->addNode($third_first_node);
273 }
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(), testTreeGetAllPrgChildren(), 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 41 of file ilObjStudyProgrammeTest.php.

41 : void
42 {
43 require_once("./Modules/StudyProgramme/classes/class.ilObjStudyProgramme.php");
44 PHPUnit\Framework\Error\Deprecated::$enabled = false;
45
46 global $DIC;
47 if (!$DIC) {
48 try {
49 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
50 ilUnitUtil::performInitialisation();
51 } catch (Exception $e) {
52 }
53 }
54
55 $this->root_object = ilObjStudyProgramme::createInstance();
56 $this->root_object_obj_id = $this->root_object->getId();
57 $this->root_object_ref_id = $this->root_object->getRefId();
58 $this->root_object->putInTree(ROOT_FOLDER_ID);
59
60 global $DIC;
61 $tree = $DIC['tree'];
62 $this->tree = $tree;
63
64 $objDefinition = $DIC['objDefinition'];
65 $this->obj_definition = $objDefinition;
66 }
const ROOT_FOLDER_ID
Definition: constants.php:30
global $DIC
Definition: goto.php:24

References $DIC, Vendor\Package\$e, ilObjStudyProgramme\createInstance(), and ROOT_FOLDER_ID.

+ Here is the call graph for this function:

◆ tearDown()

ilObjStudyProgrammeTest::tearDown ( )
protected

Definition at line 68 of file ilObjStudyProgrammeTest.php.

68 : void
69 {
70 if ($this->root_object) {
71 $this->root_object->delete();
72 }
73 }

◆ testAddLeaf()

ilObjStudyProgrammeTest::testAddLeaf ( )

Test on addLeaf.

@depends testTreeCreation

Definition at line 484 of file ilObjStudyProgrammeTest.php.

485 {
486 $this->createSmallTree();
487 $mock_leaf = new ilStudyProgrammeLeafMock();
488
489 $children = $this->root_object->getChildren();
490 $first_child = $children[0];
491
492 $first_child->addLeaf($mock_leaf);
493
494 // We use our mock factory, since the original factory won't know how
495 // to create our mock leaf.
496 $first_child->object_factory = new ilObjectFactoryWrapperMock();
497
498 $this->assertEquals(3, $this->root_object->getAmountOfChildren(), "getAmountOfChildren()");
499 // Check if StudyProgrammes are not counted as LP-Children
500 $this->assertEquals(0, $this->root_object->getAmountOfLPChildren(), "getAmountOfLPChildren() on root");
501 $this->assertEquals(false, $this->root_object->hasLPChildren(), "hasLPChildren() on root");
502
503 $this->assertEquals(1, $first_child->getAmountOfLPChildren(), "getAmountOfLPChildren() on first child");
504 $this->assertEquals(true, $first_child->hasLPChildren(), "hasLPChildren() on first child");
505 $this->assertEquals($first_child->getLPMode(), ilStudyProgrammeSettings::MODE_LP_COMPLETED);
506
507 $lp_children = $first_child->getLPChildren();
508 $this->assertEquals(1, count($lp_children));
509 $this->assertEquals($mock_leaf->getId(), $lp_children[0]->getId());
510 }
createSmallTree()
Creates a small tree, used by various tests.
Mock for object factory.
Definition: mocks.php:69
Mock classes for tests.
Definition: mocks.php:21

References createSmallTree(), and ilStudyProgrammeSettings\MODE_LP_COMPLETED.

+ Here is the call graph for this function:

◆ testAddNode()

ilObjStudyProgrammeTest::testAddNode ( )

Test on addNode.

@depends testTreeCreation

Definition at line 424 of file ilObjStudyProgrammeTest.php.

425 {
426 $this->createSmallTree();
427
428 $children = $this->root_object->getChildren();
429 $child = $children[0];
430 $grandchild = new ilObjStudyProgramme();
431 $grandchild->create();
432 $child->addNode($grandchild);
433
434 $this->assertEquals($child->getId(), $grandchild->getParent()->getId());
435 $this->assertEquals(
436 $this->root_object->getId(),
437 $grandchild->getRoot()->getId(),
438 "Root of grandchild is root of tree."
439 );
440 $this->assertEquals(1, $child->getAmountOfChildren());
441 $this->assertEquals(2, $grandchild->getDepth());
442 $this->assertEquals($child->getLPMode(), ilStudyProgrammeSettings::MODE_POINTS);
443 }

References createSmallTree(), and ilStudyProgrammeSettings\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 534 of file ilObjStudyProgrammeTest.php.

535 {
536 $this->createSmallTree();
537 $children = $this->root_object->getChildren();
538 $child_n = $children[0];
539 $child_l = $children[1];
540
541 $mock_leaf1 = new ilStudyProgrammeLeafMock();
542 $mock_leaf2 = new ilStudyProgrammeLeafMock();
543 $node1 = new ilObjStudyProgramme();
544 $node2 = new ilObjStudyProgramme();
545 $node1->create();
546 $node2->create();
547
548 $child_n->addNode($node1);
549 $child_l->addLeaf($mock_leaf1);
550
551 $raised = false;
552 try {
553 $child_n->addLeaf($mock_leaf2);
555 $raised = true;
556 }
557 $this->assertTrue($raised, "Could add leaf to program containing node.");
558
559 $raised = false;
560 try {
561 $child_n->addLeaf($mock_leaf2);
563 $raised = true;
564 }
565 $this->assertTrue($raised, "Could add node to program containing leaf.");
566 }
Exception is thrown when invariants on the program tree would be violated by manipulation of tree.

References Vendor\Package\$e, and createSmallTree().

+ Here is the call graph for this function:

◆ testApplyToSubTreeNodes()

ilObjStudyProgrammeTest::testApplyToSubTreeNodes ( )

Test applyToSubTreeNodes on ilObjStudyProgramme.

@depends testTreeCreation

Definition at line 389 of file ilObjStudyProgrammeTest.php.

390 {
391 $this->createSmallTree();
392 $children = $this->root_object->getChildren();
393
394 $val = 0;
395 $this->root_object->applyToSubTreeNodes(function ($node) use (&$val) {
396 $val += $node->getPoints();
397 });
398
399 // We didn't make modification on the points of the nodes.
400 $this->assertEquals($val, 5 * ilStudyProgrammeSettings::DEFAULT_POINTS);
401
402
403 $this->root_object->setPoints(1);
404 $children[0]->setPoints(2);
405 $children[1]->setPoints(4);
406 $children[2]->setPoints(1);
407
408 $third_level = $children[2]->getChildren();
409 $third_level[0]->setPoints(2);
410
411 $val = 0;
412 $this->root_object->applyToSubTreeNodes(function ($node) use (&$val) {
413 $val += $node->getPoints();
414 });
415
416 $this->assertEquals($val, 10);
417 }

References createSmallTree(), and ilStudyProgrammeSettings\DEFAULT_POINTS.

+ Here is the call graph for this function:

◆ testCanRemoveNodeWithNotRelevantProgress()

ilObjStudyProgrammeTest::testCanRemoveNodeWithNotRelevantProgress ( )

Definition at line 624 of file ilObjStudyProgrammeTest.php.

625 {
626 $this->createSmallTree();
627 $children = $this->root_object->getChildren();
628 $child_l = $children[0];
629 $child_r = $children[1];
630 $this->root_object->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE);
631 $child_l->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE);
633
634 $user = new ilObjUser();
635 $user->create();
636
637 $this->root_object->assignUser($user->getId(), 6);
638 $this->root_object->removeNode($child_r);
639 }

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

+ Here is the call graph for this function:

◆ testCantRemoveNodeWithRelevantProgress()

ilObjStudyProgrammeTest::testCantRemoveNodeWithRelevantProgress ( )

@expectedException ilStudyProgrammeTreeException

Definition at line 607 of file ilObjStudyProgrammeTest.php.

608 {
609 $this->createSmallTree();
610 $children = $this->root_object->getChildren();
611 $child_l = $children[0];
612 $child_r = $children[1];
613 $this->root_object->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE);
614 $child_l->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE);
615 $child_r->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE);
616
617 $user = new ilObjUser();
618 $user->create();
619
620 $child_l->assignUser($user->getId(), 6);
621 $this->root_object->removeNode($child_l);
622 }

References createSmallTree(), and ilStudyProgrammeSettings\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testCreatableSubObjectsRaisesOnNonProgramRef()

ilObjStudyProgrammeTest::testCreatableSubObjectsRaisesOnNonProgramRef ( )

@expectedException ilException

Definition at line 692 of file ilObjStudyProgrammeTest.php.

693 {
695 }
static getCreatableSubObjects(array $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 678 of file ilObjStudyProgrammeTest.php.

679 {
680 $all_possible_subobjects = $this->obj_definition->getSubObjects("prg");
681 // don't take rolfs into account, we don't need rolf anymore
682 unset($all_possible_subobjects["rolf"]);
683 $this->assertEquals(
684 $all_possible_subobjects,
685 ilObjStudyProgramme::getCreatableSubObjects($all_possible_subobjects, null)
686 );
687 }

References ilObjStudyProgramme\getCreatableSubObjects().

+ Here is the call graph for this function:

◆ testCreateableSubObjects()

ilObjStudyProgrammeTest::testCreateableSubObjects ( )

Definition at line 641 of file ilObjStudyProgrammeTest.php.

642 {
643 $this->createSmallTree();
644 $children = $this->root_object->getChildren();
645 $child_l = $children[0];
646
647 $all_possible_subobjects = $this->root_object->getPossibleSubObjects();
648 // don't take rolfs into account, we don't need rolf anymore
649 unset($all_possible_subobjects["rolf"]);
650
651 // this is course reference and training programme
652 $this->assertCount(3, $all_possible_subobjects);
653 $this->assertArrayHasKey("prg", $all_possible_subobjects);
654 $this->assertArrayHasKey("crsr", $all_possible_subobjects);
655 $this->assertArrayHasKey("prgr", $all_possible_subobjects);
656 // root already contains program nodes, so course ref is forbidden
657 $subobjs = ilObjStudyProgramme::getCreatableSubObjects($all_possible_subobjects, $this->root_object->getRefId());
658 $this->assertCount(2, $subobjs);
659 $this->assertArrayHasKey("prg", $subobjs);
660 $this->assertArrayHasKey("prgr", $all_possible_subobjects);
661 // first node contains nothing, so course ref and program node are allowed
662 $subobjs = ilObjStudyProgramme::getCreatableSubObjects($all_possible_subobjects, $child_l->getRefId());
663 $this->assertCount(3, $subobjs);
664 $this->assertArrayHasKey("prg", $subobjs);
665 $this->assertArrayHasKey("crsr", $subobjs);
666 $this->assertArrayHasKey("prgr", $all_possible_subobjects);
667 $mock_leaf = new ilStudyProgrammeLeafMock();
668 $children = $this->root_object->getChildren();
669 $child_l->object_factory = new ilObjectFactoryWrapperMock();
670 $child_l->addLeaf($mock_leaf);
671
672 // Now we added a leaf, so no program nodes are allowed anymore.
673 $subobjs = ilObjStudyProgramme::getCreatableSubObjects($all_possible_subobjects, $child_l->getRefId());
674 $this->assertCount(1, $subobjs);
675 $this->assertArrayHasKey("crsr", $subobjs);
676 }

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

+ Here is the call graph for this function:

◆ testCreatePermissionExists()

ilObjStudyProgrammeTest::testCreatePermissionExists ( )

Definition at line 713 of file ilObjStudyProgrammeTest.php.

714 {
715 // Ask for permission id for creation of "foobar" to check assumption
716 // that lookupCreateOperationIds just drops unknown object types.
717 $op_ids = ilRbacReview::lookupCreateOperationIds(array("prg", "foobar"));
718 $this->assertCount(1, $op_ids);
719 }
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 78 of file ilObjStudyProgrammeTest.php.

79 {
80 $this->assertNotEmpty($this->root_object_obj_id);
81 $this->assertGreaterThan(0, $this->root_object_obj_id);
82
83 $this->assertNotEmpty($this->root_object_ref_id);
84 $this->assertGreaterThan(0, $this->root_object_ref_id);
85
86 $this->assertTrue($this->tree->isInTree($this->root_object_ref_id));
87 }

◆ testDefaults()

ilObjStudyProgrammeTest::testDefaults ( )

Definition at line 89 of file ilObjStudyProgrammeTest.php.

90 {
91 $this->assertEquals($this->root_object->getStatus(), ilStudyProgrammeSettings::STATUS_DRAFT);
92 }

References ilStudyProgrammeSettings\STATUS_DRAFT.

◆ testDelete()

ilObjStudyProgrammeTest::testDelete ( )

Test deletion of a ilObjStudyProgramme.

@depends testCreation

Definition at line 251 of file ilObjStudyProgrammeTest.php.

252 {
253 $deleted_object = ilObjStudyProgramme::getInstanceByRefId($this->root_object_ref_id);
254
255 $this->assertTrue($deleted_object->delete());
256 }
static getInstanceByRefId($a_ref_id)

References ilObjStudyProgramme\getInstanceByRefId().

+ Here is the call graph for this function:

◆ testDeleteRemovesEntriesInPrgSettings()

ilObjStudyProgrammeTest::testDeleteRemovesEntriesInPrgSettings ( )

Definition at line 697 of file ilObjStudyProgrammeTest.php.

698 {
699 $this->root_object->delete();
700 $this->root_object = null;
701
702 global $DIC;
703 $ilDB = $DIC['ilDB'];
704 $res = $ilDB->query(
705 "SELECT COUNT(*) cnt "
707 . " WHERE obj_id = " . $this->root_object_obj_id
708 );
709 $rec = $ilDB->fetchAssoc($res);
710 $this->assertEquals(0, $rec["cnt"]);
711 }
foreach($_POST as $key=> $value) $res
global $ilDB

References $DIC, $ilDB, $res, and ilStudyProgrammeSettingsDBRepository\TABLE.

◆ testGetInstanceByRefId()

ilObjStudyProgrammeTest::testGetInstanceByRefId ( )

Test loading over getInstance.

@depends testCreation

Definition at line 144 of file ilObjStudyProgrammeTest.php.

145 {
146 require_once("Modules/StudyProgramme/classes/class.ilObjStudyProgrammeCache.php");
147
149 $this->assertTrue(ilObjStudyProgrammeCache::singleton()->test_isEmpty());
150
151 $loaded = ilObjStudyProgramme::getInstanceByRefId($this->root_object_ref_id);
152 $orig = $this->root_object;
153
154 $this->assertNotNull($loaded);
155 $this->assertGreaterThan(0, $loaded->getId());
156 $this->assertEquals($orig->getId(), $loaded->getId());
157 $this->assertEquals(
158 $orig->getLastChange()->format('YmdHis'),
159 $loaded->getLastChange()->format('YmdHis')
160 );
161 $this->assertEquals($orig->getPoints(), $loaded->getPoints());
162 $this->assertEquals($orig->getLPMode(), $loaded->getLPMode());
163 $this->assertEquals($orig->getStatus(), $loaded->getStatus());
164 }

References ilObjStudyProgramme\getInstanceByRefId(), 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 99 of file ilObjStudyProgrammeTest.php.

100 {
101 $loaded = new ilObjStudyProgramme($this->root_object_obj_id, false);
102 $orig = $this->root_object;
103 $load_ref_id = ilObjStudyProgramme::getInstanceByRefId($this->root_object_ref_id);
104
105 $this->assertNotNull($loaded);
106 $this->assertGreaterThan(0, $loaded->getId());
107 $this->assertEquals($orig->getId(), $loaded->getId());
108 $this->assertEquals(
109 $orig->getLastChange()->format('YmdHis'),
110 $loaded->getLastChange()->format('YmdHis')
111 );
112 $this->assertEquals($orig->getPoints(), $loaded->getPoints());
113 $this->assertEquals($orig->getLPMode(), $loaded->getLPMode());
114 $this->assertEquals($orig->getStatus(), $loaded->getStatus());
115 }

References ilObjStudyProgramme\getInstanceByRefId().

+ Here is the call graph for this function:

◆ testLoadByRefId()

ilObjStudyProgrammeTest::testLoadByRefId ( )

Test loading of ilObjStudyProgramme with ref_id.

@depends testCreation

Definition at line 122 of file ilObjStudyProgrammeTest.php.

123 {
124 $loaded = new ilObjStudyProgramme($this->root_object_ref_id);
125 $orig = $this->root_object;
126
127 $this->assertNotNull($loaded);
128 $this->assertGreaterThan(0, $loaded->getId());
129 $this->assertEquals($orig->getId(), $loaded->getId());
130 $this->assertEquals(
131 $orig->getLastChange()->format('YmdHis'),
132 $loaded->getLastChange()->format('YmdHis')
133 );
134 $this->assertEquals($orig->getPoints(), $loaded->getPoints());
135 $this->assertEquals($orig->getLPMode(), $loaded->getLPMode());
136 $this->assertEquals($orig->getStatus(), $loaded->getStatus());
137 }

◆ testMoveTo()

ilObjStudyProgrammeTest::testMoveTo ( )

Test on moveTo.

Definition at line 571 of file ilObjStudyProgrammeTest.php.

572 {
573 $this->createSmallTree();
574 $children = $this->root_object->getChildren();
575 $child_l = $children[0];
576 $child_r = $children[1];
577 $child_m = $children[2];
578
579 $child_r->moveTo($child_l);
580
581 $this->assertEquals(2, $child_r->getDepth());
582 $this->assertEquals($child_l->getId(), $child_r->getParent()->getId());
583 $this->assertEquals(2, $this->root_object->getAmountOfChildren());
584 $this->assertEquals(1, $child_l->getAmountOfChildren());
585
586 // test recursive moving
587 $this->assertEquals(1, $child_m->getAmountOfChildren());
588
589 $child_m->moveTo($child_r);
590
591 $m_children = $child_m->getChildren();
592 $first_third_node = $m_children[0];
593
594 $this->assertEquals(3, $child_m->getDepth());
595 $this->assertEquals(1, $child_m->getAmountOfChildren());
596 $this->assertNotNull($first_third_node);
597 $this->assertEquals(4, $first_third_node->getDepth());
598 $this->assertEquals($child_m->getId(), $first_third_node->getParent()->getId());
599
600 $this->assertEquals(1, $this->root_object->getAmountOfChildren());
601 $this->assertEquals(3, count(ilObjStudyProgramme::getAllChildren($child_l->getRefId())));
602 }
static getAllChildren(int $a_ref_id, bool $include_references=false)
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 517 of file ilObjStudyProgrammeTest.php.

518 {
519 $mock_leaf = new ilStudyProgrammeLeafMock();
520 $this->root_object->addLeaf($mock_leaf);
521
522 $this->root_object->removeLeaf($mock_leaf);
523 $this->assertEquals(0, $this->root_object->getAmountOfChildren(), "getAmountOfChildren()");
524 $this->assertEquals(0, $this->root_object->getAmountOfLPChildren(), "getAmountOfLPChildren()");
525
526 $lp_children = $this->root_object->getLPChildren();
527 $this->assertEquals(0, count($lp_children));
528 }

◆ testRemoveNode()

ilObjStudyProgrammeTest::testRemoveNode ( )

Test on removeNode.

@depends testTreeCreation

Definition at line 450 of file ilObjStudyProgrammeTest.php.

451 {
452 $this->createSmallTree();
453
454 $children = $this->root_object->getChildren();
455 $child = $children[0];
456 $this->root_object->removeNode($child);
457
458 // Is not in tree anymore...
459 $raised = false;
460 try {
461 $child->getParent();
463 $raised = true;
464 }
465 $this->assertTrue($raised, "Child does not raise on getParent after it is removed.");
466
467 $this->assertEquals(2, $this->root_object->getAmountOfChildren());
468
469 // Can't be removed a second time...
470 $raised = false;
471 try {
472 $this->root_object->removeNode($child);
474 $raised = true;
475 }
476 $this->assertTrue($raised, "Child can be removed two times.");
477 }

References Vendor\Package\$e, and createSmallTree().

+ Here is the call graph for this function:

◆ testSettings()

ilObjStudyProgrammeTest::testSettings ( )

Test settings on ilObjStudyProgramme.

@depends testCreation

Definition at line 171 of file ilObjStudyProgrammeTest.php.

172 {
173 $date = new DateTime();
174 $obj = ilObjStudyProgramme::getInstanceByRefId($this->root_object_ref_id);
175
176 $assessment_settings = $obj->getAssessmentSettings();
177 $auto_mail_settings = $obj->getAutoMailSettings();
178 $validity_of_qualification_settings = $obj->getValidityOfQualificationSettings();
179 $deadline_settings = $obj->getDeadlineSettings();
180 $type_settings = $obj->getTypeSettings();
181
182 $this->assertInstanceOf(ilStudyProgrammeAssessmentSettings::class, $assessment_settings);
183 $this->assertInstanceOf(ilStudyProgrammeAutoMailSettings::class, $auto_mail_settings);
184 $this->assertInstanceOf(
185 ilStudyProgrammeValidityOfAchievedQualificationSettings::class,
186 $validity_of_qualification_settings
187 );
188 $this->assertInstanceOf(ilStudyProgrammeDeadlineSettings::class, $deadline_settings);
189 $this->assertInstanceOf(ilStudyProgrammeTypeSettings::class, $type_settings);
190
191 $assessment_settings = $assessment_settings
193 ->withPoints(10)
194 ;
195
196 $auto_mail_settings = $auto_mail_settings
197 ->withProcessingEndsNotSuccessfulDays(10)
198 ->withReminderNotRestartedByUserDays(10)
199 ->withSendReAssignedMail(true)
200 ;
201
202 $validity_of_qualification_settings = $validity_of_qualification_settings
203 ->withRestartPeriod(10)
204 ->withQualificationPeriod(10)
205 ->withQualificationDate($date)
206 ;
207
208 $deadline_settings = $deadline_settings
209 ->withDeadlinePeriod(10)
210 ->withDeadlineDate($date)
211 ;
212
213 $type_settings = $type_settings->withTypeId(10);
214
215 $obj->setAssessmentSettings($assessment_settings);
216 $obj->setAutoMailSettings($auto_mail_settings);
217 $obj->setValidityOfQualificationSettings($validity_of_qualification_settings);
218 $obj->setDeadlineSettings($deadline_settings);
219 $obj->setTypeSettings($type_settings);
220 $obj->update();
221
222 $obj = ilObjStudyProgramme::getInstanceByRefId($this->root_object_ref_id);
223
224 $assessment_settings = $obj->getAssessmentSettings();
225 $auto_mail_settings = $obj->getAutoMailSettings();
226 $validity_of_qualification_settings = $obj->getValidityOfQualificationSettings();
227 $deadline_settings = $obj->getDeadlineSettings();
228 $type_settings = $obj->getTypeSettings();
229
230 $this->assertEquals(
232 $assessment_settings->getStatus()
233 );
234 $this->assertEquals(10, $assessment_settings->getPoints());
235 $this->assertEquals(10, $auto_mail_settings->getProcessingEndsNotSuccessfulDays());
236 $this->assertEquals(10, $auto_mail_settings->getReminderNotRestartedByUserDays());
237 $this->assertTrue($auto_mail_settings->getSendReAssignedMail());
238 $this->assertEquals(10, $validity_of_qualification_settings->getRestartPeriod());
239 $this->assertEquals(10, $validity_of_qualification_settings->getQualificationPeriod());
240 $this->assertSame($date, $validity_of_qualification_settings->getQualificationDate());
241 $this->assertEquals(10, $deadline_settings->getDeadlinePeriod());
242 $this->assertSame($date, $deadline_settings->getDeadlineDate());
243 $this->assertEquals(10, $type_settings->getTypeId());
244 }

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

+ Here is the call graph for this function:

◆ testTreeCreation()

ilObjStudyProgrammeTest::testTreeCreation ( )

Test creating a small tree.

@depends testCreation

Definition at line 280 of file ilObjStudyProgrammeTest.php.

281 {
282 $this->createSmallTree();
283 $this->assertEquals(3, $this->root_object->getAmountOfChildren());
284 }

References createSmallTree().

+ Here is the call graph for this function:

◆ testTreeDepth()

ilObjStudyProgrammeTest::testTreeDepth ( )

Test getDepth on ilObjStudyProgramme.

@depends testTreeCreation

Definition at line 360 of file ilObjStudyProgrammeTest.php.

361 {
362 $this->createSmallTree();
363 $children = $this->root_object->getChildren();
364
365 $child = $children[0];
366
367 $this->assertEquals(1, $child->getDepth());
368 }

References createSmallTree().

+ Here is the call graph for this function:

◆ testTreeGetAllPrgChildren()

ilObjStudyProgrammeTest::testTreeGetAllPrgChildren ( )

Definition at line 310 of file ilObjStudyProgrammeTest.php.

311 {
312 $this->createSmallTree();
313 $this->assertEquals(
314 4,
315 $this->root_object->getAllPrgChildren()
316 );
317 }

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 292 of file ilObjStudyProgrammeTest.php.

293 {
294 $this->createSmallTree();
295
296 $children = $this->root_object->getChildren();
297 $this->assertEquals(3, count($children), "getChildren()");
298
299 $children = ilObjStudyProgramme::getAllChildren($this->root_object_ref_id);
300 $this->assertEquals(4, count($children), "ilObjStudyProgramme::getAllChildren(" . $this->root_object_ref_id . ")");
301
302 $this->assertTrue($this->root_object->hasChildren(), "hasChildren()");
303 $this->assertEquals(3, $this->root_object->getAmountOfChildren(), "getAmountOfChildren()");
304
305 $this->assertFalse($children[0]->hasChildren(), "hasChildren()");
306 $this->assertEquals(0, $children[0]->getAmountOfChildren(), "getAmountOfChildren()");
307 $this->assertEquals(0, count($children[0]->getChildren()));
308 }

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 324 of file ilObjStudyProgrammeTest.php.

325 {
326 $this->createSmallTree();
327 $children = $this->root_object->getChildren();
328
329 $child = $children[0];
330 $this->assertNotNull($child->getParent());
331 $this->assertNull($this->root_object->getParent());
332 }

References createSmallTree().

+ Here is the call graph for this function:

◆ testTreeGetParents()

ilObjStudyProgrammeTest::testTreeGetParents ( )

@depends testTreeCreation

Definition at line 337 of file ilObjStudyProgrammeTest.php.

338 {
339 $this->createSmallTree();
341 $children = $this->root_object->getChildren();
342 $children[0]->addNode($node3);
343
344 $parents = $node3->getParents();
345 $parent_ids = array_map(function ($node) {
346 return $node->getId();
347 }, $parents);
348 $parent_ids_expected = array( $this->root_object->getId()
349 , $children[0]->getId()
350 );
351
352 $this->assertEquals($parent_ids_expected, $parent_ids);
353 }

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 375 of file ilObjStudyProgrammeTest.php.

376 {
377 $this->createSmallTree();
378 $children = $this->root_object->getChildren();
379 $child = $children[0];
380
381 $this->assertEquals($this->root_object->getId(), $child->getRoot()->getId());
382 }

References createSmallTree().

+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilObjStudyProgrammeTest::$backupGlobals = false
protected

Definition at line 39 of file ilObjStudyProgrammeTest.php.


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