ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilassMarkTest.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4use PHPUnit\Framework\TestCase;
5
15class ilassMarkTest extends TestCase
16{
18 protected $backupGlobals = false;
19
21 protected $ass_mark;
22
23 protected function setUp() : void
24 {
25 if (defined('ILIAS_PHPUNIT_CONTEXT')) {
26 require_once './Services/PHPUnit/classes/class.ilUnitUtil.php';
27 ilUnitUtil::performInitialisation();
28 } else {
29 chdir(dirname(__FILE__));
30 chdir('../../../');
31 }
32
33 // Arrange
34 require_once './Modules/Test/classes/class.assMark.php';
35 $this->ass_mark = new ASS_Mark();
36 }
37
41 public function testGetSetShortName()
42 {
43 // Arrange
44 $expected = "Esther";
45 $this->ass_mark->setShortName($expected);
46
47 // Act
48 $actual = $this->ass_mark->getShortName();
49
50 // Assert
51 $this->assertEquals(
52 $actual,
53 $expected,
54 "Get/Set on shortName failed, in/out not matching."
55 );
56 }
57
61 public function testGetSetPassed()
62 {
63 // Arrange
64 $expected = 1;
65 $this->ass_mark->setPassed($expected);
66
67 // Act
68 $actual = $this->ass_mark->getPassed();
69
70 // Assert
71 $this->assertEquals(
72 $actual,
73 $expected,
74 "Get/Set on passed failed, in/out not matching."
75 );
76 }
77
81 public function testGetSetOfficialName()
82 {
83 // Arrange
84 $expected = "Esther The Tester";
85 $this->ass_mark->setOfficialName($expected);
86
87 // Act
88 $actual = $this->ass_mark->getOfficialName();
89
90 // Assert
91 $this->assertEquals(
92 $actual,
93 $expected,
94 "Get/Set on officialName failed, in/out not matching."
95 );
96 }
97
101 public function testGetSetMinimumLevel()
102 {
103 // Arrange
104 $expected = 50;
105 $this->ass_mark->setMinimumLevel($expected);
106
107 // Act
108 $actual = $this->ass_mark->getMinimumLevel();
109
110 // Assert
111 $this->assertEquals(
112 $actual,
113 $expected,
114 "Get/Set on minimumLevel failed, in/out not matching."
115 );
116 }
117
130 public function testSetMinimumLevel_High()
131 {
132 // Arrange
133 $expected = 100;
134 $this->ass_mark->setMinimumLevel($expected);
135
136 // Act
137 $actual = $this->ass_mark->getMinimumLevel();
138
139 // Assert
140 $this->assertEquals(
141 $actual,
142 $expected,
143 "Set low on minimumLevel failed, in/out not matching."
144 );
145 }
146
153 public function testSetMinimumLevel_Low()
154 {
155 // Arrange
156 $expected = 1E-14;
157 $this->ass_mark->setMinimumLevel($expected);
158
159 // Act
160 $actual = $this->ass_mark->getMinimumLevel();
161
162 // Assert
163 $this->assertEquals(
164 $actual,
165 $expected,
166 "Set low on minimumLevel failed, in/out not matching."
167 );
168 }
169
177 {
178 $this->expectException(\Exception::class);
179
180 // Arrange
181 $expected = -1;
182 $this->ass_mark->setMinimumLevel($expected);
183
184 // Act
185 $actual = $this->ass_mark->getMinimumLevel();
186 }
187}
A class defining marks for assessment test objects.
An exception for terminatinating execution or to throw for unit testing.
Unit tests for ASS_Mark.
testGetSetOfficialName()
Basic Get/Set test on member officialName using accessor methods.
testSetMinimumLevel_Low()
Set test on member minimumLevel using accessor methods with a very low level.
testGetSetShortName()
Basic Get/Set test on member short name using accessor methods.
testSetMinimumLevel_TooLow()
Set test on member minimumLevel using accessor methods with a too low level.
testSetMinimumLevel_High()
Set test on member minimumLevel using accessor method with a high level.
testGetSetMinimumLevel()
Basic Get/Set test on member minimumLevel using accessor methods.
testGetSetPassed()
Basic Get/Set test on member passed using accessor methods.