ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilTestRandomQuestionCollectionSubsetApplicationTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
26 {
28 
29  protected function setUp(): void
30  {
31  parent::setUp();
32 
34  }
35 
37  {
38  $this->assertInstanceOf(ilTestRandomQuestionCollectionSubsetApplication::class, $this->testObj);
39  }
40 
41  public function testApplicantId(): void
42  {
43  $applicantId = 12;
44  $this->testObj->setApplicantId($applicantId);
45  $this->assertEquals($applicantId, $this->testObj->getApplicantId());
46  }
47 
48  public function testRequiredAmount(): void
49  {
50  $requiredAmount = 12;
51  $this->testObj->setRequiredAmount($requiredAmount);
52  $this->assertEquals($requiredAmount, $this->testObj->getRequiredAmount());
53  }
54 
55  public function testHasRequiredAmountLeft(): void
56  {
57  for ($i = 3; $i > -3; $i--) {
58  $this->testObj->setRequiredAmount($i);
59  $this->assertEquals($i > 0, $this->testObj->hasRequiredAmountLeft());
60  }
61  }
62 
63  public function testDecrementRequiredAmount(): void
64  {
65  $requiredAmount = 5;
66  $this->testObj->setRequiredAmount($requiredAmount);
67  $this->testObj->decrementRequiredAmount();
68  $this->assertEquals(--$requiredAmount, $this->testObj->getRequiredAmount());
69  }
70 
71  public function testHasQuestion(): void
72  {
73  $questionId = 2;
74  $this->assertFalse($this->testObj->hasQuestion($questionId));
75 
76  $question = new ilTestRandomQuestionSetQuestion();
77  $question->setQuestionId($questionId);
78 
79  $this->testObj->addQuestion($question);
80  $this->assertTrue($this->testObj->hasQuestion($questionId));
81  }
82 
83  public function testGetQuestion(): void
84  {
85  $questionId = 2;
86  $question = new ilTestRandomQuestionSetQuestion();
87  $question->setQuestionId($questionId);
88  $this->testObj->addQuestion($question);
89 
90  $this->assertEquals($question, $this->testObj->getQuestion($questionId));
91  }
92 }