ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
assOrderingQuestionTest.php
Go to the documentation of this file.
1 <?php
2 
27 {
28  protected $backupGlobals = false;
29 
30  protected function setUp(): 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  }
52 
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  }
63 
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  }
73 
78  {
79  $original = $list;
80  $this->assertNotEquals($original, $list->withElements([]));
81  }
82 
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  }
91 
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  }
121 }
Class assBaseTestCase.
testOrderingElementListMutation(ilAssOrderingElementList $list)
testOrderingElementListDefaults
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setGlobalVariable(string $name, $value)
testOrderingElementMutation(ilAssOrderingElement $element)
testOrderingElementDefaults