ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
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  {
19  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
20  ilUnitUtil::performInitialisation();
21  }
22  else
23  {
24  chdir( dirname( __FILE__ ) );
25  chdir('../../../');
26  }
27  }
28 
29  public function test_instantiateObjectSimple()
30  {
31  // Arrange
32  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
33 
34  // Act
35  $instance = new assAnswerErrorText('errortext');
36 
37  // Assert
38  $this->assertTrue(TRUE);
39  }
40 
41 
42  public function test_instantiateObjectFull()
43  {
44  // Arrange
45  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
46 
47  // Act
48  $instance = new assAnswerErrorText(
49  'errortext',
50  'correcttext',
51  1
52  );
53 
54  // Assert
55  $this->assertTrue(TRUE);
56  }
57 
58  public function test_setGetPoints_valid()
59  {
60  //$this->markTestIncomplete('Testing an uncommitted feature.');
61  // Arrange
62  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
63  $instance = new assAnswerErrorText( 'errortext' );
64  $expected = 0.01;
65 
66  // Act
67  $instance->points = $expected;
68  $actual = $instance->points;
69 
70  // Assert
71  $this->assertEquals($actual, $expected);
72  }
73 
74  public function test_setPoints_invalid()
75  {
76  // Arrange
77  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
78  $instance = new assAnswerErrorText( 'errortext' );
79  $expected = 'hokum';
80 
81  // Act
82  $instance->points = $expected;
83  $actual = $instance->points;
84  // Assert
85  $this->assertEquals($expected, $actual);
86  }
87 
88  public function test_setGetTextCorrect()
89  {
90  // Arrange
91  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
92  $instance = new assAnswerErrorText( 'errortext' );
93  $expected = 'Correct text';
94 
95  // Act
96  $instance->text_correct = $expected;
97  $actual = $instance->text_correct;
98 
99  // Assert
100  $this->assertEquals($actual, $expected);
101  }
102 
103  public function test_setGetTextWrong_valid()
104  {
105  // Arrange
106  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
107  $instance = new assAnswerErrorText( 'errortext' );
108  $expected = 'Errortext';
109 
110  // Act
111  $instance->text_wrong = $expected;
112  $actual = $instance->text_wrong;
113 
114  // Assert
115  $this->assertEquals($actual, $expected);
116  }
117 
118  public function test_setTextWrong_invalid()
119  {
120  // Arrange
121  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
122  $instance = new assAnswerErrorText( 'errortext' );
123  $expected = '';
124 
125  // Act
126  $instance->text_wrong = $expected;
127  $actual = $instance->text_wrong;
128 
129  // Assert
130  $this->assertEquals($expected, $actual);
131  }
132 
133  public function test_setGetUnknown()
134  {
135  // Arrange
136  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
137  $instance = new assAnswerErrorText( 'errortext' );
138  $expected = null;
139 
140  // Act
141  $instance->undefined123 = 'No expectations';
142  $actual = $instance->undefined123;
143 
144  // Assert
145  $this->assertEquals($expected, $actual);
146  }
147 }
Class for error text answers.
Unit tests for assAnswerErrorTextTest.