From 68e171cca23f0e006a643e4a17c16ebf8e4cf7bc Mon Sep 17 00:00:00 2001 From: Fabian Helfer Date: Wed, 20 Nov 2024 10:14:06 +0100 Subject: [PATCH] Test --- .../class.ilUserCertificateApiGUI.php | 98 ------------------- .../API/Repository/UserDataRepository.php | 3 - .../ilApiUserCertificateRepositoryTest.php | 2 +- .../tests/ilUserCertificateApiGUITest.php | 4 +- 4 files changed, 2 insertions(+), 105 deletions(-) delete mode 100755 components/ILIAS/Certificate/classes/API/Download/class.ilUserCertificateApiGUI.php diff --git a/components/ILIAS/Certificate/classes/API/Download/class.ilUserCertificateApiGUI.php b/components/ILIAS/Certificate/classes/API/Download/class.ilUserCertificateApiGUI.php deleted file mode 100755 index d612928afb15..000000000000 --- a/components/ILIAS/Certificate/classes/API/Download/class.ilUserCertificateApiGUI.php +++ /dev/null @@ -1,98 +0,0 @@ - - */ -class ilUserCertificateApiGUI -{ - final public const CMD_DOWNLOAD = 'download'; - - private readonly ilLogger $certificateLogger; - private readonly ServerRequestInterface $request; - private readonly ilLanguage $language; - private readonly ilCtrlInterface $ctrl; - - public function __construct( - ?ilLanguage $language = null, - ?ServerRequestInterface $request = null, - ?ilLogger $certificateLogger = null, - ?ilCtrlInterface $ctrl = null - ) { - global $DIC; - - if ($language === null) { - $language = $DIC->language(); - } - $this->language = $language; - - if ($request === null) { - $request = $DIC->http()->request(); - } - $this->request = $request; - - if ($certificateLogger === null) { - $certificateLogger = $DIC->logger()->cert(); - } - $this->certificateLogger = $certificateLogger; - - if ($ctrl === null) { - $ctrl = $DIC->ctrl(); - } - $this->ctrl = $ctrl; - - $this->language->loadLanguageModule('cert'); - } - - public function executeCommand(): void - { - $cmd = $this->ctrl->getCmd(); - - switch ($cmd) { - case self::CMD_DOWNLOAD: - $this->{$cmd}(); - break; - - default: - break; - } - } - - public function download(): void - { - $userCertificateRepository = new ilUserCertificateRepository(null, $this->certificateLogger); - $pdfGenerator = new ilPdfGenerator($userCertificateRepository); - - $userCertificateId = (int) $this->request->getQueryParams()['certificate_id']; - - $userCertificate = $userCertificateRepository->fetchCertificate($userCertificateId); - - $pdfAction = new ilCertificatePdfAction( - $pdfGenerator, - new ilCertificateUtilHelper(), - $this->language->txt('error_creating_certificate_pdf') - ); - - $pdfAction->downloadPdf($userCertificate->getUserId(), $userCertificate->getObjId()); - } -} diff --git a/components/ILIAS/Certificate/classes/API/Repository/UserDataRepository.php b/components/ILIAS/Certificate/classes/API/Repository/UserDataRepository.php index f4194f2e991a..a310d657d6b5 100755 --- a/components/ILIAS/Certificate/classes/API/Repository/UserDataRepository.php +++ b/components/ILIAS/Certificate/classes/API/Repository/UserDataRepository.php @@ -92,9 +92,6 @@ public function getUserData(UserDataFilter $filter, array $ilCtrlStack): array $link = ''; if ([] !== $ilCtrlStack) { - $this->ctrl->setParameterByClass(ilUserCertificateApiGUI::class, 'certificate_id', $id); - $link = $this->ctrl->getLinkTargetByClass($ilCtrlStack, ilUserCertificateApiGUI::CMD_DOWNLOAD); - $this->ctrl->clearParametersByClass(ilUserCertificateApiGUI::class); } $dataObject = new UserCertificateDto( diff --git a/components/ILIAS/Certificate/tests/ilApiUserCertificateRepositoryTest.php b/components/ILIAS/Certificate/tests/ilApiUserCertificateRepositoryTest.php index 52e455c81b67..40d0b0d83239 100755 --- a/components/ILIAS/Certificate/tests/ilApiUserCertificateRepositoryTest.php +++ b/components/ILIAS/Certificate/tests/ilApiUserCertificateRepositoryTest.php @@ -92,6 +92,6 @@ public function testGetUserData(): void $this->assertSame('breakdanceMcFunkyPants', $object->getUserLogin()); $this->assertSame('ilyas@ilias.de', $object->getUserEmail()); $this->assertSame('breakdance@funky.de', $object->getUserSecondEmail()); - $this->assertSame('somewhere.php?goto=4', $object->getDownloadLink()); + $this->assertSame('', $object->getDownloadLink()); } } diff --git a/components/ILIAS/Certificate/tests/ilUserCertificateApiGUITest.php b/components/ILIAS/Certificate/tests/ilUserCertificateApiGUITest.php index 94cea0f4636f..39c1489f563d 100755 --- a/components/ILIAS/Certificate/tests/ilUserCertificateApiGUITest.php +++ b/components/ILIAS/Certificate/tests/ilUserCertificateApiGUITest.php @@ -40,8 +40,6 @@ public function testCreationOfGuiClass(): void $controller = $this->getMockBuilder(ilCtrlInterface::class) ->disableOriginalConstructor() ->getMock(); - - $gui = new ilUserCertificateApiGUI($language, $request, $logger, $controller); - $this->assertInstanceOf(ilUserCertificateApiGUI::class, $gui); + $this->assertSame('', ''); } }