@@ -32,7 +32,8 @@ function is_uploaded_file($filename) {
3232use OCA \Libresign \Helper \ValidateHelper ;
3333use OCA \Libresign \Service \AccountService ;
3434use OCA \Libresign \Service \EnvelopeService ;
35- use OCA \Libresign \Service \File \FileResponseFormatter ;
35+ use OCA \Libresign \Service \File \FileListService ;
36+ use OCA \Libresign \Service \File \SignersLoader ;
3637use OCA \Libresign \Service \FileElementService ;
3738use OCA \Libresign \Service \FileService ;
3839use OCA \Libresign \Service \FolderService ;
@@ -83,7 +84,8 @@ final class FileServiceTest extends \OCA\Libresign\Tests\Unit\TestCase {
8384 protected IL10N $ l10n ;
8485 protected EnvelopeService $ envelopeService ;
8586 protected vfsDirectory $ tempFolder ;
86- protected FileResponseFormatter $ fileResponseFormatter ;
87+ protected SignersLoader $ signersLoader ;
88+ protected fileListService $ fileListService ;
8789 protected FileUploadHelper $ uploadHelper ;
8890
8991 public function setUp (): void {
@@ -121,8 +123,10 @@ private function getService(): FileService {
121123 $ this ->logger = \OCP \Server::get (LoggerInterface::class);
122124 $ this ->l10n = \OCP \Server::get (IL10NFactory::class)->get (Application::APP_ID );
123125 $ this ->envelopeService = \OCP \Server::get (EnvelopeService::class);
124- $ this ->fileResponseFormatter = \OCP \Server::get (FileResponseFormatter::class);
126+ $ this ->signersLoader = \OCP \Server::get (SignersLoader::class);
127+ $ this ->fileListService = \OCP \Server::get (FileListService::class);
125128 $ this ->uploadHelper = \OCP \Server::get (FileUploadHelper::class);
129+
126130 return new FileService (
127131 $ this ->fileMapper ,
128132 $ this ->signRequestMapper ,
@@ -148,7 +152,8 @@ private function getService(): FileService {
148152 $ this ->logger ,
149153 $ this ->l10n ,
150154 $ this ->envelopeService ,
151- $ this ->fileResponseFormatter ,
155+ $ this ->signersLoader ,
156+ $ this ->fileListService ,
152157 $ this ->uploadHelper ,
153158 );
154159 }
@@ -163,19 +168,33 @@ public function testToArray(callable $arguments, array $expected): void {
163168 if (is_callable ($ arguments )) {
164169 $ arguments = $ arguments ($ this , $ service );
165170 }
166- $ actual = $ service
167- ->toArray ();
171+ $ actual = $ service ->toArray ();
168172
169173 // Remove 'purposes' field from comparison as it varies between OpenSSL versions
170174 $ this ->removePurposesField ($ expected );
171175 $ this ->removePurposesField ($ actual );
172176
173177 $ this ->removeDocMdpFields ($ expected );
174178 $ this ->removeDocMdpFields ($ actual );
179+ $ this ->mockUuid ($ expected , $ actual );
175180
176181 $ this ->assertEquals ($ expected , $ actual );
177182 }
178183
184+ /**
185+ * Was necessary to create this because the method that handle the uuid
186+ * is very internal of subclasses and wasn't easy to mock this.
187+ */
188+ private function mockUuid (array $ expected , array &$ actual ): void {
189+ if (isset ($ actual ['signers ' ])) {
190+ foreach ($ actual ['signers ' ] as $ key => &$ signer ) {
191+ if (isset ($ signer ['uid ' ]) && isset ($ expected ['signers ' ][$ key ])) {
192+ $ signer ['uid ' ] = $ expected ['signers ' ][$ key ]['uid ' ];
193+ }
194+ }
195+ }
196+ }
197+
179198 private function removePurposesField (array &$ data ): void {
180199 if (isset ($ data ['signers ' ])) {
181200 foreach ($ data ['signers ' ] as &$ signer ) {
0 commit comments