@@ -136,7 +136,12 @@ public static function providerValidateToSignWithError(): array {
136136 }
137137
138138 #[DataProvider('providerValidateToSignWithCertificateData ' )]
139- public function testValidateToSignWithCertificateData (array $ certificateData , bool $ shouldThrow , string $ expectedMessage = '' ): void {
139+ public function testValidateToSignWithCertificateData (
140+ array $ certificateData ,
141+ bool $ shouldThrow ,
142+ string $ expectedMessage = '' ,
143+ ?int $ expectedCode = null ,
144+ ): void {
140145 $ this ->pkcs12Handler = $ this ->getPkcs12Instance (['getPfxOfCurrentSigner ' , 'setCertificate ' , 'setPassword ' , 'readCertificate ' ]);
141146 $ this ->pkcs12Handler ->method ('getPfxOfCurrentSigner ' )->willReturn ('mock-pfx ' );
142147 $ this ->pkcs12Handler ->method ('setCertificate ' )->willReturnSelf ();
@@ -153,6 +158,9 @@ public function testValidateToSignWithCertificateData(array $certificateData, bo
153158 if ($ expectedMessage ) {
154159 $ this ->expectExceptionMessage ($ expectedMessage );
155160 }
161+ if ($ expectedCode !== null ) {
162+ $ this ->expectExceptionCode ($ expectedCode );
163+ }
156164 }
157165
158166 $ password ->validateToSign ();
@@ -183,13 +191,15 @@ public static function providerValidateToSignWithCertificateData(): array {
183191 ],
184192 'shouldThrow ' => true ,
185193 'expectedMessage ' => 'Certificate has expired ' ,
194+ 'expectedCode ' => 422 ,
186195 ],
187196 'invalid certificate - validTo_time_t is string ' => [
188197 'certificateData ' => [
189198 'validTo_time_t ' => '1234567890 ' ,
190199 ],
191200 'shouldThrow ' => true ,
192201 'expectedMessage ' => 'Invalid certificate ' ,
202+ 'expectedCode ' => 422 ,
193203 ],
194204 'invalid certificate - validTo_time_t is null ' => [
195205 'certificateData ' => [
@@ -233,6 +243,7 @@ public static function providerValidateToSignWithCertificateData(): array {
233243 ],
234244 'shouldThrow ' => true ,
235245 'expectedMessage ' => 'Certificate has been revoked ' ,
246+ 'expectedCode ' => 422 ,
236247 ],
237248 'valid certificate with crl validation ' => [
238249 'certificateData ' => [
@@ -255,6 +266,7 @@ public static function providerValidateToSignWithCertificateData(): array {
255266 ],
256267 'shouldThrow ' => true ,
257268 'expectedMessage ' => 'Certificate revocation status could not be verified ' ,
269+ 'expectedCode ' => 422 ,
258270 ],
259271 'invalid certificate - crl validation empty string ' => [
260272 'certificateData ' => [
0 commit comments