ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilStudyProgrammeProgressTest.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2
3class ilStudyProgrammeProgressTest extends \PHPUnit\Framework\TestCase
4{
5 public function test_init_and_id()
6 {
7 $spp = new ilStudyProgrammeProgress(123);
8 $this->assertEquals($spp->getId(), 123);
9 return $spp;
10 }
11
15 public function test_assignment_id()
16 {
17 $spp = (new ilStudyProgrammeProgress(123))->setAssignmentId(321);
18 $this->assertEquals($spp->getAssignmentId(), 321);
19 }
20
24 public function test_node_id()
25 {
26 $spp = (new ilStudyProgrammeProgress(123))->setNodeId(321);
27 $this->assertEquals($spp->getNodeId(), 321);
28 }
29
33 public function test_user_id()
34 {
35 $spp = (new ilStudyProgrammeProgress(123))->setUserId(321);
36 $this->assertEquals($spp->getUserId(), 321);
37 }
38
42 public function test_amount_of_points()
43 {
44 $spp = (new ilStudyProgrammeProgress(123))->setAmountOfPoints(321);
45 $this->assertEquals($spp->getAmountOfPoints(), 321);
46 }
47
52 {
53 $this->expectException(\ilException::class);
54 $spp = (new ilStudyProgrammeProgress(123))->setAmountOfPoints(-321);
55 }
56
61 {
62 $spp = (new ilStudyProgrammeProgress(123))->setCurrentAmountOfPoints(321);
63 $this->assertEquals($spp->getCurrentAmountOfPoints(), 321);
64 }
65
66 public function status()
67 {
68 return [
74 ];
75 }
76
80 public function test_status($status)
81 {
82 $spp = (new ilStudyProgrammeProgress(123))->setStatus($status);
83 $this->assertEquals($spp->getStatus(), $status);
84 }
85
89 public function test_status_invalid()
90 {
91 $this->expectException(\ilException::class);
92 $spp = (new ilStudyProgrammeProgress(123))->setStatus(321);
93 }
94
98 public function test_completion_by()
99 {
100 $spp = (new ilStudyProgrammeProgress(123))->setCompletionBy(321);
101 $this->assertEquals($spp->getCompletionBy(), 321);
102 }
103
107 public function test_last_change_by()
108 {
109 $spp = (new ilStudyProgrammeProgress(123))->setLastChangeBy(6);
110 $this->assertEquals($spp->getLastChangeBy(), 6);
111 }
112
117 {
118 $this->expectException(\ilException::class);
119 $spp = (new ilStudyProgrammeProgress(123))->setLastChangeBy(-1);
120 }
121
125 public function test_last_change_by_null()
126 {
127 $this->expectException(\ilException::class);
128 $spp = (new ilStudyProgrammeProgress(123))->setLastChangeBy();
129 }
130
134 public function test_assignment_date()
135 {
136 $ad = new DateTime();
137 $spp = (new ilStudyProgrammeProgress(123))->setAssignmentDate($ad);
138 $this->assertEquals($spp->getAssignmentDate()->format('Y-m-d'), $ad->format('Y-m-d'));
139 }
140
144 public function test_completion_date()
145 {
146 $cd = new DateTime();
147 $spp = (new ilStudyProgrammeProgress(123))->setCompletionDate($cd);
148 $this->assertEquals($spp->getCompletionDate()->format('Y-m-d'), $cd->format('Y-m-d'));
149 $spp = (new ilStudyProgrammeProgress(123))->setCompletionDate(null);
150 $this->assertNull($spp->getCompletionDate());
151 }
152
156 public function test_deadline()
157 {
158 $dl = new DateTime();
159 $spp = (new ilStudyProgrammeProgress(123))->setDeadline($dl);
160 $this->assertEquals($spp->getDeadline()->format('Y-m-d'), $dl->format('Y-m-d'));
161 }
162
166 public function test_vq_date()
167 {
168 $dl = DateTime::createFromFormat('Ymd', '20201011');
169 $spp = (new ilStudyProgrammeProgress(123))->setValidityOfQualification($dl);
170 $this->assertEquals($spp->getValidityOfQualification()->format('Ymd'), '20201011');
171 }
172
176 public function test_invalidate()
177 {
178 $spp = new ilStudyProgrammeProgress(123);
179 $this->assertFalse($spp->isInvalidated());
180 $past = DateTime::createFromFormat('Ymd', '20180101');
181 $spp->setValidityOfQualification($past);
182 $spp->invalidate();
183 $this->assertTrue($spp->isInvalidated());
184 }
185
190 {
191 $this->expectException(\ilException::class);
192 $tomorrow = new DateTime();
193 $tomorrow->add(new DateInterval('P1D'));
194 $spp = (new ilStudyProgrammeProgress(123))->setValidityOfQualification($tomorrow)->invalidate();
195 }
196
201 {
202 $this->expectException(\ilException::class);
203 $spp = (new ilStudyProgrammeProgress(123))->invalidate();
204 }
205}
An exception for terminatinating execution or to throw for unit testing.
test_amount_of_points_invalid()
@depends test_init_and_id
test_current_amount_of_points()
@depends test_init_and_id
test_invalidate_non_expired_2()
@depends test_vq_date
test_assignment_id()
@depends test_init_and_id
test_deadline()
@depends test_init_and_id
test_node_id()
@depends test_init_and_id
test_assignment_date()
@depends test_init_and_id
test_last_change_by()
@depends test_init_and_id
test_last_change_by_null()
@depends test_init_and_id
test_last_change_by_invalid()
@depends test_init_and_id
test_user_id()
@depends test_init_and_id
test_completion_date()
@depends test_init_and_id
test_amount_of_points()
@depends test_init_and_id
test_status_invalid()
@depends test_init_and_id
test_status($status)
@dataProvider status
test_invalidate_non_expired_1()
@depends test_vq_date
test_completion_by()
@depends test_init_and_id
Class ilStudyProgrammeProgress.