@@ -466,6 +466,53 @@ public function testCheckEncoding()
466
466
$ this ->assertTrue (mb_check_encoding ("\xE9" , 'Windows-1252 ' ));
467
467
}
468
468
469
+ /**
470
+ * @covers \Symfony\Polyfill\Mbstring\Mbstring::mb_check_encoding
471
+ *
472
+ * @requires PHP 7.2
473
+ */
474
+ public function testCheckEncodingWithArrayValue ()
475
+ {
476
+ $ this ->assertTrue (mb_check_encoding (['aςσb ' ], 'UTF8 ' ));
477
+ $ this ->assertTrue (mb_check_encoding (['abc ' ], 'ASCII ' ));
478
+ $ this ->assertTrue (mb_check_encoding (["\xE9" ], 'Windows-1252 ' ));
479
+
480
+ $ this ->assertTrue (mb_check_encoding (['aςσb ' , 'abc ' ], 'UTF8 ' ));
481
+ $ this ->assertTrue (mb_check_encoding (["\xE9" , 'abc ' ], 'Windows-1252 ' ));
482
+
483
+ $ this ->assertFalse (mb_check_encoding (['aςσb ' , "\xE9" ], 'UTF8 ' ));
484
+ $ this ->assertFalse (mb_check_encoding (['abc ' , "\xE9" ], 'ASCII ' ));
485
+ $ this ->assertFalse (mb_check_encoding (['abc ' , 'aςσb ' ], 'ASCII ' ));
486
+
487
+ $ this ->assertTrue (mb_check_encoding (["\xE9" => "\xE9" , 'abc ' => 'abc ' ], 'Windows-1252 ' ));
488
+ $ this ->assertTrue (mb_check_encoding (['aςσb ' => 'aςσb ' , 'abc ' => 'abc ' ], 'UTF8 ' ));
489
+
490
+ $ this ->assertFalse (mb_check_encoding (['aςσb ' => 'aςσb ' , "\xE9" => 'abc ' ], 'UTF8 ' ));
491
+
492
+
493
+ $ this ->assertTrue (mb_check_encoding (['aςσb ' => 'aςσb ' , 'abc ' => ['abc ' , 'aςσb ' ]], 'UTF8 ' ));
494
+ $ this ->assertTrue (mb_check_encoding (['aςσb ' => 'aςσb ' , 'abc ' => ['abc ' => 'abc ' , 'aςσb ' => 'aςσb ' ]], 'UTF8 ' ));
495
+
496
+
497
+ $ this ->assertFalse (mb_check_encoding (['aςσb ' => 'aςσb ' , 'abc ' => ['abc ' => 'abc ' , 'aςσb ' => "\xE9" ]], 'UTF8 ' ));
498
+ $ this ->assertFalse (mb_check_encoding (['aςσb ' => 'aςσb ' , 'abc ' => ['abc ' => 'abc ' , "\xE9" => 'aςσb ' ]], 'UTF8 ' ));
499
+ }
500
+
501
+ /**
502
+ * @covers \Symfony\Polyfill\Mbstring\Mbstring::mb_check_encoding
503
+ *
504
+ * @requires PHP < 7.2
505
+ */
506
+ public function testCheckEncodingWithArrayValueForPhpLessThan72 ()
507
+ {
508
+ $ errorMessage = null ;
509
+ set_error_handler (function ($ type , $ msg , $ file , $ line ) use (&$ errorMessage ) { $ errorMessage = \E_USER_WARNING === $ type || \E_WARNING === $ type ? $ msg : null ; });
510
+ $ this ->assertNull (mb_check_encoding (['aςσb ' ], 'UTF8 ' ));
511
+ restore_error_handler ();
512
+ $ this ->assertSame ('mb_check_encoding() expects parameter 1 to be string, array given ' , $ errorMessage );
513
+ }
514
+
515
+
469
516
/**
470
517
* @covers \Symfony\Polyfill\Mbstring\Mbstring::mb_detect_encoding
471
518
*/
0 commit comments