SeemsUtf8.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * @group formatting
  4. */
  5. class Tests_Formatting_SeemsUtf8 extends WP_UnitTestCase {
  6. /**
  7. * `seems_utf8` returns true for utf-8 strings, false otherwise.
  8. *
  9. * @dataProvider utf8_strings
  10. */
  11. function test_returns_true_for_utf8_strings( $utf8_string ) {
  12. // From http://www.i18nguy.com/unicode-example.html
  13. $this->assertTrue( seems_utf8( $utf8_string ) );
  14. }
  15. function utf8_strings() {
  16. $utf8_strings = file( DIR_TESTDATA . '/formatting/utf-8/utf-8.txt' );
  17. foreach ( $utf8_strings as &$string ) {
  18. $string = (array) trim( $string );
  19. }
  20. unset( $string );
  21. return $utf8_strings;
  22. }
  23. /**
  24. * @dataProvider big5_strings
  25. */
  26. function test_returns_false_for_non_utf8_strings( $big5_string ) {
  27. $this->assertFalse( seems_utf8( $big5_string ) );
  28. }
  29. function big5_strings() {
  30. // Get data from formatting/big5.txt.
  31. $big5_strings = file( DIR_TESTDATA . '/formatting/big5.txt' );
  32. foreach ( $big5_strings as &$string ) {
  33. $string = (array) trim( $string );
  34. }
  35. unset( $string );
  36. return $big5_strings;
  37. }
  38. }