ILIAS  release_8 Revision v8.24
assOrderingQuestionTest Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for assOrderingQuestionTest:
+ Collaboration diagram for assOrderingQuestionTest:

Public Member Functions

 test_instantiateObject_shouldReturnInstance ()
 
 testOrderingElementListDefaults ()
 
 testOrderingElementListMutation (ilAssOrderingElementList $list)
 @depends testOrderingElementListDefaults More...
 
 testOrderingElementDefaults ()
 
 testOrderingElementMutation (ilAssOrderingElement $element)
 @depends testOrderingElementDefaults More...
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from assBaseTestCase
 setUp ()
 
 tearDown ()
 
 setGlobalVariable (string $name, $value)
 
 getGlobalTemplateMock ()
 
 getDatabaseMock ()
 
 getIliasMock ()
 

Protected Attributes

 $backupGlobals = false
 
- Protected Attributes inherited from assBaseTestCase
Container $dic = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Unit tests

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de

Definition at line 26 of file assOrderingQuestionTest.php.

Member Function Documentation

◆ setUp()

assOrderingQuestionTest::setUp ( )
protected

Reimplemented from assBaseTestCase.

Definition at line 30 of file assOrderingQuestionTest.php.

30 : void
31 {
32 parent::setUp();
33
34 $ilCtrl_mock = $this->getMockBuilder(ilCtrl::class)
35 ->disableOriginalConstructor()
36 ->getMock();
37 $ilCtrl_mock->method('saveParameter');
38 $ilCtrl_mock->method('saveParameterByClass');
39 $this->setGlobalVariable('ilCtrl', $ilCtrl_mock);
40
41 $lng_mock = $this->getMockBuilder(ilLanguage::class)
42 ->disableOriginalConstructor()
43 ->onlyMethods(['txt'])
44 ->getMock();
45 $lng_mock->method('txt')->will($this->returnValue('Test'));
46 $this->setGlobalVariable('lng', $lng_mock);
47
48 $this->setGlobalVariable('ilias', $this->getIliasMock());
49 $this->setGlobalVariable('tpl', $this->getGlobalTemplateMock());
50 $this->setGlobalVariable('ilDB', $this->getDatabaseMock());
51 }
setGlobalVariable(string $name, $value)

References assBaseTestCase\getDatabaseMock(), assBaseTestCase\getGlobalTemplateMock(), assBaseTestCase\getIliasMock(), and assBaseTestCase\setGlobalVariable().

+ Here is the call graph for this function:

◆ test_instantiateObject_shouldReturnInstance()

assOrderingQuestionTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 53 of file assOrderingQuestionTest.php.

53 : void
54 {
55 // Arrange
56 require_once './Modules/TestQuestionPool/classes/class.assOrderingQuestion.php';
57
58 // Act
59 $instance = new assOrderingQuestion();
60
61 $this->assertInstanceOf('assOrderingQuestion', $instance);
62 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ testOrderingElementDefaults()

assOrderingQuestionTest::testOrderingElementDefaults ( )

Definition at line 83 of file assOrderingQuestionTest.php.

84 {
85 $element_id = 12;
86 $element = new ilAssOrderingElement($element_id);
87 $this->assertInstanceOf('ilAssOrderingElement', $element);
88 $this->assertEquals($element_id, $element->getId());
89 return $element;
90 }

◆ testOrderingElementListDefaults()

assOrderingQuestionTest::testOrderingElementListDefaults ( )

Definition at line 64 of file assOrderingQuestionTest.php.

65 {
66 $question_id = 7;
67 $list = new ilAssOrderingElementList($question_id);
68 $this->assertInstanceOf('ilAssOrderingElementList', $list);
69 $this->assertEquals($question_id, $list->getQuestionId());
70 $this->assertEquals([], $list->getElements());
71 return $list;
72 }

◆ testOrderingElementListMutation()

assOrderingQuestionTest::testOrderingElementListMutation ( ilAssOrderingElementList  $list)

@depends testOrderingElementListDefaults

Definition at line 77 of file assOrderingQuestionTest.php.

78 {
79 $original = $list;
80 $this->assertNotEquals($original, $list->withElements([]));
81 }

References ilAssOrderingElementList\withElements().

+ Here is the call graph for this function:

◆ testOrderingElementMutation()

assOrderingQuestionTest::testOrderingElementMutation ( ilAssOrderingElement  $element)

@depends testOrderingElementDefaults

Definition at line 95 of file assOrderingQuestionTest.php.

96 {
97 $original = $element;
98 $val = 21;
99
100 $element = $original->withRandomIdentifier($val);
101 $this->assertNotEquals($original, $element);
102 $this->assertEquals($val, $element->getRandomIdentifier());
103
104 $element = $original->withSolutionIdentifier($val);
105 $this->assertNotEquals($original, $element);
106 $this->assertEquals($val, $element->getSolutionIdentifier());
107
108 $element = $original->withPosition($val);
109 $this->assertNotEquals($original, $element);
110 $this->assertEquals($val, $element->getPosition());
111
112 $element = $original->withIndentation($val);
113 $this->assertNotEquals($original, $element);
114 $this->assertEquals($val, $element->getIndentation());
115
116 $val = 'some string';
117 $element = $original->withContent($val);
118 $this->assertNotEquals($original, $element);
119 $this->assertEquals($val, $element->getContent());
120 }

References ilAssOrderingElement\getContent(), ilAssOrderingElement\getIndentation(), ilAssOrderingElement\getPosition(), ilAssOrderingElement\getRandomIdentifier(), ilAssOrderingElement\getSolutionIdentifier(), ilAssOrderingElement\withContent(), ilAssOrderingElement\withIndentation(), ilAssOrderingElement\withPosition(), ilAssOrderingElement\withRandomIdentifier(), and ilAssOrderingElement\withSolutionIdentifier().

+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

assOrderingQuestionTest::$backupGlobals = false
protected

Definition at line 28 of file assOrderingQuestionTest.php.


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