ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
assAnswerBinaryStateTest.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.assAnswerBinaryState.php';
40 
41  // Act
42  $instance = new ASS_AnswerBinaryState();
43 
44  $this->assertInstanceOf('ASS_AnswerBinaryState', $instance);
45  }
46 
48  {
49  // Arrange
50  require_once './Modules/TestQuestionPool/classes/class.assAnswerBinaryState.php';
51  $instance = new ASS_AnswerBinaryState();
52  $expected = 1;
53 
54  // Act
55  $instance->setState($expected);
56  $actual = $instance->getState();
57 
58  // Assert
59  $this->assertEquals($expected, $actual);
60  }
61 
63  {
64  // Arrange
65  require_once './Modules/TestQuestionPool/classes/class.assAnswerBinaryState.php';
66  $instance = new ASS_AnswerBinaryState();
67  $expected = 1;
68 
69  // Act
70  $instance->setState($expected);
71  $actual = $instance->isStateChecked();
72 
73  // Assert
74  $this->assertEquals($expected, $actual);
75  }
76 
78  {
79  // Arrange
80  require_once './Modules/TestQuestionPool/classes/class.assAnswerBinaryState.php';
81  $instance = new ASS_AnswerBinaryState();
82  $expected = 1;
83 
84  // Act
85  $instance->setState($expected);
86  $actual = $instance->isStateSet();
87 
88  // Assert
89  $this->assertEquals($expected, $actual);
90  }
91 
93  {
94  // Arrange
95  require_once './Modules/TestQuestionPool/classes/class.assAnswerBinaryState.php';
96  $instance = new ASS_AnswerBinaryState();
97  $expected = 1;
98 
99  // Act
100  $instance->setState($expected);
101  $actual = !$instance->isStateUnset();
102 
103  // Assert
104  $this->assertEquals($expected, $actual);
105  }
106 
108  {
109  // Arrange
110  require_once './Modules/TestQuestionPool/classes/class.assAnswerBinaryState.php';
111  $instance = new ASS_AnswerBinaryState();
112  $expected = 1;
113 
114  // Act
115  $instance->setState($expected);
116  $actual = !$instance->isStateUnchecked();
117 
118  // Assert
119  $this->assertEquals($expected, $actual);
120  }
121 
122  public function test_setChecked_shouldAlterState(): void
123  {
124  // Arrange
125  require_once './Modules/TestQuestionPool/classes/class.assAnswerBinaryState.php';
126  $instance = new ASS_AnswerBinaryState();
127  $expected = 0;
128  $instance->setState($expected);
129 
130  // Act
131  $instance->setChecked();
132  $actual = $instance->isStateUnchecked();
133 
134  // Assert
135  $this->assertEquals($expected, $actual);
136  }
137 
138  public function test_setUnchecked_shouldAlterState(): void
139  {
140  // Arrange
141  require_once './Modules/TestQuestionPool/classes/class.assAnswerBinaryState.php';
142  $instance = new ASS_AnswerBinaryState();
143  $expected = 1;
144  $instance->setState($expected);
145 
146  // Act
147  $instance->setUnchecked();
148  $actual = $instance->isStateUnchecked();
149 
150  // Assert
151  $this->assertEquals($expected, $actual);
152  }
153 
154  public function test_setSet_shouldAlterState(): void
155  {
156  // Arrange
157  require_once './Modules/TestQuestionPool/classes/class.assAnswerBinaryState.php';
158  $instance = new ASS_AnswerBinaryState();
159  $expected = 0;
160  $instance->setState($expected);
161 
162  // Act
163  $instance->setSet();
164  $actual = $instance->isStateUnchecked();
165 
166  // Assert
167  $this->assertEquals($expected, $actual);
168  }
169 
170  public function test_setUnset_shouldAlterState(): void
171  {
172  // Arrange
173  require_once './Modules/TestQuestionPool/classes/class.assAnswerBinaryState.php';
174  $instance = new ASS_AnswerBinaryState();
175  $expected = 1;
176  $instance->setState($expected);
177 
178  // Act
179  $instance->setUnset();
180  $actual = $instance->isStateUnchecked();
181 
182  // Assert
183  $this->assertEquals($expected, $actual);
184  }
185 }
Class assBaseTestCase.
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...