Skip to content

Commit 9088d4f

Browse files
committed
test: refactor DocMDP level 1 exception test to use getService helper
Simplifies test setup and improves maintainability. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 0668e31 commit 9088d4f

1 file changed

Lines changed: 1 addition & 39 deletions

File tree

tests/php/Unit/Service/SignFileServiceTest.php

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,50 +1176,12 @@ public static function providerGetNodeByIdUsingUid(): array {
11761176

11771177
public function testSignThrowsExceptionWhenDocMdpLevel1Detected(): void {
11781178
$this->expectException(LibresignException::class);
1179-
1180-
// Create a real DocMdpHandler for this test
1181-
$realDocMdpHandler = new DocMdpHandler($this->l10n);
1182-
1183-
// Create service with custom methods mocked and real DocMdpHandler
1184-
$service = $this->getMockBuilder(SignFileService::class)
1185-
->setConstructorArgs([
1186-
$this->l10n,
1187-
$this->fileMapper,
1188-
$this->signRequestMapper,
1189-
$this->idDocsMapper,
1190-
$this->footerHandler,
1191-
$this->folderService,
1192-
$this->clientService,
1193-
$this->userManager,
1194-
$this->logger,
1195-
$this->appConfig,
1196-
$this->validateHelper,
1197-
$this->signerElementsService,
1198-
$this->root,
1199-
$this->userSession,
1200-
$this->dateTimeZone,
1201-
$this->fileElementMapper,
1202-
$this->userElementMapper,
1203-
$this->eventDispatcher,
1204-
$this->secureRandom,
1205-
$this->urlGenerator,
1206-
$this->identifyMethodMapper,
1207-
$this->tempManager,
1208-
$this->identifyMethodService,
1209-
$this->timeFactory,
1210-
$this->signEngineFactory,
1211-
$this->signedEventFactory,
1212-
$this->pdf,
1213-
$realDocMdpHandler,
1214-
])
1215-
->onlyMethods(['getNextcloudFile', 'getEngine'])
1216-
->getMock();
1179+
$service = $this->getService(['getNextcloudFile', 'getEngine']);
12171180

12181181
$nextcloudFile = $this->createMock(\OCP\Files\File::class);
12191182
$nextcloudFile->method('getContent')->willReturn(file_get_contents(__DIR__ . '/../../fixtures/real_jsignpdf_level1.pdf'));
12201183
$service->method('getNextcloudFile')->willReturn($nextcloudFile);
12211184

1222-
// Mock getEngine to prevent actual signing (should not be called)
12231185
$engineMock = $this->createMock(Pkcs12Handler::class);
12241186
$service->method('getEngine')->willReturn($engineMock);
12251187

0 commit comments

Comments
 (0)