ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

References $name.

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

◆ setUp()

assLongmenuTest::setUp ( )
protected

Definition at line 22 of file assLongMenuTest.php.

References $GLOBALS.

23  {
24  $GLOBALS['DIC']['ilDB'] = 'test';
25 
26  require_once './Modules/TestQuestionPool/classes/class.assLongMenu.php';
27  if (defined('ILIAS_PHPUNIT_CONTEXT')) {
28  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
29  ilUnitUtil::performInitialisation();
30  } else {
31  chdir(dirname(__FILE__));
32  chdir('../../../');
33  }
34  require_once './Services/Utilities/classes/class.ilUtil.php';
35  }
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerDoesNotExistsInAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerDoesNotExistsInAnswers ( )

Definition at line 144 of file assLongMenuTest.php.

145  {
146  $obj = new assLongMenu();
147  $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1')));
148  $obj->setAnswers(array(array(1)));
149  $this->assertEquals($obj->checkQuestionCustomPart(), false);
150  }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoAnswers ( )

Definition at line 152 of file assLongMenuTest.php.

153  {
154  $obj = new assLongMenu();
155  $obj->setCorrectAnswers(array( 0 => array( 0 => array(),1 => '2.25', 2 => '1')));
156  $obj->setAnswers(array(array('answer')));
157  $this->assertEquals($obj->checkQuestionCustomPart(), false);
158  }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoPoints()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoPoints ( )

Definition at line 160 of file assLongMenuTest.php.

161  {
162  $obj = new assLongMenu();
163  $obj->setCorrectAnswers(array( 0 => array( 0 => array())));
164  $obj->setAnswers(array(array('answer')));
165  $this->assertEquals($obj->checkQuestionCustomPart(), false);
166  }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerPointsAreZero()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerPointsAreZero ( )

Definition at line 168 of file assLongMenuTest.php.

169  {
170  $obj = new assLongMenu();
171  $obj->setCorrectAnswers(array( 0 => array( 0 => array('answer'),1 => 0, 2 => '1')));
172  $obj->setAnswers(array(array('answer')));
173  $this->assertEquals($obj->checkQuestionCustomPart(), false);
174  }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseNoCustomPart()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseNoCustomPart ( )

Definition at line 116 of file assLongMenuTest.php.

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

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyAnswers ( )

Definition at line 122 of file assLongMenuTest.php.

123  {
124  $obj = new assLongMenu();
125  $obj->setAnswers(array(array(1,2,3,4)));
126  $this->assertEquals($obj->checkQuestionCustomPart(), false);
127  }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyCorrectAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyCorrectAnswers ( )

Definition at line 129 of file assLongMenuTest.php.

130  {
131  $obj = new assLongMenu();
132  $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1'),
133  1 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1')));
134  $this->assertEquals($obj->checkQuestionCustomPart(), false);
135  }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseToManyCorrectAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseToManyCorrectAnswers ( )

Definition at line 136 of file assLongMenuTest.php.

137  {
138  $obj = new assLongMenu();
139  $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1'),
140  1 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1')));
141  $obj->setAnswers(array(array('answer')));
142  $this->assertEquals($obj->checkQuestionCustomPart(), false);
143  }

◆ test_checkQuestionCustomPart_shouldBeTrue()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeTrue ( )

Definition at line 176 of file assLongMenuTest.php.

177  {
178  $obj = new assLongMenu();
179  $obj->setCorrectAnswers(array( 0 => array( 0 => array('answer'),1 => 1, 2 => '1')));
180  $obj->setAnswers(array(array('answer')));
181  $this->assertEquals($obj->checkQuestionCustomPart(), true);
182  }

◆ test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnFalse()

assLongmenuTest::test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnFalse ( )

Definition at line 69 of file assLongMenuTest.php.

70  {
71  $method = self::getMethod('correctAnswerDoesNotExistInAnswerOptions');
72  $obj = new assLongMenu();
73  $value = $method->invokeArgs($obj, array(array(array(1),1,1), array(1,2,3,4)));
74  $this->assertEquals(false, $value);
75  }

◆ test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnTrue()

assLongmenuTest::test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnTrue ( )

Definition at line 61 of file assLongMenuTest.php.

62  {
63  $method = self::getMethod('correctAnswerDoesNotExistInAnswerOptions');
64  $obj = new assLongMenu();
65  $value = $method->invokeArgs($obj, array(array(array(5),1,1), array(1,2,3,4)));
66  $this->assertEquals(true, $value);
67  }

