ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
assAnswerSimpleTest.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 
27  {
28  // Arrange
29  require_once './Modules/TestQuestionPool/classes/class.assAnswerSimple.php';
30 
31  // Act
32  $instance = new ASS_AnswerSimple();
33 
34  $this->assertInstanceOf('ASS_AnswerSimple', $instance);
35  }
36 
38  {
39  // Arrange
40  require_once './Modules/TestQuestionPool/classes/class.assAnswerSimple.php';
41  $instance = new ASS_AnswerSimple();
42  $expected = 1;
43 
44  // Act
45  $instance->setId($expected);
46  $actual = $instance->getId();
47 
48  // Assert
49  $this->assertEquals($expected, $actual);
50  }
51 
53  {
54  // Arrange
55  require_once './Modules/TestQuestionPool/classes/class.assAnswerSimple.php';
56  $instance = new ASS_AnswerSimple();
57  $expected = 'The answer, of course, is 42.';
58 
59  // Act
60  $instance->setAnswertext($expected);
61  $actual = $instance->getAnswertext();
62 
63  // Assert
64  $this->assertEquals($expected, $actual);
65  }
66 
68  {
69  // Arrange
70  require_once './Modules/TestQuestionPool/classes/class.assAnswerSimple.php';
71  $instance = new ASS_AnswerSimple();
72  $expected = 42;
73 
74  // Act
75  $instance->setPoints($expected);
76  $actual = $instance->getPoints();
77 
78  // Assert
79  $this->assertEquals($expected, $actual);
80  }
81 
83  {
84  // Note: We want to get rid of this functionality in the class.
85 
86  // Arrange
87  require_once './Modules/TestQuestionPool/classes/class.assAnswerSimple.php';
88  $instance = new ASS_AnswerSimple();
89  $expected = 0.0;
90 
91  // Act
92  $instance->setPoints('Günther');
93  $actual = $instance->getPoints();
94 
95  // Assert
96  $this->assertEquals($expected, $actual);
97  }
98 
100  {
101  // Arrange
102  require_once './Modules/TestQuestionPool/classes/class.assAnswerSimple.php';
103  $instance = new ASS_AnswerSimple();
104  $expected = 42;
105 
106  // Act
107  $instance->setOrder($expected);
108  $actual = $instance->getOrder();
109 
110  // Assert
111  $this->assertEquals($expected, $actual);
112  }
113 }
test_setGetPoints_shouldReturnUnchangedZeroOnNonNumericInput()
Class for simple answers.
test_setGetAnswertext_shouldReturnUnchangedAnswertext()
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27