File tree Expand file tree Collapse file tree 3 files changed +25
-1
lines changed
tests/ApbctWP/ContactsEncoder Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -327,7 +327,7 @@ public static function getPhonesEncodingLongDescription()
327327 <p>%s</p>
328328 ' ;
329329 $ tmp = sprintf (
330- $ tmp ,
330+ trim ( $ tmp) ,
331331 __ ('Enable this option to encode contact phone numbers ' , 'cleantalk-spam-protect ' ),
332332 __ ('There are a few requirements to the number format: ' , 'cleantalk-spam-protect ' ),
333333 __ ('Should starting with "+" symbol or opening brace ' , 'cleantalk-spam-protect ' ),
Original file line number Diff line number Diff line change @@ -166,6 +166,7 @@ public function runEncoding($content = '')
166166 *
167167 * @return string JSON like {success: bool, data: [compiled response data]}
168168 * @psalm-suppress PossiblyUnusedMethod
169+ * @codeCoverageIgnore
169170 */
170171 public function runDecoding ($ encoded_contacts_data )
171172 {
Original file line number Diff line number Diff line change @@ -37,6 +37,21 @@ public function testPlainTextEncodeDecodeSSL()
3737 $ this ->assertEquals ($ decoded_entity , $ this ->plain_text );
3838 }
3939
40+ public function testPlainTextDecodeError ()
41+ {
42+ $ decoded_entity = $ this ->contacts_encoder ->encoder ->decodeString ('asdas121312 ' );
43+ $ this ->assertEmpty ($ decoded_entity );
44+ $ this ->assertIsString ($ decoded_entity );
45+ /**
46+ * @var State $apbct
47+ */
48+ global $ apbct ;
49+ $ this ->assertTrue ($ apbct ->isHaveErrors ());
50+ $ this ->assertTrue ($ apbct ->errorExists ('email_encoder ' ), $ this ->plain_text );
51+ $ this ->assertStringContainsString ( 'decrypt attempts failed ' , $ apbct ->errors ['email_encoder ' ][0 ]['error ' ]);
52+ $ apbct ->errorDeleteAll ();
53+ }
54+
4055 public function testEncodeErrors ()
4156 {
4257 /**
@@ -228,4 +243,12 @@ public function testPhoneEncodingSetting()
228243 $ this ->assertEquals ($ test_tel_origin , $ result );
229244 }
230245
246+ public function testGetPhonesEncodingLongDescription ()
247+ {
248+ $ description = ContactsEncoder::getPhonesEncodingLongDescription ();
249+ $ this ->assertIsString ($ description );
250+ $ this ->assertStringStartsWith ('< ' , $ description );
251+ $ this ->assertStringEndsWith ('> ' , $ description );
252+ }
253+
231254}
You can’t perform that action at this time.
0 commit comments