ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
assLongmenuTest Class Reference

Unit tests. More...

+ Inheritance diagram for assLongmenuTest:
+ Collaboration diagram for assLongmenuTest:

Public Member Functions

 test_instantiateObject_shouldReturnInstance ()
 
 test_getAdditionalTableName_shouldReturnString ()
 
 test_getQuestionType_shouldReturnString ()
 
 test_getAnswerTableName_shouldReturnString ()
 
 test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnTrue ()
 
 test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnFalse ()
 
 test_getMaximumPoints_shouldBeFour ()
 
 test_getMaximumPoints_shouldBeFourPointFive ()
 
 test_isComplete_shouldBeFalse ()
 
 test_isComplete_shouldBeTrue ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseNoCustomPart ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyAnswers ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyCorrectAnswers ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseToManyCorrectAnswers ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerDoesNotExistsInAnswers ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoAnswers ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoPoints ()
 
 test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerPointsAreZero ()
 
 test_checkQuestionCustomPart_shouldBeTrue ()
 
 test_getSolutionSubmit_shouldReturnSolution ()
 
 test_setAnswerType_shouldReturnGetAnswerType ()
 
 test_setLongMenuTextValue_shouldReturnGetLongMenuTextValue ()
 
 test_setJsonStructure_shouldReturnGetJsonStructure ()
 
 test_isShuffleAnswersEnabled_shouldReturnFalse ()
 

Protected Member Functions

 setUp ()
 

Static Protected Member Functions

static getMethod ($name)
 

Protected Attributes

 $backupGlobals = FALSE
 

Detailed Description

Unit tests.

Author
Guido Vollbach <gvollbachdatabay.de>

Definition at line 9 of file assLongMenuTest.php.

Member Function Documentation

◆ getMethod()

static assLongmenuTest::getMethod (   $name)
staticprotected

Definition at line 14 of file assLongMenuTest.php.

14  {
15  $class = new ReflectionClass('assLongMenu');
16  $method = $class->getMethod($name);
17  $method->setAccessible(true);
18  return $method;
19  }

◆ setUp()

assLongmenuTest::setUp ( )
protected

Definition at line 21 of file assLongMenuTest.php.

References $GLOBALS, and defined.

22  {
23  $GLOBALS['DIC']['ilDB'] = 'test';
24 
25  require_once './Modules/TestQuestionPool/classes/class.assLongMenu.php';
26  if (defined('ILIAS_PHPUNIT_CONTEXT'))
27  {
28  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
29  ilUnitUtil::performInitialisation();
30  }
31  else
32  {
33  chdir( dirname( __FILE__ ) );
34  chdir('../../../');
35  }
36  require_once './Services/Utilities/classes/class.ilUtil.php';
37  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerDoesNotExistsInAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerDoesNotExistsInAnswers ( )

Definition at line 146 of file assLongMenuTest.php.

References array.

147  {
148  $obj = new assLongMenu();
149  $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
150  $obj->setAnswers(array(array(1)));
151  $this->assertEquals($obj->checkQuestionCustomPart(), false);
152  }
Create styles array
The data for the language used.

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoAnswers ( )

Definition at line 154 of file assLongMenuTest.php.

References array.

155  {
156  $obj = new assLongMenu();
157  $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (),1 => '2.25', 2 => '1')));
158  $obj->setAnswers(array(array('answer')));
159  $this->assertEquals($obj->checkQuestionCustomPart(), false);
160  }
Create styles array
The data for the language used.

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoPoints()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoPoints ( )

Definition at line 162 of file assLongMenuTest.php.

References array.

163  {
164  $obj = new assLongMenu();
165  $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array ())));
166  $obj->setAnswers(array(array('answer')));
167  $this->assertEquals($obj->checkQuestionCustomPart(), false);
168  }
Create styles array
The data for the language used.

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerPointsAreZero()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerPointsAreZero ( )

Definition at line 170 of file assLongMenuTest.php.

References array.

171  {
172  $obj = new assLongMenu();
173  $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array ('answer'),1 => 0, 2 => '1')));
174  $obj->setAnswers(array(array('answer')));
175  $this->assertEquals($obj->checkQuestionCustomPart(), false);
176  }
Create styles array
The data for the language used.

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseNoCustomPart()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseNoCustomPart ( )

