test: fix mock callbacks for testUpdateDatabaseWhenSign and testDispatchEventWhenSign

Add __call callbacks to SignRequest mocks in both tests to properly return
fileId and signingOrder values. Without these callbacks, the mocks were
returning null when these magic methods were called, causing
SequentialSigningService::releaseNextOrder() to fail with a TypeError.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
This commit is contained in:
Vitor Mattos 2025-12-09 21:22:33 -03:00
parent 6502530576
commit fae11f133c
No known key found for this signature in database
GPG key ID: 6FECE2AD4809003A

View file

@ -340,6 +340,15 @@ final class SignFileServiceTest extends \OCA\Libresign\Tests\Unit\TestCase {
$this->signRequestMapper->expects($this->once())->method('update');
$signRequest = $this->createMock(SignRequest::class);
$signRequest->method('__call')->willReturnCallback(function ($method, $args) {
switch ($method) {
case 'getFileId':
return 1;
case 'getSigningOrder':
return 1;
default: return null;
}
});
$libreSignFile = $this->createMock(\OCA\Libresign\Db\File::class);
$service
@ -366,6 +375,15 @@ final class SignFileServiceTest extends \OCA\Libresign\Tests\Unit\TestCase {
->with($this->isInstanceOf(SignedEvent::class));
$signRequest = $this->createMock(SignRequest::class);
$signRequest->method('__call')->willReturnCallback(function ($method, $args) {
switch ($method) {
case 'getFileId':
return 1;
case 'getSigningOrder':
return 1;
default: return null;
}
});
$libreSignFile = $this->createMock(\OCA\Libresign\Db\File::class);
$service