ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 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 186 of file ilObjStudyProgrammeTest.php.

186 {
190
191 $this->root_object->addNode($first_node);
192 $this->root_object->addNode($second_node);
193 $this->root_object->addNode($third_node);
194
195 $third_first_node = ilObjStudyProgramme::createInstance();
196 $third_node->addNode($third_first_node);
197 }
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 38 of file ilObjStudyProgrammeTest.php.

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

References $DIC, and ilObjStudyProgramme\createInstance().

+ Here is the call graph for this function:

◆ tearDown()

ilObjStudyProgrammeTest::tearDown ( )
protected

Definition at line 62 of file ilObjStudyProgrammeTest.php.

62 {
63 if ($this->root_object) {
64 $this->root_object->delete();
65 }
66 }

◆ testAddLeaf()

ilObjStudyProgrammeTest::testAddLeaf ( )

Test on addLeaf.

@depends testTreeCreation

Definition at line 389 of file ilObjStudyProgrammeTest.php.

389 {
390 $this->createSmallTree();
391 $mock_leaf = new ilStudyProgrammeLeafMock();
392
393 $children = $this->root_object->getChildren();
394 $first_child = $children[0];
395
396 $first_child->addLeaf($mock_leaf);
397
398 // We use our mock factory, since the original factory won't know how
399 // to create our mock leaf.
400 $first_child->object_factory = new ilObjectFactoryWrapperMock();
401
402 $this->assertEquals(3, $this->root_object->getAmountOfChildren(), "getAmountOfChildren()");
403 // Check if StudyProgrammes are not counted as LP-Children
404 $this->assertEquals(0, $this->root_object->getAmountOfLPChildren(), "getAmountOfLPChildren() on root");
405 $this->assertEquals(false, $this->root_object->hasLPChildren(), "hasLPChildren() on root");
406
407 $this->assertEquals(1, $first_child->getAmountOfLPChildren(), "getAmountOfLPChildren() on first child");
408 $this->assertEquals(true, $first_child->hasLPChildren(), "hasLPChildren() on first child");
409 $this->assertEquals($first_child->getLPMode(), ilStudyProgramme::MODE_LP_COMPLETED);
410
411 $lp_children = $first_child->getLPChildren();
412 $this->assertEquals(1, count($lp_children));
413 $this->assertEquals($mock_leaf->getId(), $lp_children[0]->getId());
414 }
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 ilStudyProgramme\MODE_LP_COMPLETED.

+ Here is the call graph for this function:

◆ testAddNode()

ilObjStudyProgrammeTest::testAddNode ( )

Test on addNode.

@depends testTreeCreation

Definition at line 332 of file ilObjStudyProgrammeTest.php.

332 {
333 $this->createSmallTree();
334
335 $children = $this->root_object->getChildren();
336 $child = $children[0];
337 $grandchild = new ilObjStudyProgramme();
338 $grandchild->create();
339 $child->addNode($grandchild);
340
341 $this->assertEquals($child->getId(), $grandchild->getParent()->getId());
342 $this->assertEquals($this->root_object->getId(), $grandchild->getRoot()->getId(),
343 "Root of grandchild is root of tree.");
344 $this->assertEquals(1, $child->getAmountOfChildren());
345 $this->assertEquals(2, $grandchild->getDepth());
346 $this->assertEquals($child->getLPMode(), ilStudyProgramme::MODE_POINTS);
347 }
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 437 of file ilObjStudyProgrammeTest.php.

437 {
438 $this->createSmallTree();
439 $children = $this->root_object->getChildren();
440 $child_n = $children[0];
441 $child_l = $children[1];
442
443 $mock_leaf1 = new ilStudyProgrammeLeafMock();
444 $mock_leaf2 = new ilStudyProgrammeLeafMock();
445 $node1 = new ilObjStudyProgramme();
446 $node2 = new ilObjStudyProgramme();
447 $node1->create();
448 $node2->create();
449
450 $child_n->addNode($node1);
451 $child_l->addLeaf($mock_leaf1);
452
453 $raised = false;
454 try {
455 $child_n->addLeaf($mock_leaf2);
456 }
458 $raised = true;
459 }
460 $this->assertTrue($raised, "Could add leaf to program containing node.");
461
462 $raised = false;
463 try {
464 $child_n->addLeaf($mock_leaf2);
465 }
467 $raised = true;
468 }
469 $this->assertTrue($raised, "Could add node to program containing leaf.");
470 }
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 298 of file ilObjStudyProgrammeTest.php.

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

References createSmallTree(), and ilStudyProgramme\DEFAULT_POINTS.

+ Here is the call graph for this function:

◆ testCanRemoveNodeWithNotRelevantProgress()

ilObjStudyProgrammeTest::testCanRemoveNodeWithNotRelevantProgress ( )

Definition at line 526 of file ilObjStudyProgrammeTest.php.

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

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

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

References createSmallTree(), and ilStudyProgramme\STATUS_ACTIVE.

+ Here is the call graph for this function:

◆ testCreatableSubObjectsRaisesOnNonProgramRef()

ilObjStudyProgrammeTest::testCreatableSubObjectsRaisesOnNonProgramRef ( )

@expectedException ilException

Definition at line 590 of file ilObjStudyProgrammeTest.php.

590 {
592 }
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 578 of file ilObjStudyProgrammeTest.php.

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

