ILIAS  release_7 Revision v7.30-3-g800a261c036
ilStudyProgrammeSettingsTest.php
Go to the documentation of this file.
1<?php
2
6class ilStudyProgrammeSettingsTest 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
25 public function test_init_and_id()
26 {
27 $sps = new ilStudyProgrammeSettings(123);
28 $this->assertEquals($sps->getObjId(), 123);
29 return $sps;
30 }
31
35 public function test_subtype_id($sps)
36 {
37 $this->assertEquals($sps->setSubtypeId(2)->getSubtypeId(), 2);
38 }
39
43 public function test_points($sps)
44 {
45 $this->assertEquals($sps->setPoints(3)->getPoints(), 3);
46 }
47
52 public function test_wrong_points($sps)
53 {
54 $sps->setPoints(-3);
55 }
56
60 public function test_lp_mode($sps)
61 {
62 $this->assertEquals(
63 $sps->setLPMode(ilStudyProgrammeSettings::MODE_UNDEFINED)->getLPMode(),
65 );
66 $this->assertEquals(
67 $sps->setLPMode(ilStudyProgrammeSettings::MODE_POINTS)->getLPMode(),
69 );
70 $this->assertEquals(
71 $sps->setLPMode(ilStudyProgrammeSettings::MODE_LP_COMPLETED)->getLPMode(),
73 );
74 }
75
80 public function test_wrong_lp_mode($sps)
81 {
82 $sps->setLPMode(4)->getLPMode();
83 }
84
88 public function test_status($sps)
89 {
90 $this->assertEquals(
91 $sps->setStatus(ilStudyProgrammeSettings::STATUS_DRAFT)->getStatus(),
93 );
94 $this->assertEquals(
95 $sps->setStatus(ilStudyProgrammeSettings::STATUS_ACTIVE)->getStatus(),
97 );
98 $this->assertEquals(
99 $sps->setStatus(ilStudyProgrammeSettings::STATUS_OUTDATED)->getStatus(),
101 );
102 }
103
108 public function test_wrong_status($sps)
109 {
110 $sps->setStatus(41);
111 }
112
116 public function test_deadline_period($sps)
117 {
118 $this->assertEquals($sps->setDeadlinePeriod(10)->getDeadlinePeriod(), 10);
119 $this->assertEquals($sps->setDeadlineDate(new \DateTime())->getDeadlinePeriod(), 0);
120 }
121
125 public function test_deadline_date($sps)
126 {
127 $this->assertEquals($sps->setDeadlineDate(new \DateTime())->getDeadlineDate()->format('Ymd'), (new \DateTime())->format('Ymd'));
128 $this->assertNull($sps->setDeadlinePeriod(10)->getDeadlineDate());
129 }
130
135 {
136 $this->assertEquals($sps->setValidityOfQualificationPeriod(10)->getValidityOfQualificationPeriod(), 10);
137 $this->assertEquals($sps->setValidityOfQualificationDate(new \DateTime())->getValidityOfQualificationPeriod(), ilStudyProgrammeSettings::NO_VALIDITY_OF_QUALIFICATION_PERIOD);
138 }
139
144 {
145 $this->assertEquals($sps->setValidityOfQualificationDate(new \DateTime())->getValidityOfQualificationDate()->format('Ymd'), (new \DateTime())->format('Ymd'));
146 $this->assertNull($sps->setValidityOfQualificationPeriod(10)->getValidityOfQualificationDate());
147 }
148
153 public function test_wrong_vq_peiod($sps)
154 {
155 $sps->setValidityOfQualificationPeriod(-10);
156 }
157
161 public function test_restart_period($sps)
162 {
163 $this->assertEquals($sps->setRestartPeriod(10)->getRestartPeriod(), 10);
164 }
165
170 public function test_wrong_restart_period($sps)
171 {
172 $sps->setRestartPeriod(-10);
173 }
174}
An exception for terminatinating execution or to throw for unit testing.
test_wrong_lp_mode($sps)
@depends test_init_and_id @expectedException ilException
test_validity_qualification_date($sps)
@depends test_init_and_id
test_subtype_id($sps)
@depends test_init_and_id
test_wrong_points($sps)
@depends test_init_and_id @expectedException ilException
test_validity_qualification_period($sps)
@depends test_init_and_id
test_deadline_period($sps)
@depends test_init_and_id
test_points($sps)
@depends test_init_and_id
test_deadline_date($sps)
@depends test_init_and_id
test_wrong_vq_peiod($sps)
@depends test_init_and_id @expectedException ilException
test_lp_mode($sps)
@depends test_init_and_id
test_restart_period($sps)
@depends test_init_and_id
test_wrong_restart_period($sps)
@depends test_init_and_id @expectedException ilException
test_status($sps)
@depends test_init_and_id
test_wrong_status($sps)
@depends test_init_and_id @expectedException ilException
global $DIC
Definition: goto.php:24