File tree Expand file tree Collapse file tree
lib/Service/IdentifyMethod/SignatureMethod
tests/php/Unit/Service/IdentifyMethod/SignatureMethod Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99namespace OCA \Libresign \Service \IdentifyMethod \SignatureMethod ;
1010
1111use OCA \Libresign \Exception \LibresignException ;
12- use OCA \Libresign \Helper \JSActions ;
1312use OCA \Libresign \Service \IdentifyMethod \IdentifyService ;
1413use OCA \Libresign \Vendor \Wobeto \EmailBlur \Blur ;
1514
@@ -42,10 +41,15 @@ public function toArray(): array {
4241 };
4342
4443 if (!filter_var ($ email , FILTER_VALIDATE_EMAIL )) {
45- throw new LibresignException (json_encode ([
46- 'action ' => JSActions::ACTION_DO_NOTHING ,
47- 'errors ' => [['message ' => $ this ->identifyService ->getL10n ()->t ('Invalid email ' )]],
48- ]));
44+ $ message = match ($ entity ->getIdentifierKey ()) {
45+ // TRANSLATORS Error message shown when the email provided is not valid
46+ 'email ' => $ this ->identifyService ->getL10n ()->t ('Invalid email ' ),
47+ // TRANSLATORS Error message shown when the signer has no valid email address in his profile, so he cannot be identified by email token
48+ 'account ' => $ this ->identifyService ->getL10n ()->t ('Signer without valid email address to be identified by email token. ' ),
49+ // TRANSLATORS Error message shown when the email provided is not valid
50+ default => $ this ->identifyService ->getL10n ()->t ('Invalid email ' ),
51+ };
52+ throw new LibresignException ($ message );
4953 }
5054
5155 $ emailLowercase = strtolower ($ email );
Original file line number Diff line number Diff line change @@ -42,18 +42,14 @@ private function getClass(): EmailToken {
4242 }
4343
4444 #[DataProvider('providerToArrayWithInvalidEmail ' )]
45- public function testToArrayWithInvalidEmail (mixed $ email ): void {
45+ public function testToArrayWithInvalidEmail (string $ email ): void {
4646 $ instance = $ this ->getClass ();
4747 $ identifyMethod = new IdentifyMethod ();
4848 $ identifyMethod ->fromRow ([
4949 'identifierValue ' => $ email
5050 ]);
5151 $ instance ->setEntity ($ identifyMethod );
5252 $ this ->expectException (LibresignException::class);
53- $ this ->expectExceptionMessage (json_encode ([
54- 'action ' => 2000 ,
55- 'errors ' => [['message ' => 'Invalid email ' ]],
56- ]));
5753 $ instance ->toArray ();
5854 }
5955
You can’t perform that action at this time.
0 commit comments