Skip to content

Commit a603f09

Browse files
committed
test(handler): stub CrlRevocationChecker::validate() in AEngineHandlerTest
The mock returned null by default, causing AEngineHandler to access $crlDetails['status'] on a null value and trigger a PHP warning. Stubbing validate() to return ['status' => CrlValidationStatus::VALID] fulfils the contract and silences the warning. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 067832f commit a603f09

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

tests/php/Unit/Handler/CertificateEngine/AEngineHandlerTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
use OCA\Libresign\AppInfo\Application;
13+
use OCA\Libresign\Enum\CrlValidationStatus;
1314
use OCA\Libresign\Handler\CertificateEngine\OpenSslHandler;
1415
use OCA\Libresign\Service\CaIdentifierService;
1516
use OCA\Libresign\Service\CertificatePolicyService;
@@ -22,6 +23,7 @@
2223
use OCP\ITempManager;
2324
use OCP\IURLGenerator;
2425
use PHPUnit\Framework\Attributes\DataProvider;
26+
use PHPUnit\Framework\MockObject\MockObject;
2527
use Psr\Log\LoggerInterface;
2628

2729
final class AEngineHandlerTest extends \OCA\Libresign\Tests\Unit\TestCase {
@@ -35,7 +37,7 @@ final class AEngineHandlerTest extends \OCA\Libresign\Tests\Unit\TestCase {
3537
private CaIdentifierService $caIdentifierService;
3638
private LoggerInterface $logger;
3739
private SubjectAlternativeNameService $subjectAlternativeNameService;
38-
private CrlRevocationChecker $crlRevocationChecker;
40+
private CrlRevocationChecker&MockObject $crlRevocationChecker;
3941

4042
public function setUp(): void {
4143
$this->config = \OCP\Server::get(IConfig::class);
@@ -52,6 +54,7 @@ public function setUp(): void {
5254
$this->logger = \OCP\Server::get(LoggerInterface::class);
5355
$this->subjectAlternativeNameService = \OCP\Server::get(SubjectAlternativeNameService::class);
5456
$this->crlRevocationChecker = $this->createMock(CrlRevocationChecker::class);
57+
$this->crlRevocationChecker->method('validate')->willReturn(['status' => CrlValidationStatus::VALID]);
5558
}
5659

5760
private function getInstance(): OpenSslHandler {

0 commit comments

Comments
 (0)