ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
assAnswerErrorTextTest.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
32 {
33  protected $backupGlobals = FALSE;
34 
35  protected function setUp()
36  {
37  if (defined('ILIAS_PHPUNIT_CONTEXT'))
38  {
39  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
40  ilUnitUtil::performInitialisation();
41  }
42  else
43  {
44  chdir( dirname( __FILE__ ) );
45  chdir('../../../');
46  }
47  }
48 
49  public function test_instantiateObjectSimple()
50  {
51  // Arrange
52  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
53 
54  // Act
55  $instance = new assAnswerErrorText('errortext');
56 
57  // Assert
58  $this->assertTrue(TRUE);
59  }
60 
61 
62  public function test_instantiateObjectFull()
63  {
64  // Arrange
65  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
66 
67  // Act
68  $instance = new assAnswerErrorText(
69  'errortext',
70  'correcttext',
71  1
72  );
73 
74  // Assert
75  $this->assertTrue(TRUE);
76  }
77 
78  public function test_setGetPoints_valid()
79  {
80  //$this->markTestIncomplete('Testing an uncommitted feature.');
81  // Arrange
82  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
83  $instance = new assAnswerErrorText( 'errortext' );
84  $expected = 0.01;
85 
86  // Act
87  $instance->points = $expected;
88  $actual = $instance->points;
89 
90  // Assert
91  $this->assertEquals($actual, $expected);
92  }
93 
94  public function test_setPoints_invalid()
95  {
96  // Arrange
97  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
98  $instance = new assAnswerErrorText( 'errortext' );
99  $expected = 'hokum';
100 
101  // Act
102  $instance->points = $expected;
103  $actual = $instance->points;
104  // Assert
105  $this->assertEquals($expected, $actual);
106  }
107 
108  public function test_setGetTextCorrect()
109  {
110  // Arrange
111  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
112  $instance = new assAnswerErrorText( 'errortext' );
113  $expected = 'Correct text';
114 
115  // Act
116  $instance->text_correct = $expected;
117  $actual = $instance->text_correct;
118 
119  // Assert
120  $this->assertEquals($actual, $expected);
121  }
122 
123  public function test_setGetTextWrong_valid()
124  {
125  // Arrange
126  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
127  $instance = new assAnswerErrorText( 'errortext' );
128  $expected = 'Errortext';
129 
130  // Act
131  $instance->text_wrong = $expected;
132  $actual = $instance->text_wrong;
133 
134  // Assert
135  $this->assertEquals($actual, $expected);
136  }
137 
138  public function test_setTextWrong_invalid()
139  {
140  // Arrange
141  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
142  $instance = new assAnswerErrorText( 'errortext' );
143  $expected = '';
144 
145  // Act
146  $instance->text_wrong = $expected;
147  $actual = $instance->text_wrong;
148 
149  // Assert
150  $this->assertEquals($expected, $actual);
151  }
152 
153  public function test_setGetUnknown()
154  {
155  // Arrange
156  require_once './Modules/TestQuestionPool/classes/class.assAnswerErrorText.php';
157  $instance = new assAnswerErrorText( 'errortext' );
158  $expected = null;
159 
160  // Act
161  $instance->undefined123 = 'No expectations';
162  $actual = $instance->undefined123;
163 
164  // Assert
165  $this->assertEquals($expected, $actual);
166  }
167 }