ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
assAnswerSimpleTest.php
Go to the documentation of this file.
1 <?php
2 
27 {
28  protected $backupGlobals = false;
29 
30  protected function setUp(): void
31  {
32  chdir(dirname(__FILE__));
33  chdir('../../../');
34  }
35 
37  {
38  // Arrange
39  require_once './Modules/TestQuestionPool/classes/class.assAnswerSimple.php';
40 
41  // Act
42  $instance = new ASS_AnswerSimple();
43 
44  $this->assertInstanceOf('ASS_AnswerSimple', $instance);
45  }
46 
47  public function test_setGetId_shouldReturnUnchangedId(): void
48  {
49  // Arrange
50  require_once './Modules/TestQuestionPool/classes/class.assAnswerSimple.php';
51  $instance = new ASS_AnswerSimple("", 0.0, 0, -1, 0);
52  $expected = 1;
53 
54  // Act
55  $instance->setId($expected);
56  $actual = $instance->getId();
57 
58  // Assert
59  $this->assertEquals($expected, $actual);
60  }
61 
63  {
64  // Arrange
65  require_once './Modules/TestQuestionPool/classes/class.assAnswerSimple.php';
66  $instance = new ASS_AnswerSimple("", 0.0, 0, -1, 0);
67  $expected = 'The answer, of course, is 42.';
68 
69  // Act
70  $instance->setAnswertext($expected);
71  $actual = $instance->getAnswertext();
72 
73  // Assert
74  $this->assertEquals($expected, $actual);
75  }
76 
78  {
79  // Arrange
80  require_once './Modules/TestQuestionPool/classes/class.assAnswerSimple.php';
81  $instance = new ASS_AnswerSimple("", 0.0, 0, -1, 0);
82  $expected = 42;
83 
84  // Act
85  $instance->setPoints($expected);
86  $actual = $instance->getPoints();
87 
88  // Assert
89  $this->assertEquals($expected, $actual);
90  }
91 
93  {
94  // Note: We want to get rid of this functionality in the class.
95 
96  // Arrange
97  require_once './Modules/TestQuestionPool/classes/class.assAnswerSimple.php';
98  $instance = new ASS_AnswerSimple();
99  $expected = 0.0;
100 
101  // Act
102  $instance->setPoints('Günther');
103  $actual = $instance->getPoints();
104 
105  // Assert
106  $this->assertEquals($expected, $actual);
107  }
108 
110  {
111  // Arrange
112  require_once './Modules/TestQuestionPool/classes/class.assAnswerSimple.php';
113  $instance = new ASS_AnswerSimple("", 0.0, 0, -1, 0);
114  $expected = 42;
115 
116  // Act
117  $instance->setOrder($expected);
118  $actual = $instance->getOrder();
119 
120  // Assert
121  $this->assertEquals($expected, $actual);
122  }
123 }
Class assBaseTestCase.
test_setGetPoints_shouldReturnUnchangedZeroOnNonNumericInput()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
test_setGetAnswertext_shouldReturnUnchangedAnswertext()