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

Unit tests. More...

+ Inheritance diagram for assKprimChoiceTest:
+ Collaboration diagram for assKprimChoiceTest:

Public Member Functions

 test_instantiateObject_shouldReturnInstance ()
 
 test_getQuestionType_shouldReturnQuestionType ()
 
 test_getAdditionalTableName_shouldReturnAdditionalTableName ()
 
 test_getAnswerTableName_shouldReturnAnswerTableName ()
 
 test_isCompleteWithoutAnswer_shouldReturnTrue ()
 
 test_isCompleteWithAnswer_shouldReturnTrue ()
 
 test_isValidOptionLabel_shouldReturnTrue ()
 
 test_isObligationPossible_shouldReturnTrue ()
 
 test_getAnswer_shouldReturnAnswer ()
 
 test_isValidAnswerType_shouldReturnTrue ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $backupGlobals = false
 

Detailed Description

Unit tests.

Author
Guido Vollbach <gvollbachdatabay.de>

Definition at line 9 of file assKprimChoiceTest.php.

Member Function Documentation

◆ setUp()

assKprimChoiceTest::setUp ( )
protected

Definition at line 13 of file assKprimChoiceTest.php.

14  {
15  require_once './Modules/TestQuestionPool/classes/class.assKprimChoice.php';
16  require_once './Modules/TestQuestionPool/classes/class.ilAssKprimChoiceAnswer.php';
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  require_once './Services/Utilities/classes/class.ilUtil.php';
25  }

◆ test_getAdditionalTableName_shouldReturnAdditionalTableName()

assKprimChoiceTest::test_getAdditionalTableName_shouldReturnAdditionalTableName ( )

Definition at line 39 of file assKprimChoiceTest.php.

40  {
41  $obj = new assKprimChoice();
42  $this->assertEquals('qpl_qst_kprim', $obj->getAdditionalTableName());
43  }

◆ test_getAnswer_shouldReturnAnswer()

assKprimChoiceTest::test_getAnswer_shouldReturnAnswer ( )

Definition at line 95 of file assKprimChoiceTest.php.

96  {
97  $obj = new assKprimChoice();
98  $ans = new ilAssKprimChoiceAnswer();
99  $ans->setCorrectness(true);
100  $ans->setAnswertext('Text');
101  $obj->addAnswer($ans);
102  $this->assertInstanceOf('ilAssKprimChoiceAnswer', $obj->getAnswer(0));
103  $this->assertEquals(null, $obj->getAnswer(1));
104  }

◆ test_getAnswerTableName_shouldReturnAnswerTableName()

assKprimChoiceTest::test_getAnswerTableName_shouldReturnAnswerTableName ( )

Definition at line 45 of file assKprimChoiceTest.php.

46  {
47  $obj = new assKprimChoice();
48  $this->assertEquals('qpl_a_kprim', $obj->getAnswerTableName());
49  }

◆ test_getQuestionType_shouldReturnQuestionType()

assKprimChoiceTest::test_getQuestionType_shouldReturnQuestionType ( )

Definition at line 33 of file assKprimChoiceTest.php.

34  {
35  $obj = new assKprimChoice();
36  $this->assertEquals('assKprimChoice', $obj->getQuestionType());
37  }

◆ test_instantiateObject_shouldReturnInstance()

assKprimChoiceTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 27 of file assKprimChoiceTest.php.

28  {
29  $instance = new assKprimChoice();
30  $this->assertInstanceOf('assKprimChoice', $instance);
31  }

◆ test_isCompleteWithAnswer_shouldReturnTrue()

assKprimChoiceTest::test_isCompleteWithAnswer_shouldReturnTrue ( )

Definition at line 63 of file assKprimChoiceTest.php.

64  {
65  $obj = new assKprimChoice();
66  $this->assertEquals(false, $obj->isComplete());
67  $obj->setTitle('Tilte');
68  $obj->setAuthor('Me or another');
69  $obj->setQuestion('My great Question.');
70  $obj->setPoints(1);
71  $ans = new ilAssKprimChoiceAnswer();
72  $obj->addAnswer($ans);
73  $this->assertEquals(false, $obj->isComplete());
74  $ans->setCorrectness(true);
75  $obj->addAnswer($ans);
76  $this->assertEquals(false, $obj->isComplete());
77  $ans->setAnswertext('Text');
78  $obj->addAnswer($ans);
79  $this->assertEquals(true, $obj->isComplete());
80  }

◆ test_isCompleteWithoutAnswer_shouldReturnTrue()

assKprimChoiceTest::test_isCompleteWithoutAnswer_shouldReturnTrue ( )

Definition at line 51 of file assKprimChoiceTest.php.

52  {
53  $obj = new assKprimChoice();
54  $this->assertEquals(false, $obj->isComplete());
55  $obj->setTitle('Tilte');
56  $obj->setAuthor('Me or another');
57  $obj->setQuestion('My great Question.');
58  $this->assertEquals(false, $obj->isComplete());
59  $obj->setPoints(1);
60  $this->assertEquals(true, $obj->isComplete());
61  }

◆ test_isObligationPossible_shouldReturnTrue()

assKprimChoiceTest::test_isObligationPossible_shouldReturnTrue ( )

Definition at line 89 of file assKprimChoiceTest.php.

90  {
91  $obj = new assKprimChoice();
92  $this->assertEquals(true, $obj->isObligationPossible(1));
93  }

◆ test_isValidAnswerType_shouldReturnTrue()

assKprimChoiceTest::test_isValidAnswerType_shouldReturnTrue ( )

Definition at line 106 of file assKprimChoiceTest.php.

107  {
108  $obj = new assKprimChoice();
109  $this->assertEquals(false, $obj->isValidAnswerType('not valid'));
110  $this->assertEquals(true, $obj->isValidAnswerType($obj::ANSWER_TYPE_SINGLE_LINE));
111  }

◆ test_isValidOptionLabel_shouldReturnTrue()

assKprimChoiceTest::test_isValidOptionLabel_shouldReturnTrue ( )

Definition at line 82 of file assKprimChoiceTest.php.

83  {
84  $obj = new assKprimChoice();
85  $this->assertEquals(false, $obj->isValidOptionLabel('not valid'));
86  $this->assertEquals(true, $obj->isValidOptionLabel($obj::OPTION_LABEL_RIGHT_WRONG));
87  }

Field Documentation

◆ $backupGlobals

assKprimChoiceTest::$backupGlobals = false
protected

Definition at line 11 of file assKprimChoiceTest.php.


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