ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilStudyProgrammeAssignmentTest.php
Go to the documentation of this file.
1<?php
2
6class ilStudyProgrammeAssignmentTest extends \PHPUnit\Framework\TestCase
7{
8 protected $backupGlobals = false;
9
10 public function setUp() : void
11 {
12 PHPUnit_Framework_Error_Deprecated::$enabled = false;
13
14 global $DIC;
15 if (!$DIC) {
16 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
17 try {
18 ilUnitUtil::performInitialisation();
19 } catch (\Exception $e) {
20 }
21 }
22 }
23
24 public function test_init_and_id()
25 {
26 $spa = new ilStudyProgrammeAssignment(123);
27 $this->assertEquals($spa->getId(), 123);
28 return $spa;
29 }
30
34 public function test_root_id()
35 {
36 $spa = (new ilStudyProgrammeAssignment(123))->setRootId(321);
37 $this->assertEquals($spa->getRootId(), 321);
38 }
39
43 public function test_user_id()
44 {
45 $spa = (new ilStudyProgrammeAssignment(123))->setUserId(321);
46 $this->assertEquals($spa->getUserId(), 321);
47 }
48
52 public function test_last_change_by()
53 {
54 $spa = (new ilStudyProgrammeAssignment(123))->setLastChangeBy(6);
55 $this->assertEquals($spa->getLastChangeBy(), 6);
56 }
57
63 {
64 $spa = (new ilStudyProgrammeAssignment(123))->setLastChangeBy(-55);
65 }
66
70 public function test_last_change()
71 {
72 $dl = new DateTime();
73 $spa = (new ilStudyProgrammeAssignment(123))->setLastChange($dl);
74 $this->assertEquals($spa->getLastChange()->format('Y-m-d H:i:s'), $dl->format('Y-m-d H:i:s'));
75 }
76
80 public function test_restart_date()
81 {
82 $dl = DateTime::createFromFormat('Ymd', '20201001');
83 $spa = (new ilStudyProgrammeAssignment(123))->setRestartDate($dl);
84 $this->assertEquals($spa->getRestartDate()->format('Ymd'), '20201001');
85 }
86
87
91 public function test_restarted_assigment()
92 {
93 $spa = new ilStudyProgrammeAssignment(123);
94 $this->assertEquals($spa->getRestartedAssignmentId(), ilStudyProgrammeAssignment::NO_RESTARTED_ASSIGNMENT);
95 $this->assertEquals($spa->setRestartedAssignmentId(321)->getRestartedAssignmentId(), 321);
96 }
97}
An exception for terminatinating execution or to throw for unit testing.
test_last_change_by()
@depends test_init_and_id
test_restarted_assigment()
@depends test_init_and_id
test_last_change_by_invalid()
@depends test_init_and_id @expectedException ilException
Class ilStudyProgrammeAssignment.
$DIC
Definition: xapitoken.php:46