References ilObjStudyProgramme\getCreatableSubObjects().

+ Here is the call graph for this function:

◆ testCreateableSubObjects()

ilObjStudyProgrammeTest::testCreateableSubObjects ( )

Definition at line 542 of file ilObjStudyProgrammeTest.php.

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

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

+ Here is the call graph for this function:

◆ testCreatePermissionExists()

ilObjStudyProgrammeTest::testCreatePermissionExists ( )

Definition at line 608 of file ilObjStudyProgrammeTest.php.

608 {
609 // Ask for permission id for creation of "foobar" to check assumption
610 // that lookupCreateOperationIds just drops unknown object types.
611 $op_ids = ilRbacReview::lookupCreateOperationIds(array("prg", "foobar"));
612 $this->assertCount(1, $op_ids);
613 }
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 71 of file ilObjStudyProgrammeTest.php.

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

◆ testDefaults()

ilObjStudyProgrammeTest::testDefaults ( )

Definition at line 81 of file ilObjStudyProgrammeTest.php.

81 {
82 $this->assertEquals($this->root_object->getStatus(), ilStudyProgramme::STATUS_DRAFT);
83 }

References ilStudyProgramme\STATUS_DRAFT.

◆ testDelete()

ilObjStudyProgrammeTest::testDelete ( )

Test deletion of a ilObjStudyProgramme.

@depends testCreation

Definition at line 177 of file ilObjStudyProgrammeTest.php.

177 {
178 $deleted_object = ilObjStudyProgramme::getInstanceByRefId($this->root_object_ref_id);
179
180 $this->assertTrue($deleted_object->delete());
181 }
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 594 of file ilObjStudyProgrammeTest.php.

594 {
595 $this->root_object->delete();
596 $this->root_object = null;
597
598 global $DIC;
599 $ilDB = $DIC['ilDB'];
600 $res = $ilDB->query( "SELECT COUNT(*) cnt "
602 ." WHERE obj_id = ".$this->root_object_obj_id
603 );
604 $rec = $ilDB->fetchAssoc($res);
605 $this->assertEquals(0, $rec["cnt"]);
606 }
global $ilDB

References $DIC, $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 131 of file ilObjStudyProgrammeTest.php.

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

References $orig, 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 90 of file ilObjStudyProgrammeTest.php.

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

References $orig, 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 111 of file ilObjStudyProgrammeTest.php.

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

References $orig, and IL_CAL_DATETIME.

◆ testMoveTo()

ilObjStudyProgrammeTest::testMoveTo ( )

Test on moveTo.

Definition at line 475 of file ilObjStudyProgrammeTest.php.

475 {
476 $this->createSmallTree();
477 $children = $this->root_object->getChildren();
478 $child_l = $children[0];
479 $child_r = $children[1];
480 $child_m = $children[2];
481
482 $child_r->moveTo($child_l);
483
484 $this->assertEquals(2, $child_r->getDepth());
485 $this->assertEquals($child_l->getId(), $child_r->getParent()->getId());
486 $this->assertEquals(2, $this->root_object->getAmountOfChildren());
487 $this->assertEquals(1, $child_l->getAmountOfChildren());
488
489 // test recursive moving
490 $this->assertEquals(1, $child_m->getAmountOfChildren());
491
492 $child_m->moveTo($child_r);
493
494 $m_children = $child_m->getChildren();
495 $first_third_node = $m_children[0];
496
497 $this->assertEquals(3, $child_m->getDepth());
498 $this->assertEquals(1, $child_m->getAmountOfChildren());
499 $this->assertNotNull($first_third_node);
500 $this->assertEquals(4, $first_third_node->getDepth());
501 $this->assertEquals($child_m->getId(), $first_third_node->getParent()->getId());
502
503 $this->assertEquals(1, $this->root_object->getAmountOfChildren());
504 $this->assertEquals(3, count(ilObjStudyProgramme::getAllChildren($child_l->getRefId())));
505 }
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 421 of file ilObjStudyProgrammeTest.php.

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

◆ testRemoveNode()

ilObjStudyProgrammeTest::testRemoveNode ( )

Test on removeNode.

@depends testTreeCreation

Definition at line 354 of file ilObjStudyProgrammeTest.php.

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

References createSmallTree().

+ Here is the call graph for this function:

◆ testSettings()

ilObjStudyProgrammeTest::testSettings ( )

Test tings on ilObjStudyProgramme.

@depends testCreation

Definition at line 156 of file ilObjStudyProgrammeTest.php.

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

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

204 {
205 $this->createSmallTree();
206 $this->assertEquals(3, $this->root_object->getAmountOfChildren());
207 }

References createSmallTree().

+ Here is the call graph for this function:

◆ testTreeDepth()

ilObjStudyProgrammeTest::testTreeDepth ( )

Test getDepth on ilObjStudyProgramme.

@depends testTreeCreation

Definition at line 271 of file ilObjStudyProgrammeTest.php.

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

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

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

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

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

References createSmallTree().

+ Here is the call graph for this function:

◆ testTreeGetParents()

ilObjStudyProgrammeTest::testTreeGetParents ( )

@depends testTreeCreation

Definition at line 249 of file ilObjStudyProgrammeTest.php.

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

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

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

References createSmallTree().

+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilObjStudyProgrammeTest::$backupGlobals = FALSE
protected

Definition at line 36 of file ilObjStudyProgrammeTest.php.


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