Definition at line 118 of file assLongMenuTest.php.

119  {
120  $obj = new assLongMenu();
121  $this->assertEquals($obj->checkQuestionCustomPart(), false);
122  }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyAnswers ( )

Definition at line 124 of file assLongMenuTest.php.

References array.

125  {
126  $obj = new assLongMenu();
127  $obj->setAnswers(array(array(1,2,3,4)));
128  $this->assertEquals($obj->checkQuestionCustomPart(), false);
129  }
Create styles array
The data for the language used.

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyCorrectAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyCorrectAnswers ( )

Definition at line 131 of file assLongMenuTest.php.

References array.

132  {
133  $obj = new assLongMenu();
134  $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1'),
135  1 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
136  $this->assertEquals($obj->checkQuestionCustomPart(), false);
137  }
Create styles array
The data for the language used.

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseToManyCorrectAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseToManyCorrectAnswers ( )

Definition at line 138 of file assLongMenuTest.php.

References array.

139  {
140  $obj = new assLongMenu();
141  $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1'),
142  1 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
143  $obj->setAnswers(array(array('answer')));
144  $this->assertEquals($obj->checkQuestionCustomPart(), false);
145  }
Create styles array
The data for the language used.

◆ test_checkQuestionCustomPart_shouldBeTrue()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeTrue ( )

Definition at line 178 of file assLongMenuTest.php.

References array.

179  {
180  $obj = new assLongMenu();
181  $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array ('answer'),1 => 1, 2 => '1')));
182  $obj->setAnswers(array(array('answer')));
183  $this->assertEquals($obj->checkQuestionCustomPart(), true);
184  }
Create styles array
The data for the language used.

◆ test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnFalse()

assLongmenuTest::test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnFalse ( )

Definition at line 71 of file assLongMenuTest.php.

References array.

72  {
73  $method = self::getMethod('correctAnswerDoesNotExistInAnswerOptions');
74  $obj = new assLongMenu();
75  $value = $method->invokeArgs($obj, array(array(array(1),1,1), array(1,2,3,4)));
76  $this->assertEquals(false, $value);
77  }
Create styles array
The data for the language used.

◆ test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnTrue()

assLongmenuTest::test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnTrue ( )

Definition at line 63 of file assLongMenuTest.php.

References array.

64  {
65  $method = self::getMethod('correctAnswerDoesNotExistInAnswerOptions');
66  $obj = new assLongMenu();
67  $value = $method->invokeArgs($obj, array(array(array(5),1,1), array(1,2,3,4)));
68  $this->assertEquals(true, $value);
69  }
Create styles array
The data for the language used.

◆ test_getAdditionalTableName_shouldReturnString()

assLongmenuTest::test_getAdditionalTableName_shouldReturnString ( )

Definition at line 45 of file assLongMenuTest.php.

46  {
47  $instance = new assLongMenu();
48  $this->assertEquals('qpl_qst_lome', $instance->getAdditionalTableName());
49  }

◆ test_getAnswerTableName_shouldReturnString()

assLongmenuTest::test_getAnswerTableName_shouldReturnString ( )

Definition at line 57 of file assLongMenuTest.php.

58  {
59  $instance = new assLongMenu();
60  $this->assertEquals('qpl_a_lome', $instance->getAnswerTableName());
61  }

◆ test_getMaximumPoints_shouldBeFour()

assLongmenuTest::test_getMaximumPoints_shouldBeFour ( )

Definition at line 79 of file assLongMenuTest.php.

References array.

80  {
81  $obj = new assLongMenu();
82  $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2', 2 => '1'),
83  1 => array ( 0 =>array (0 => 'answer'),1 => '2', 2 => '1')));
84  $value = $obj->getMaximumPoints();
85  $this->assertEquals(4, $value);
86  }
Create styles array
The data for the language used.

◆ test_getMaximumPoints_shouldBeFourPointFive()

assLongmenuTest::test_getMaximumPoints_shouldBeFourPointFive ( )

Definition at line 88 of file assLongMenuTest.php.

References array.

89  {
90  $obj = new assLongMenu();
91  $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1'),
92  1 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
93  $value = $obj->getMaximumPoints();
94  $this->assertEquals(4.5, $value);
95  }
Create styles array
The data for the language used.

