19 declare(strict_types=1);
29 protected function setUp(): void
38 $this->assertInstanceOf(ilTestRandomQuestionSetQuestionCollection::class, $this->testObj);
48 $this->testObj->setQuestions($expected);
49 $this->assertEquals($expected, $this->testObj->getQuestions());
54 for ($count = 0; $count < 3; $count++) {
57 $this->assertCount($count, $this->testObj->getQuestions());
63 $ids = [125, 112, 10];
64 foreach ($ids as
$id) {
66 $question->setQuestionId($id);
67 $questions[] = $question;
70 $this->testObj->setQuestions($questions);
72 $this->assertEquals($questions[0], $this->testObj->current());
78 $ids = [125, 112, 10];
79 foreach ($ids as
$id) {
81 $question->setQuestionId($id);
82 $questions[] = $question;
85 $this->testObj->setQuestions($questions);
89 $this->assertEquals(0, $this->testObj->key());
91 for ($i = 1; $i < $iMax; $i++) {
92 $this->testObj->next();
95 $this->assertEquals(--$i, $this->testObj->key());
97 $this->assertTrue(
false);
104 $ids = [125, 112, 10];
105 foreach ($ids as
$id) {
107 $question->setQuestionId($id);
108 $questions[] = $question;
111 $this->testObj->setQuestions($questions);
113 $this->assertTrue($this->testObj->valid());
115 $this->testObj->setQuestions([]);
116 $this->assertFalse($this->testObj->valid());
122 $ids = [125, 112, 10];
123 foreach ($ids as
$id) {
125 $question->setQuestionId($id);
126 $questions[] = $question;
129 $this->testObj->setQuestions($questions);
131 $iMax = count($questions);
133 $this->assertEquals($questions[0], $this->testObj->current());
135 for ($i = 1; $i < $iMax; $i++) {
136 $this->testObj->next();
139 $this->assertEquals($questions[--$i], $this->testObj->current());
141 for ($j = $i; $j > 0; $j--) {
142 $this->testObj->rewind();
145 $this->assertEquals($questions[$j], $this->testObj->current());
147 $this->assertTrue(
false);
154 $ids = [125, 112, 10];
155 foreach ($ids as
$id) {
157 $question->setQuestionId($id);
158 $questions[] = $question;
161 $this->testObj->setQuestions($questions);
163 for ($i = 0, $iMax = count($questions); $i < $iMax; $i++) {
164 $this->assertTrue($this->testObj->isGreaterThan($i));
166 $this->assertFalse($this->testObj->isGreaterThan($i));
172 $ids = [125, 112, 10];
173 foreach ($ids as
$id) {
175 $question->setQuestionId($id);
176 $questions[] = $question;
179 $this->testObj->setQuestions($questions);
181 for ($questionsCount = count($questions), $i = $questionsCount * 2; $i > $questionsCount; $i--) {
182 $this->assertTrue($this->testObj->isSmallerThan($i));
184 $this->assertFalse($this->testObj->isSmallerThan($i));
190 $ids = [125, 112, 10];
191 foreach ($ids as
$id) {
193 $question->setQuestionId($id);
194 $questions[] = $question;
197 $this->testObj->setQuestions($questions);
199 $questionsCount = count($questions);
201 for ($i = 0, $iMax = $questionsCount; $i < $iMax; $i++) {
202 $this->assertEquals(0, $this->testObj->getMissingCount($i));
205 for ($i = $questionsCount, $iMax = $questionsCount * 2; $i <= $iMax; $i++) {
206 $this->assertEquals($i - $questionsCount, $this->testObj->getMissingCount($i));
213 $ids = [125, 112, 10];
214 foreach ($ids as
$id) {
216 $question->setQuestionId($id);
217 $questions[] = $question;
218 $this->testObj->addQuestion($question);
224 foreach ($ids as $id) {
226 $question->setQuestionId($id);
227 $questions[] = $question;
228 $collection->addQuestion($question);
231 $this->testObj->mergeQuestionCollection($collection);
233 $this->assertEquals($questions, $this->testObj->getQuestions());
238 $ids = [125, 112, 10, 112];
239 foreach ($ids as
$id) {
241 $question->setQuestionId($id);
242 $this->testObj->addQuestion($question);
245 $this->assertCount(count(array_unique($ids)), $this->testObj->getUniqueQuestionCollection()->getQuestions());
250 $ids = [125, 112, 10];
251 foreach ($ids as
$id) {
253 $question->setQuestionId($id);
254 $this->testObj->addQuestion($question);
257 $this->assertEquals(count($ids), $this->testObj->getQuestionAmount());
262 $ids = [125, 112, 10];
263 foreach ($ids as
$id) {
265 $question->setQuestionId($id);
266 $this->testObj->addQuestion($question);
269 $this->assertEquals($ids, $this->testObj->getInvolvedQuestionIds());
testMergeQuestionCollection()
testGetInvolvedQuestionIds()
testGetUniqueQuestionCollection()
ilTestRandomQuestionSetQuestionCollection $testObj
Class ilTestRandomQuestionSetQuestionCollectionTest.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
test_instantiateObject_shouldReturnInstance()