Skip to content

Commit

Permalink
[FIX] use Streams for Certificate-ZIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansenDatabay committed Nov 13, 2023
1 parent 9dd1af0 commit 5227b05
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ public function zipAndDeliver(array $streams, string $download_filename): void
);
}

public function deliverFile(string $zipPath, string $zipFileName, string $mime): void
{
$this->delivery->delivery()->

ilFileDelivery::deliverFileLegacy($zipPath, $zipFileName, $mime);
}

public function getDir(string $copyDirectory): array
{
return ilFileUtils::getDir($copyDirectory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function testFileCanBeUploaded(): void
->method('delete');

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper->expects($this->exactly(2))
Expand Down Expand Up @@ -158,6 +159,7 @@ public function testPendingFilesCanBeUploaded(): void
->method('writeStream');

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper->expects($this->exactly(2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public function testIsActive(): void
->disableOriginalConstructor()
->getMock();

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$provider = new ilCertificateLearningHistoryProvider(
10,
$learningHistoryFactory,
Expand All @@ -71,7 +75,8 @@ public function testIsActive(): void
$controller,
$certificateSettings,
$uiFactory,
$uiRenderer
$uiRenderer,
$utilHelper
);

$this->assertTrue($provider->isActive());
Expand Down Expand Up @@ -304,6 +309,10 @@ public function testGetName(): void
->disableOriginalConstructor()
->getMock();

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$provider = new ilCertificateLearningHistoryProvider(
10,
$learningHistoryFactory,
Expand All @@ -314,7 +323,8 @@ public function testGetName(): void
$controller,
$certificateSettings,
$uiFactory,
$uiRenderer
$uiRenderer,
$utilHelper
);

$this->assertSame('Certificates', $provider->getName());
Expand Down
3 changes: 3 additions & 0 deletions Services/Certificate/test/ilCertificatePdfActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function testCreatePdfWillCreatedAndIsDownloadable(): void
->willReturn('Something');

$ilUtilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$errorHandler = $this->getMockBuilder(ilErrorHandling::class)
Expand Down Expand Up @@ -66,6 +67,7 @@ public function testPdfDownloadAction(): void
->willReturn('some_file_name.pdf');

$ilUtilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$ilUtilHelper->method('deliverData')
Expand Down Expand Up @@ -104,6 +106,7 @@ public function testDownloadResultsInExceptionBecauseTheServerIsNotActive(): voi
->willReturn('some_file_name.pdf');

$ilUtilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$ilUtilHelper->method('deliverData')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function testDeleteTemplateAndUseOldThumbnail(): void
));

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper
Expand Down Expand Up @@ -100,6 +101,7 @@ public function testDeleteTemplateButNoThumbnailWillBeCopiedFromOldCertificate()
));

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,41 +44,23 @@ public function testExport(): void
));

$filesystem = $this->getMockBuilder(ILIAS\Filesystem\Filesystem::class)
->disableOriginalConstructor()
->getMock();

$filesystem
->expects($this->once())
->method('createDir');

$filesystem
->expects($this->once())
->method('put');

$filesystem
->expects($this->once())
->method('deleteDir');

$filesystem
->expects($this->once())
->method('put');

$objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
->getMock();

$objectHelper->method('lookupType')
->willReturn('crs');

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper
->expects($this->once())
->method('zipAndDeliver');

$utilHelper
->expects($this->once())
->method('deliverFile');

$action = new ilCertificateTemplateExportAction(
100,
'/some/where/background.jpg',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function testCertificateCanBeImportedWithBackgroundImage(): void
->willReturn('crs');

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper
Expand Down Expand Up @@ -128,6 +129,7 @@ public function testCertificateCanBeImportedWithoutBackgroundImage(): void
->willReturn('crs');

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper
Expand Down Expand Up @@ -197,6 +199,7 @@ public function testNoXmlFileInUplodadZipFolder(): void
->getMock();

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper
Expand Down Expand Up @@ -262,6 +265,7 @@ public function testZipfileCouldNoBeMoved(): void
->getMock();

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function testA(): void
->willReturn(100);

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper
Expand Down
2 changes: 2 additions & 0 deletions Services/Certificate/test/ilCoursePlaceholderValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function testGetPlaceholderValues(): void
->willReturn('2018-09-10');

$ilUtilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$ilUtilHelper->method('prepareFormOutput')
Expand Down Expand Up @@ -152,6 +153,7 @@ public function testGetPreviewPlaceholderValues(): void
->getMock();

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper->method('prepareFormOutput')
Expand Down
2 changes: 2 additions & 0 deletions Services/Certificate/test/ilDefaultPlaceholderValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public function testGetPlaceholderValues(): void
->willReturn('Something');

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper->method('prepareFormOutput')
Expand Down Expand Up @@ -206,6 +207,7 @@ public function testGetPlaceholderValuesForPreview(): void
->willReturn('Something');

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper->method('prepareFormOutput')
Expand Down
2 changes: 2 additions & 0 deletions Services/Certificate/test/ilExercisePlaceHolderValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function testGetPlaceholderValues(): void
->willReturn('aaa');

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper->expects($this->exactly(2))
Expand Down Expand Up @@ -147,6 +148,7 @@ public function testGetPlaceholderValuesForPreview(): void
->getMock();

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper->method('prepareFormOutput')
Expand Down
2 changes: 2 additions & 0 deletions Services/Certificate/test/ilScormPlaceholderValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function testGetPlaceholderValues(): void
->willReturn($objectMock);

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper->method('prepareFormOutput')
Expand Down Expand Up @@ -193,6 +194,7 @@ public function testGetPlaceholderValuesForPreview(): void
->willReturn($objectMock);

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper->method('prepareFormOutput')
Expand Down
2 changes: 2 additions & 0 deletions Services/Certificate/test/ilTestPlaceHolderValuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public function testA(): void
->willReturn('2018-01-12');

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper->method('prepareFormOutput')
Expand Down Expand Up @@ -187,6 +188,7 @@ public function testGetPlaceholderValuesForPreview(): void
->getMock();

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper->method('prepareFormOutput')
Expand Down
5 changes: 5 additions & 0 deletions Services/Certificate/test/ilXlsFoParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ private function verifyFoGeneratedFromXhtml(array $form_data, string $fo): void
$page_formats = new ilPageFormats($language);

$util_helper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$util_helper->method('stripSlashes')
Expand Down Expand Up @@ -114,6 +115,7 @@ public function testParseWithNonCustomPageFormatting(): void
$xmlChecker = new ilXMLChecker(new ILIAS\Data\Factory());

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper->method('stripSlashes')
Expand Down Expand Up @@ -208,6 +210,7 @@ public function testParseButXmlCheckerFindsAnError(): never
$xmlChecker = new ilXMLChecker(new ILIAS\Data\Factory());

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$xlstProcess = $this->getMockBuilder(ilCertificateXlstProcess::class)
Expand Down Expand Up @@ -279,6 +282,7 @@ public function testParseWithCustomPageFormatting(): void
$xmlChecker = new ilXMLChecker(new ILIAS\Data\Factory());

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper->method('stripSlashes')
Expand Down Expand Up @@ -373,6 +377,7 @@ public function testCommasWillBeConvertedToPointInDecimalSepartor(): void
$xmlChecker = new ilXMLChecker(new ILIAS\Data\Factory());

$utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
->disableOriginalConstructor()
->getMock();

$utilHelper->method('stripSlashes')
Expand Down

0 comments on commit 5227b05

Please sign in to comment.