Skip to content

Commit

Permalink
feature: Added logging of zip export errors with tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Janos Pribelszki committed Nov 5, 2023
1 parent 1781821 commit 385df63
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/unit/model/ZipExporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -38,6 +39,8 @@ class ZipExporterTest extends TestCase

private ServiceManager $serviceManagerMock;

private LoggerInterface $loggerMock;

private ZipExporter $sut;

/**
Expand All @@ -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();
}

Expand Down Expand Up @@ -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())
Expand All @@ -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: <br>' .
Expand Down

0 comments on commit 385df63

Please sign in to comment.