◆ test_getAdditionalTableName_shouldReturnString()

assLongmenuTest::test_getAdditionalTableName_shouldReturnString ( )

Definition at line 43 of file assLongMenuTest.php.

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

◆ test_getAnswerTableName_shouldReturnString()

assLongmenuTest::test_getAnswerTableName_shouldReturnString ( )

Definition at line 55 of file assLongMenuTest.php.

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

◆ test_getMaximumPoints_shouldBeFour()

assLongmenuTest::test_getMaximumPoints_shouldBeFour ( )

Definition at line 77 of file assLongMenuTest.php.

78  {
79  $obj = new assLongMenu();
80  $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 => 'answer'),1 => '2', 2 => '1'),
81  1 => array( 0 => array(0 => 'answer'),1 => '2', 2 => '1')));
82  $value = $obj->getMaximumPoints();
83  $this->assertEquals(4, $value);
84  }

◆ test_getMaximumPoints_shouldBeFourPointFive()

assLongmenuTest::test_getMaximumPoints_shouldBeFourPointFive ( )

Definition at line 86 of file assLongMenuTest.php.

87  {
88  $obj = new assLongMenu();
89  $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1'),
90  1 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1')));
91  $value = $obj->getMaximumPoints();
92  $this->assertEquals(4.5, $value);
93  }

◆ test_getQuestionType_shouldReturnString()

assLongmenuTest::test_getQuestionType_shouldReturnString ( )

Definition at line 49 of file assLongMenuTest.php.

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

◆ test_getSolutionSubmit_shouldReturnSolution()

assLongmenuTest::test_getSolutionSubmit_shouldReturnSolution ( )

Definition at line 184 of file assLongMenuTest.php.

References $_POST.

185  {
186  $obj = new assLongMenu();
187  $array = array( 0 => 'squirrel', 1 => 'icebear');
188  $_POST['answer'] = $array;
189  $this->assertEquals($obj->getSolutionSubmit(), $array);
190  }
$_POST["username"]

◆ test_instantiateObject_shouldReturnInstance()

assLongmenuTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 37 of file assLongMenuTest.php.

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

◆ test_isComplete_shouldBeFalse()

assLongmenuTest::test_isComplete_shouldBeFalse ( )

Definition at line 95 of file assLongMenuTest.php.

96  {
97  $obj = new assLongMenu();
98  $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1'),
99  1 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1')));
100  $obj->setAnswers(array(array(1,2,3,4)));
101  $this->assertEquals($obj->isComplete(), false);
102  }

◆ test_isComplete_shouldBeTrue()

assLongmenuTest::test_isComplete_shouldBeTrue ( )

Definition at line 104 of file assLongMenuTest.php.

105  {
106  $obj = new assLongMenu();
107  $obj->setCorrectAnswers(array( 0 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1'),
108  1 => array( 0 => array(0 => 'answer'),1 => '2.25', 2 => '1')));
109  $obj->setAnswers(array(array(1,2,3,4)));
110  $obj->setPoints(4.5);
111  $obj->setTitle('LongMenu Title');
112  $obj->setLongMenuTextValue('LongMenu Question');
113  $this->assertEquals($obj->isComplete(), true);
114  }

◆ test_isShuffleAnswersEnabled_shouldReturnFalse()

assLongmenuTest::test_isShuffleAnswersEnabled_shouldReturnFalse ( )

Definition at line 213 of file assLongMenuTest.php.

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

◆ test_setAnswerType_shouldReturnGetAnswerType()

assLongmenuTest::test_setAnswerType_shouldReturnGetAnswerType ( )

Definition at line 192 of file assLongMenuTest.php.

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

◆ test_setJsonStructure_shouldReturnGetJsonStructure()

assLongmenuTest::test_setJsonStructure_shouldReturnGetJsonStructure ( )

Definition at line 206 of file assLongMenuTest.php.

207  {
208  $obj = new assLongMenu();
209  $obj->setJsonStructure(json_encode(array(1 => 'bla')));
210  $this->assertEquals('{"1":"bla"}', $obj->getJsonStructure());
211  }

◆ test_setLongMenuTextValue_shouldReturnGetLongMenuTextValue()

assLongmenuTest::test_setLongMenuTextValue_shouldReturnGetLongMenuTextValue ( )

Definition at line 198 of file assLongMenuTest.php.

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

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: