ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilTestEvaluationPassDataTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
28
29 protected function setUp(): void
30 {
31 parent::setUp();
32
33 $this->testObj = new ilTestEvaluationPassData();
34 }
35
37 {
38 $this->assertInstanceOf(ilTestEvaluationPassData::class, $this->testObj);
39 }
40
41 public function test__sleep(): void
42 {
43 $expected = [
44 'answeredQuestions',
45 'pass',
46 'nrOfAnsweredQuestions',
47 'reachedpoints',
48 'maxpoints',
49 'questioncount',
50 'workingtime',
51 'examId'
52 ];
53 $this->assertEquals($expected, $this->testObj->__sleep());
54 }
55
56 public function testNrOfAnsweredQuestions(): void
57 {
58 $nrOfAnsweredQuestions = 20;
59 $this->testObj->setNrOfAnsweredQuestions($nrOfAnsweredQuestions);
60 $this->assertEquals($nrOfAnsweredQuestions, $this->testObj->getNrOfAnsweredQuestions());
61 }
62
63 public function testReachedPoints(): void
64 {
65 $reachedpoints = 20;
66 $this->testObj->setReachedPoints($reachedpoints);
67 $this->assertEquals($reachedpoints, $this->testObj->getReachedPoints());
68 }
69
70 public function testMaxPoints(): void
71 {
72 $maxpoints = 20;
73 $this->testObj->setMaxPoints($maxpoints);
74 $this->assertEquals($maxpoints, $this->testObj->getMaxPoints());
75 }
76
77 public function testQuestionCount(): void
78 {
79 $questioncount = 20;
80 $this->testObj->setQuestionCount($questioncount);
81 $this->assertEquals($questioncount, $this->testObj->getQuestionCount());
82 }
83
84 public function testWorkingTime(): void
85 {
86 $workingtime = 20;
87 $this->testObj->setWorkingTime($workingtime);
88 $this->assertEquals($workingtime, $this->testObj->getWorkingTime());
89 }
90
91 public function testPass(): void
92 {
93 $pass = 20;
94 $this->testObj->setPass($pass);
95 $this->assertEquals($pass, $this->testObj->getPass());
96 }
97
98 public function testAnsweredQuestions(): void
99 {
100 $expected = [
101 ['id' => 20, 'points' => 2.5, 'reached' => 1.5, 'isAnswered' => true, 'sequence' => null, 'manual' => 0],
102 ['id' => 12, 'points' => 12.5, 'reached' => 11, 'isAnswered' => true, 'sequence' => null, 'manual' => 1],
103 ['id' => 165, 'points' => -5.5, 'reached' => 0, 'isAnswered' => false, 'sequence' => null, 'manual' => 0],
104 ['id' => 4, 'points' => 55.5, 'reached' => 200, 'isAnswered' => false, 'sequence' => null, 'manual' => 1]
105 ];
106
107 foreach ($expected as $value) {
108 $this->testObj->addAnsweredQuestion(
109 $value['id'],
110 $value['points'],
111 $value['reached'],
112 $value['isAnswered'],
113 $value['sequence'],
114 $value['manual']
115 );
116 }
117
118 $this->assertEquals($expected, $this->testObj->getAnsweredQuestions());
119
120 foreach ($expected as $key => $value) {
121 $this->assertEquals($value, $this->testObj->getAnsweredQuestion($key));
122 }
123 }
124
126 {
127 $expected = [
128 ['id' => 20, 'points' => 2.5, 'reached' => 1.5, 'isAnswered' => true, 'sequence' => null, 'manual' => 0],
129 ['id' => 12, 'points' => 12.5, 'reached' => 11, 'isAnswered' => true, 'sequence' => null, 'manual' => 1],
130 ['id' => 165, 'points' => -5.5, 'reached' => 0, 'isAnswered' => false, 'sequence' => null, 'manual' => 0],
131 ['id' => 4, 'points' => 55.5, 'reached' => 200, 'isAnswered' => false, 'sequence' => null, 'manual' => 1]
132 ];
133 foreach ($expected as $value) {
134 $this->testObj->addAnsweredQuestion(
135 $value['id'],
136 $value['points'],
137 $value['reached'],
138 $value['isAnswered'],
139 $value['sequence'],
140 $value['manual']
141 );
142 }
143
144 foreach ($expected as $value) {
145 $this->assertEquals($value, $this->testObj->getAnsweredQuestionByQuestionId($value['id']));
146 }
147 }
148
149 public function testGetAnsweredQuestionCount(): void
150 {
151 $expected = [
152 ['id' => 20, 'points' => 2.5, 'reached' => 1.5, 'isAnswered' => true, 'sequence' => null, 'manual' => 0],
153 ['id' => 12, 'points' => 12.5, 'reached' => 11, 'isAnswered' => true, 'sequence' => null, 'manual' => 1],
154 ['id' => 165, 'points' => -5.5, 'reached' => 0, 'isAnswered' => false, 'sequence' => null, 'manual' => 0],
155 ['id' => 4, 'points' => 55.5, 'reached' => 200, 'isAnswered' => false, 'sequence' => null, 'manual' => 1]
156 ];
157
158 foreach ($expected as $value) {
159 $this->testObj->addAnsweredQuestion(
160 $value['id'],
161 $value['points'],
162 $value['reached'],
163 $value['isAnswered'],
164 $value['sequence'],
165 $value['manual']
166 );
167 }
168
169 $this->assertEquals(count($expected), $this->testObj->getAnsweredQuestionCount());
170 }
171
172 public function testExamId(): void
173 {
174 $exam_id = '5';
175 $this->testObj->setExamId($exam_id);
176
177 $this->assertEquals($exam_id, $this->testObj->getExamId());
178 }
179}
Class ilTestBaseClass.
Class ilTestEvaluationPassDataTest.