From 385df631cdca77adece14d0c7e14bb50db124a46 Mon Sep 17 00:00:00 2001 From: Janos Pribelszki Date: Sun, 5 Nov 2023 10:50:14 +0100 Subject: [PATCH] feature: Added logging of zip export errors with tests. --- test/unit/model/ZipExporterTest.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/unit/model/ZipExporterTest.php b/test/unit/model/ZipExporterTest.php index 528906175..08fbaa95c 100644 --- a/test/unit/model/ZipExporterTest.php +++ b/test/unit/model/ZipExporterTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; use Psr\Http\Message\StreamInterface; +use Psr\Log\LoggerInterface; class ZipExporterTest extends TestCase { @@ -38,6 +39,8 @@ class ZipExporterTest extends TestCase private ServiceManager $serviceManagerMock; + private LoggerInterface $loggerMock; + private ZipExporter $sut; /** @@ -54,10 +57,11 @@ public function setUp(): void $this->fileManagementMock = $this->createMock(FileManagement::class); $this->mediaResourcePreparerMock = $this->createMock(MediaResourcePreparerInterface::class); $this->serviceManagerMock = $this->createMock(ServiceManager::class); + $this->loggerMock = $this->createMock(LoggerInterface::class); $this->sut = $this ->getMockBuilder(ZipExporterTester::class) - ->onlyMethods(['getServiceManager']) + ->onlyMethods(['getServiceManager', 'getLogger']) ->getMock(); } @@ -108,6 +112,12 @@ public function testCreateZipFileThrowsMediaReferencesNotFoundException(): void ->method('getServiceManager') ->willReturn($this->serviceManagerMock); + $this + ->sut + ->expects(self::once()) + ->method('getLogger') + ->willReturn($this->loggerMock); + $this ->fileManagementMock ->expects(self::once()) @@ -126,6 +136,11 @@ public function testCreateZipFileThrowsMediaReferencesNotFoundException(): void ->method('get') ->willReturnOnConsecutiveCalls($this->fileManagementMock, $this->mediaResourcePreparerMock); + $this + ->loggerMock + ->expects(self::once()) + ->method('error'); + $this->expectException(ZipExporterFileErrorList::class); $this->expectExceptionMessage( 'Errors in zip file:
' .