ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 13 of file assLongMenuTest.php.

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

Referenced by test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnFalse(), and test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnTrue().

+ Here is the caller graph for this function:

◆ setUp()

assLongmenuTest::setUp ( )
protected

Definition at line 20 of file assLongMenuTest.php.

21 {
22 require_once './Modules/TestQuestionPool/classes/class.assLongMenu.php';
23 if (defined('ILIAS_PHPUNIT_CONTEXT'))
24 {
25 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
26 ilUnitUtil::performInitialisation();
27 }
28 else
29 {
30 chdir( dirname( __FILE__ ) );
31 chdir('../../../');
32 }
33 require_once './Services/Utilities/classes/class.ilUtil.php';
34 }

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerDoesNotExistsInAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerDoesNotExistsInAnswers ( )

Definition at line 143 of file assLongMenuTest.php.

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

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoAnswers ( )

Definition at line 151 of file assLongMenuTest.php.

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

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoPoints()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerHasNoPoints ( )

Definition at line 159 of file assLongMenuTest.php.

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

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerPointsAreZero()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseCorrectAnswerPointsAreZero ( )

Definition at line 167 of file assLongMenuTest.php.

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

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseNoCustomPart()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseNoCustomPart ( )

Definition at line 115 of file assLongMenuTest.php.

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

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyAnswers ( )

Definition at line 121 of file assLongMenuTest.php.

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

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyCorrectAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseOnlyCorrectAnswers ( )

Definition at line 128 of file assLongMenuTest.php.

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

◆ test_checkQuestionCustomPart_shouldBeFalseBecauseToManyCorrectAnswers()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeFalseBecauseToManyCorrectAnswers ( )

Definition at line 135 of file assLongMenuTest.php.

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

◆ test_checkQuestionCustomPart_shouldBeTrue()

assLongmenuTest::test_checkQuestionCustomPart_shouldBeTrue ( )

Definition at line 175 of file assLongMenuTest.php.

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

◆ test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnFalse()

assLongmenuTest::test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnFalse ( )

Definition at line 68 of file assLongMenuTest.php.

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

References getMethod().

+ Here is the call graph for this function:

◆ test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnTrue()

assLongmenuTest::test_correctAnswerDoesNotExistInAnswerOptions_shouldReturnTrue ( )

Definition at line 60 of file assLongMenuTest.php.

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

References getMethod().

+ Here is the call graph for this function:

◆ test_getAdditionalTableName_shouldReturnString()

assLongmenuTest::test_getAdditionalTableName_shouldReturnString ( )

Definition at line 42 of file assLongMenuTest.php.

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

◆ test_getAnswerTableName_shouldReturnString()

assLongmenuTest::test_getAnswerTableName_shouldReturnString ( )

Definition at line 54 of file assLongMenuTest.php.

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

◆ test_getMaximumPoints_shouldBeFour()

assLongmenuTest::test_getMaximumPoints_shouldBeFour ( )

Definition at line 76 of file assLongMenuTest.php.

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

◆ test_getMaximumPoints_shouldBeFourPointFive()

assLongmenuTest::test_getMaximumPoints_shouldBeFourPointFive ( )

Definition at line 85 of file assLongMenuTest.php.

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

◆ test_getQuestionType_shouldReturnString()

assLongmenuTest::test_getQuestionType_shouldReturnString ( )

Definition at line 48 of file assLongMenuTest.php.

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

◆ test_getSolutionSubmit_shouldReturnSolution()

assLongmenuTest::test_getSolutionSubmit_shouldReturnSolution ( )

Definition at line 183 of file assLongMenuTest.php.

184 {
185 $obj = new assLongMenu();
186 $array = array( 0 => 'squirrel', 1 => 'icebear');
187 $_POST['answer'] = $array;
188 $this->assertEquals($obj->getSolutionSubmit(), $array);
189 }
$_POST['username']
Definition: cron.php:12

References $_POST.

◆ test_instantiateObject_shouldReturnInstance()

assLongmenuTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 36 of file assLongMenuTest.php.

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

◆ test_isComplete_shouldBeFalse()

assLongmenuTest::test_isComplete_shouldBeFalse ( )

Definition at line 94 of file assLongMenuTest.php.

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

◆ test_isComplete_shouldBeTrue()

assLongmenuTest::test_isComplete_shouldBeTrue ( )

Definition at line 103 of file assLongMenuTest.php.

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

◆ test_isShuffleAnswersEnabled_shouldReturnFalse()

assLongmenuTest::test_isShuffleAnswersEnabled_shouldReturnFalse ( )

Definition at line 212 of file assLongMenuTest.php.

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

◆ test_setAnswerType_shouldReturnGetAnswerType()

assLongmenuTest::test_setAnswerType_shouldReturnGetAnswerType ( )

Definition at line 191 of file assLongMenuTest.php.

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

◆ test_setJsonStructure_shouldReturnGetJsonStructure()

assLongmenuTest::test_setJsonStructure_shouldReturnGetJsonStructure ( )

Definition at line 205 of file assLongMenuTest.php.

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

◆ test_setLongMenuTextValue_shouldReturnGetLongMenuTextValue()

assLongmenuTest::test_setLongMenuTextValue_shouldReturnGetLongMenuTextValue ( )

Definition at line 197 of file assLongMenuTest.php.

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

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: