ILIAS  release_8 Revision v8.24
ilTestRandomQuestionSetGeneralConfigFormGUITest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21use PHPUnit\Framework\MockObject\MockObject;
22
28{
34
35 protected function setUp(): void
36 {
37 parent::setUp();
38 $ctrl_mock = $this->createMock(ilCtrl::class);
39 $lng_mock = $this->createMock(ilLanguage::class);
40 $lng_mock->expects($this->any())
41 ->method("txt")
42 ->willReturnCallback([self::class, "lngTxtCallback"]);
43
44 $this->setGlobalVariable("lng", $lng_mock);
45 $this->setGlobalVariable("ilCtrl", $ctrl_mock);
46
47 $testObject_mock = $this->createMock(ilObjTest::class);
48 $questionSetConfigGui_mock = $this->createMock(ilTestRandomQuestionSetConfigGUI::class);
49 $this->questionSetConfig_mock = $this->createMock(ilTestRandomQuestionSetConfig::class);
50
52 $ctrl_mock,
53 $lng_mock,
54 $testObject_mock,
55 $questionSetConfigGui_mock,
56 $this->questionSetConfig_mock
57 );
58 }
59
61 {
62 $this->assertInstanceOf(ilTestRandomQuestionSetGeneralConfigFormGUI::class, $this->formGui);
63 }
64
65 public function testEditModeEnabled(): void
66 {
67 $expected = true;
68
69 $this->formGui->setEditModeEnabled($expected);
70
71 $this->assertEquals($expected, $this->formGui->isEditModeEnabled());
72 }
73
74 public function testSave(): void
75 {
76 $this->formGui->build();
77
78 $this->formGui->testOBJ->setTestId(20101259);
79
80 $this->questionSetConfig_mock->expects($this->once())
81 ->method("saveToDb");
82
83 $this->formGui->save();
84 }
85
86 public static function lngTxtCallback(): string
87 {
88 $args = func_get_args();
89 switch ($args[0]) {
90 case "tst_rnd_quest_set_cfg_general_form":
91 return "testTitle";
92 default:
93 return "testValue";
94 }
95 }
96}
Class ilTestBaseClass.
setGlobalVariable(string $name, $value)