From 1cc38d2b824354fe9e129e14124b7aefc4bf6e48 Mon Sep 17 00:00:00 2001 From: Fadi Asbih Date: Tue, 1 Sep 2026 12:20:47 +0200 Subject: [PATCH] [FIX] 48255: Route hint requests in question preview --- .../ILIAS/Test/classes/class.ilObjTestGUI.php | 12 ++++ .../ILIAS/Test/tests/ilObjTestGUITest.php | 59 +++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/components/ILIAS/Test/classes/class.ilObjTestGUI.php b/components/ILIAS/Test/classes/class.ilObjTestGUI.php index 4a9c267d2da5..d09cd5b1a1ae 100755 --- a/components/ILIAS/Test/classes/class.ilObjTestGUI.php +++ b/components/ILIAS/Test/classes/class.ilObjTestGUI.php @@ -1076,6 +1076,18 @@ protected function forwardCommandToQuestionPreview( $this->ctrl->getLinkTargetByClass(self::class, self::SHOW_QUESTIONS_CMD) ); $this->ctrl->saveParameterByClass(self::class, 'q_id'); + $this->dispatchQuestionPreviewCommand($gui, $cmd); + } + + protected function dispatchQuestionPreviewCommand( + ilAssQuestionPreviewGUI $gui, + string $cmd + ): void { + if ($this->ctrl->getNextClass($gui) !== '') { + $this->ctrl->forwardCommand($gui); + return; + } + $gui->{$cmd . 'Cmd'}(); } diff --git a/components/ILIAS/Test/tests/ilObjTestGUITest.php b/components/ILIAS/Test/tests/ilObjTestGUITest.php index 3aadfb8303fc..31fa64b216ff 100755 --- a/components/ILIAS/Test/tests/ilObjTestGUITest.php +++ b/components/ILIAS/Test/tests/ilObjTestGUITest.php @@ -134,4 +134,63 @@ public function testCancelCreateQuestionObject(): void ; $testObj->cancelCreateQuestionObject(); } + + public function testDispatchQuestionPreviewCommandDirectly(): void + { + $ctrl_mock = $this->createMock(ilCtrl::class); + $this->setGlobalVariable('ilCtrl', $ctrl_mock); + $testObj = $this->getNewTestGUI(); + $preview_gui = $this->getMockBuilder(ilAssQuestionPreviewGUI::class) + ->disableOriginalConstructor() + ->onlyMethods(['showCmd']) + ->getMock(); + + $ctrl_mock + ->expects($this->once()) + ->method('getNextClass') + ->with($preview_gui) + ->willReturn(''); + $ctrl_mock + ->expects($this->never()) + ->method('forwardCommand'); + $preview_gui + ->expects($this->once()) + ->method('showCmd'); + + self::callMethod( + $testObj, + 'dispatchQuestionPreviewCommand', + [$preview_gui, ilAssQuestionPreviewGUI::CMD_SHOW] + ); + } + + public function testDispatchQuestionPreviewCommandToChildGui(): void + { + $ctrl_mock = $this->createMock(ilCtrl::class); + $this->setGlobalVariable('ilCtrl', $ctrl_mock); + $testObj = $this->getNewTestGUI(); + $preview_gui = $this->getMockBuilder(ilAssQuestionPreviewGUI::class) + ->disableOriginalConstructor() + ->onlyMethods(['showCmd']) + ->getMock(); + + $ctrl_mock + ->expects($this->once()) + ->method('getNextClass') + ->with($preview_gui) + ->willReturn(strtolower(ilAssQuestionHintRequestGUI::class)); + $ctrl_mock + ->expects($this->once()) + ->method('forwardCommand') + ->with($preview_gui); + $preview_gui + ->expects($this->never()) + ->method('showCmd'); + + self::callMethod( + $testObj, + 'dispatchQuestionPreviewCommand', + [$preview_gui, ilAssQuestionPreviewGUI::CMD_SHOW] + ); + } }