Skip to content

Commit 6d91725

Browse files
committed
test: fix unit tests after FileUploadHelper injection
- Add FileUploadHelper mock to AccountServiceTest - Add FileUploadHelper instance to FileServiceTest - Add FileUploadHelper mock to IdDocsServiceTest - Replace FileService with FileUploadHelper in RequestSignatureServiceTest - All services now correctly inject FileUploadHelper dependency Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent c9cd6ad commit 6d91725

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

tests/php/Unit/Service/AccountServiceTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use OCA\Libresign\Db\UserElementMapper;
1919
use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory;
2020
use OCA\Libresign\Handler\SignEngine\Pkcs12Handler;
21+
use OCA\Libresign\Helper\FileUploadHelper;
2122
use OCA\Libresign\Helper\ValidateHelper;
2223
use OCA\Libresign\Service\AccountService;
2324
use OCA\Libresign\Service\FolderService;
@@ -71,6 +72,7 @@ final class AccountServiceTest extends \OCA\Libresign\Tests\Unit\TestCase {
7172
private TimeFactory&MockObject $timeFactory;
7273
private RequestSignatureService&MockObject $requestSignatureService;
7374
private Pkcs12Handler&MockObject $pkcs12Handler;
75+
private FileUploadHelper&MockObject $uploadHelper;
7476

7577
public function setUp(): void {
7678
parent::setUp();
@@ -104,6 +106,7 @@ public function setUp(): void {
104106
$this->folderService = $this->createMock(FolderService::class);
105107
$this->clientService = $this->createMock(ClientService::class);
106108
$this->timeFactory = $this->createMock(TimeFactory::class);
109+
$this->uploadHelper = $this->createMock(FileUploadHelper::class);
107110
}
108111

109112
private function getService(): AccountService {
@@ -134,7 +137,8 @@ private function getService(): AccountService {
134137
$this->userElementMapper,
135138
$this->folderService,
136139
$this->clientService,
137-
$this->timeFactory
140+
$this->timeFactory,
141+
$this->uploadHelper
138142
);
139143
}
140144

tests/php/Unit/Service/FileServiceTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ private function getService(): FileService {
117117
$this->logger = \OCP\Server::get(LoggerInterface::class);
118118
$this->l10n = \OCP\Server::get(IL10NFactory::class)->get(Application::APP_ID);
119119
$this->envelopeService = \OCP\Server::get(EnvelopeService::class);
120+
$uploadHelper = \OCP\Server::get(FileUploadHelper::class);
120121
return new FileService(
121122
$this->fileMapper,
122123
$this->signRequestMapper,
@@ -142,6 +143,7 @@ private function getService(): FileService {
142143
$this->logger,
143144
$this->l10n,
144145
$this->envelopeService,
146+
$uploadHelper,
145147
);
146148
}
147149

tests/php/Unit/Service/IdDocsServiceTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ final class IdDocsServiceTest extends \OCA\Libresign\Tests\Unit\TestCase {
7373
private TimeFactory&MockObject $timeFactory;
7474
private RequestSignatureService&MockObject $requestSignatureService;
7575
private Pkcs12Handler&MockObject $pkcs12Handler;
76+
private FileUploadHelper&MockObject $uploadHelper;
7677

7778
public function setUp(): void {
7879
parent::setUp();
@@ -107,6 +108,7 @@ public function setUp(): void {
107108
$this->folderService = $this->createMock(FolderService::class);
108109
$this->clientService = $this->createMock(ClientService::class);
109110
$this->timeFactory = $this->createMock(TimeFactory::class);
111+
$this->uploadHelper = $this->createMock(FileUploadHelper::class);
110112
}
111113

112114
private function getService(): AccountService {
@@ -137,7 +139,8 @@ private function getService(): AccountService {
137139
$this->userElementMapper,
138140
$this->folderService,
139141
$this->clientService,
140-
$this->timeFactory
142+
$this->timeFactory,
143+
$this->uploadHelper
141144
);
142145
}
143146

tests/php/Unit/Service/RequestSignatureServiceTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use OCA\Libresign\Service\DocMdpConfigService;
1717
use OCA\Libresign\Service\EnvelopeService;
1818
use OCA\Libresign\Service\FileElementService;
19-
use OCA\Libresign\Service\FileService;
2019
use OCA\Libresign\Service\FileStatusService;
2120
use OCA\Libresign\Service\FolderService;
2221
use OCA\Libresign\Service\IdentifyMethodService;
@@ -61,7 +60,7 @@ final class RequestSignatureServiceTest extends \OCA\Libresign\Tests\Unit\TestCa
6160
private SignRequestStatusService&MockObject $signRequestStatusService;
6261
private DocMdpConfigService&MockObject $docMdpConfigService;
6362
private EnvelopeService&MockObject $envelopeService;
64-
private FileService&MockObject $fileService;
63+
private FileUploadHelper&MockObject $uploadHelper;
6564

6665
public function setUp(): void {
6766
parent::setUp();
@@ -93,7 +92,7 @@ public function setUp(): void {
9392
$this->signRequestStatusService = $this->createMock(SignRequestStatusService::class);
9493
$this->docMdpConfigService = $this->createMock(DocMdpConfigService::class);
9594
$this->envelopeService = $this->createMock(EnvelopeService::class);
96-
$this->fileService = $this->createMock(FileService::class);
95+
$this->uploadHelper = $this->createMock(FileUploadHelper::class);
9796
}
9897

9998
private function getService(): RequestSignatureService {
@@ -120,7 +119,7 @@ private function getService(): RequestSignatureService {
120119
$this->signRequestStatusService,
121120
$this->docMdpConfigService,
122121
$this->envelopeService,
123-
$this->fileService,
122+
$this->uploadHelper,
124123
);
125124
}
126125

0 commit comments

Comments
 (0)