ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
assAnswerErrorTextTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
12 {
13  protected $backupGlobals = false;
14 
15  protected function setUp()
16  {
17  if (defined('ILIAS_PHPUNIT_CONTEXT')) {
18  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
19  ilUnitUtil::performInitialisation();
20  } else {
21  chdir(dirname(__FILE__));
22  chdir('../../../');
23  }
24  }
25 
26  public function test_instantiateObjectSimple()
27  {
28  // Arrange
29  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
30 
31  // Act
32  $instance = new assAnswerErrorText('errortext');
33 
34  // Assert
35  $this->assertTrue(true);
36  }
37 
38 
39  public function test_instantiateObjectFull()
40  {
41  // Arrange
42  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
43 
44  // Act
45  $instance = new assAnswerErrorText(
46  'errortext',
47  'correcttext',
48  1
49  );
50 
51  // Assert
52  $this->assertTrue(true);
53  }
54 
55  public function test_setGetPoints_valid()
56  {
57  //$this->markTestIncomplete('Testing an uncommitted feature.');
58  // Arrange
59  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
60  $instance = new assAnswerErrorText('errortext');
61  $expected = 0.01;
62 
63  // Act
64  $instance->points = $expected;
65  $actual = $instance->points;
66 
67  // Assert
68  $this->assertEquals($actual, $expected);
69  }
70 
71  public function test_setPoints_invalid()
72  {
73  // Arrange
74  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
75  $instance = new assAnswerErrorText('errortext');
76  $expected = 'hokum';
77 
78  // Act
79  $instance->points = $expected;
80  $actual = $instance->points;
81  // Assert
82  $this->assertEquals($expected, $actual);
83  }
84 
85  public function test_setGetTextCorrect()
86  {
87  // Arrange
88  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
89  $instance = new assAnswerErrorText('errortext');
90  $expected = 'Correct text';
91 
92  // Act
93  $instance->text_correct = $expected;
94  $actual = $instance->text_correct;
95 
96  // Assert
97  $this->assertEquals($actual, $expected);
98  }
99 
100  public function test_setGetTextWrong_valid()
101  {
102  // Arrange
103  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
104  $instance = new assAnswerErrorText('errortext');
105  $expected = 'Errortext';
106 
107  // Act
108  $instance->text_wrong = $expected;
109  $actual = $instance->text_wrong;
110 
111  // Assert
112  $this->assertEquals($actual, $expected);
113  }
114 
115  public function test_setTextWrong_invalid()
116  {
117  // Arrange
118  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
119  $instance = new assAnswerErrorText('errortext');
120  $expected = '';
121 
122  // Act
123  $instance->text_wrong = $expected;
124  $actual = $instance->text_wrong;
125 
126  // Assert
127  $this->assertEquals($expected, $actual);
128  }
129 
130  public function test_setGetUnknown()
131  {
132  // Arrange
133  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
134  $instance = new assAnswerErrorText('errortext');
135  $expected = null;
136 
137  // Act
138  $instance->undefined123 = 'No expectations';
139  $actual = $instance->undefined123;
140 
141  // Assert
142  $this->assertEquals($expected, $actual);
143  }
144 }
Class for error text answers.
Unit tests for assAnswerErrorTextTest.