◆ test_getQuestionType_shouldReturnString()

assLongmenuTest::test_getQuestionType_shouldReturnString ( )

Definition at line 51 of file assLongMenuTest.php.

52  {
53  $instance = new assLongMenu();
54  $this->assertEquals('assLongMenu', $instance->getQuestionType());
55  }

◆ test_getSolutionSubmit_shouldReturnSolution()

assLongmenuTest::test_getSolutionSubmit_shouldReturnSolution ( )

Definition at line 186 of file assLongMenuTest.php.

References $_POST, and array.

187  {
188  $obj = new assLongMenu();
189  $array = array( 0 => 'squirrel', 1 => 'icebear');
190  $_POST['answer'] = $array;
191  $this->assertEquals($obj->getSolutionSubmit(), $array);
192  }
Create styles array
The data for the language used.
$_POST["username"]

◆ test_instantiateObject_shouldReturnInstance()

assLongmenuTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 39 of file assLongMenuTest.php.

40  {
41  $instance = new assLongMenu();
42  $this->assertInstanceOf('assLongMenu', $instance);
43  }

◆ test_isComplete_shouldBeFalse()

assLongmenuTest::test_isComplete_shouldBeFalse ( )

Definition at line 97 of file assLongMenuTest.php.

References array.

98  {
99  $obj = new assLongMenu();
100  $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1'),
101  1 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
102  $obj->setAnswers(array(array(1,2,3,4)));
103  $this->assertEquals($obj->isComplete(), false);
104  }
Create styles array
The data for the language used.

◆ test_isComplete_shouldBeTrue()

assLongmenuTest::test_isComplete_shouldBeTrue ( )

Definition at line 106 of file assLongMenuTest.php.

References array.

107  {
108  $obj = new assLongMenu();
109  $obj->setCorrectAnswers(array ( 0 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1'),
110  1 => array ( 0 =>array (0 => 'answer'),1 => '2.25', 2 => '1')));
111  $obj->setAnswers(array(array(1,2,3,4)));
112  $obj->setPoints(4.5);
113  $obj->setTitle('LongMenu Title');
114  $obj->setQuestion('LongMenu Question');
115  $this->assertEquals($obj->isComplete(), true);
116  }
Create styles array
The data for the language used.

◆ test_isShuffleAnswersEnabled_shouldReturnFalse()

assLongmenuTest::test_isShuffleAnswersEnabled_shouldReturnFalse ( )

Definition at line 215 of file assLongMenuTest.php.

216  {
217  $obj = new assLongMenu();
218  $this->assertEquals(false, $obj->isShuffleAnswersEnabled());
219  $this->assertNotEquals(true, $obj->isShuffleAnswersEnabled());
220  }

◆ test_setAnswerType_shouldReturnGetAnswerType()

assLongmenuTest::test_setAnswerType_shouldReturnGetAnswerType ( )

Definition at line 194 of file assLongMenuTest.php.

195  {
196  $obj = new assLongMenu();
197  $obj->setAnswerType(0);
198  $this->assertEquals(0, $obj->getAnswerType());
199  }

◆ test_setJsonStructure_shouldReturnGetJsonStructure()

assLongmenuTest::test_setJsonStructure_shouldReturnGetJsonStructure ( )

Definition at line 208 of file assLongMenuTest.php.

References array.

209  {
210  $obj = new assLongMenu();
211  $obj->setJsonStructure(json_encode(array(1 => 'bla')));
212  $this->assertEquals('{"1":"bla"}', $obj->getJsonStructure());
213  }
Create styles array
The data for the language used.

◆ test_setLongMenuTextValue_shouldReturnGetLongMenuTextValue()

assLongmenuTest::test_setLongMenuTextValue_shouldReturnGetLongMenuTextValue ( )

Definition at line 200 of file assLongMenuTest.php.

201  {
202  $obj = new assLongMenu();
203  $this->assertEquals('', $obj->getLongMenuTextValue());
204  $obj->setLongMenuTextValue('dummy text');
205  $this->assertEquals('dummy text', $obj->getLongMenuTextValue());
206  }

Field Documentation

◆ $backupGlobals

assLongmenuTest::$backupGlobals = FALSE
protected

Definition at line 11 of file assLongMenuTest.php.


The documentation for this class was generated from the following file: