ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilTestQuestionsTableGUITest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
26 {
29 
30  protected function setUp(): void
31  {
32  global $DIC;
33  parent::setUp();
34 
35  $this->addGlobal_lng();
36  $this->addGlobal_tpl();
38  $this->addGlobal_uiFactory();
39  $this->addGlobal_uiRenderer();
40 
41  $ctrl_mock = $this->createMock(ilCtrl::class);
42  $ctrl_mock->expects($this->any())
43  ->method("getFormAction")
44  ->willReturnCallback(function () {
45  return "testFormAction";
46  });
47  $this->setGlobalVariable("ilCtrl", $ctrl_mock);
48 
49  $component_factory = $this->createMock(ilComponentFactory::class);
50  $component_factory->method("getActivePluginsInSlot")->willReturn(new ArrayIterator());
51  $this->setGlobalVariable("component.factory", $component_factory);
52 
53  $this->parentObj_mock = $this->getMockBuilder(ilObjTestGUI::class)
54  ->disableOriginalConstructor()
55  ->onlyMethods(['getObject'])
56  ->getMock();
57  $this->parentObj_mock->expects($this->any())->method('getObject')->willReturn($this->createMock(ilObjTest::class));
58  $this->tableGui = new ilTestQuestionsTableGUI(
59  $this->parentObj_mock,
60  "",
61  0,
62  $this->createMock(ilAccessHandler::class),
63  $DIC['ui.factory'],
64  $DIC['ui.renderer'],
65  $this->createMock(\ILIAS\TestQuestionPool\QuestionInfoService::class)
66  );
67  }
68 
70  {
71  $this->assertInstanceOf(ilTestQuestionsTableGUI::class, $this->tableGui);
72  }
73 
74  public function testQuestionManagingEnabled(): void
75  {
76  $this->assertIsBool($this->tableGui->isQuestionManagingEnabled());
77  $this->tableGui->setQuestionManagingEnabled(false);
78  $this->assertFalse($this->tableGui->isQuestionManagingEnabled());
79  $this->tableGui->setQuestionManagingEnabled(true);
80  $this->assertTrue($this->tableGui->isQuestionManagingEnabled());
81  }
82 
83  public function testPositionInsertCommandsEnabled(): void
84  {
85  $this->assertIsBool($this->tableGui->isPositionInsertCommandsEnabled());
86  $this->tableGui->setPositionInsertCommandsEnabled(false);
87  $this->assertFalse($this->tableGui->isPositionInsertCommandsEnabled());
88  $this->tableGui->setPositionInsertCommandsEnabled(true);
89  $this->assertTrue($this->tableGui->isPositionInsertCommandsEnabled());
90  }
91 
92  public function testQuestionPositioningEnabled(): void
93  {
94  $this->assertIsBool($this->tableGui->isQuestionPositioningEnabled());
95  $this->tableGui->setQuestionPositioningEnabled(false);
96  $this->assertFalse($this->tableGui->isQuestionPositioningEnabled());
97  $this->tableGui->setQuestionPositioningEnabled(true);
98  $this->assertTrue($this->tableGui->isQuestionPositioningEnabled());
99  }
100 
102  {
103  $this->assertIsBool($this->tableGui->isObligatoryQuestionsHandlingEnabled());
104  $this->tableGui->setObligatoryQuestionsHandlingEnabled(false);
105  $this->assertFalse($this->tableGui->isObligatoryQuestionsHandlingEnabled());
106  $this->tableGui->setObligatoryQuestionsHandlingEnabled(true);
107  $this->assertTrue($this->tableGui->isObligatoryQuestionsHandlingEnabled());
108  }
109 
110  public function testTotalPoints(): void
111  {
112  $this->assertIsFloat($this->tableGui->getTotalPoints());
113  $this->tableGui->setTotalPoints(125.251);
114  $this->assertEquals(125.251, $this->tableGui->getTotalPoints());
115  }
116 
117  public function testQuestionRemoveRowButtonEnabled(): void
118  {
119  $this->assertIsBool($this->tableGui->isQuestionRemoveRowButtonEnabled());
120  $this->tableGui->setQuestionRemoveRowButtonEnabled(false);
121  $this->assertFalse($this->tableGui->isQuestionRemoveRowButtonEnabled());
122  $this->tableGui->setQuestionRemoveRowButtonEnabled(true);
123  $this->assertTrue($this->tableGui->isQuestionRemoveRowButtonEnabled());
124  }
125 }
Class ilTestQuestionsTableGUITest.
Class ilObjTestGUI.
Class ChatMainBarProvider .
global $DIC
Definition: feed.php:28
setGlobalVariable(string $name, $value)
Class ilTestBaseClass.