ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
assSingleChoiceTest Class Reference

Unit tests for single choice questions. More...

+ Inheritance diagram for assSingleChoiceTest:
+ Collaboration diagram for assSingleChoiceTest:

Public Member Functions

 test_isComplete_shouldReturnTrue ()
 Create a sample question and save it to the database. More...
 
 test_getThumbPrefix_shouldReturnString ()
 
 test_setOutputType_shouldReturngetOutputType ()
 
 test_getAnswerCount_shouldReturnCount ()
 
 test_flushAnswers_shouldClearAnswers ()
 
 test_getQuestionType_shouldReturnQuestionType ()
 
 test_getAdditionalTableName_shouldReturnAdditionalTableName ()
 
 test_getAnswerTableName_shouldReturnAnswerTableName ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $backupGlobals = false
 

Detailed Description

Unit tests for single choice questions.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Version
$Id$

Definition at line 13 of file assSingleChoiceTest.php.

Member Function Documentation

◆ setUp()

assSingleChoiceTest::setUp ( )
protected

Definition at line 17 of file assSingleChoiceTest.php.

18  {
19  require_once './Modules/TestQuestionPool/classes/class.assSingleChoice.php';
20  if (defined('ILIAS_PHPUNIT_CONTEXT')) {
21  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
22  ilUnitUtil::performInitialisation();
23  } else {
24  chdir(dirname(__FILE__));
25  chdir('../../../');
26  }
27  require_once './Services/Utilities/classes/class.ilUtil.php';
28  }

◆ test_flushAnswers_shouldClearAnswers()

assSingleChoiceTest::test_flushAnswers_shouldClearAnswers ( )

Definition at line 122 of file assSingleChoiceTest.php.

123  {
124  $obj = new assSingleChoice();
125  $obj->addAnswer('1', 1, 0);
126  $obj->addAnswer('1', 1, 1);
127  $this->assertEquals(2, $obj->getAnswerCount());
128  $obj->flushAnswers();
129  $this->assertEquals(0, $obj->getAnswerCount());
130  }
Class for single choice questions.

◆ test_getAdditionalTableName_shouldReturnAdditionalTableName()

assSingleChoiceTest::test_getAdditionalTableName_shouldReturnAdditionalTableName ( )

Definition at line 138 of file assSingleChoiceTest.php.

139  {
140  $obj = new assSingleChoice();
141  $this->assertEquals('qpl_qst_sc', $obj->getAdditionalTableName());
142  }
Class for single choice questions.

◆ test_getAnswerCount_shouldReturnCount()

assSingleChoiceTest::test_getAnswerCount_shouldReturnCount ( )

Definition at line 111 of file assSingleChoiceTest.php.

112  {
113  $obj = new assSingleChoice();
114  $this->assertEquals(0, $obj->getAnswerCount());
115  $obj->addAnswer('1', 1, 0);
116  $obj->addAnswer('1', 1, 1);
117  $this->assertEquals(2, $obj->getAnswerCount());
118  $obj->deleteAnswer(0);
119  $this->assertEquals(1, $obj->getAnswerCount());
120  }
Class for single choice questions.

◆ test_getAnswerTableName_shouldReturnAnswerTableName()

assSingleChoiceTest::test_getAnswerTableName_shouldReturnAnswerTableName ( )

Definition at line 144 of file assSingleChoiceTest.php.

145  {
146  $obj = new assSingleChoice();
147  $this->assertEquals('qpl_a_sc', $obj->getAnswerTableName());
148  }
Class for single choice questions.

◆ test_getQuestionType_shouldReturnQuestionType()

assSingleChoiceTest::test_getQuestionType_shouldReturnQuestionType ( )

Definition at line 132 of file assSingleChoiceTest.php.

133  {
134  $obj = new assSingleChoice();
135  $this->assertEquals('assSingleChoice', $obj->getQuestionType());
136  }
Class for single choice questions.

◆ test_getThumbPrefix_shouldReturnString()

assSingleChoiceTest::test_getThumbPrefix_shouldReturnString ( )

Definition at line 98 of file assSingleChoiceTest.php.

99  {
100  $obj = new assSingleChoice();
101  $this->assertEquals('thumb.', $obj->getThumbPrefix());
102  }
Class for single choice questions.

◆ test_isComplete_shouldReturnTrue()

assSingleChoiceTest::test_isComplete_shouldReturnTrue ( )

Create a sample question and save it to the database.

Parameters
integer$obj_idObject ID of the containing question pool object (optional)
Returns
integer ID of the newly created question Question creation test
Parameters

Definition at line 86 of file assSingleChoiceTest.php.

87  {
88  $obj = new assSingleChoice();
89  $this->assertEquals(false, $obj->isComplete());
90  $obj->setTitle('Tilte');
91  $obj->setAuthor('Me or another');
92  $obj->setQuestion('My great Question.');
93  $obj->addAnswer('Super simple single Choice', 1);
94 
95  $this->assertEquals(true, $obj->isComplete());
96  }
Class for single choice questions.

◆ test_setOutputType_shouldReturngetOutputType()

assSingleChoiceTest::test_setOutputType_shouldReturngetOutputType ( )

Definition at line 104 of file assSingleChoiceTest.php.

105  {
106  $obj = new assSingleChoice();
107  $obj->setOutputType(0);
108  $this->assertEquals(0, $obj->getOutputType());
109  }
Class for single choice questions.

Field Documentation

◆ $backupGlobals

assSingleChoiceTest::$backupGlobals = false
protected

Definition at line 15 of file assSingleChoiceTest.php.


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