wordpress-develop/tests/phpunit/tests/formatting/SeemsUtf8.php
Boone Gorges ed426ef8ef Repair the seems_utf8() tests that use Big5 encoding.
* Provide sample data that is actually encoded in Big5.
* Do some actual assertions against that data.

Props akumria.
Fixes #30455.

git-svn-id: https://develop.svn.wordpress.org/trunk@30525 602fd350-edb4-49c9-b593-d223f7449a82
2014-11-22 20:56:23 +00:00

45 lines
1.0 KiB
PHP

<?php
/**
* @group formatting
*/
class Tests_Formatting_SeemsUtf8 extends WP_UnitTestCase {
/**
* `seems_utf8` returns true for utf-8 strings, false otherwise.
*
* @dataProvider utf8_strings
*/
function test_returns_true_for_utf8_strings( $utf8_string ) {
// from http://www.i18nguy.com/unicode-example.html
$this->assertTrue( seems_utf8( $utf8_string ) );
}
function utf8_strings() {
$utf8_strings = file( DIR_TESTDATA . '/formatting/utf-8/utf-8.txt' );
foreach ( $utf8_strings as &$string ) {
$string = (array) trim( $string );
}
unset( $string );
return $utf8_strings;
}
/**
* @dataProvider big5_strings
*/
function test_returns_false_for_non_utf8_strings( $big5_string ) {
$this->assertFalse( seems_utf8( $big5_string ) );
}
function big5_strings() {
// Get data from formatting/big5.txt
$big5_strings = file( DIR_TESTDATA . '/formatting/big5.txt' );
foreach ( $big5_strings as &$string ) {
$string = (array) trim( $string );
}
unset( $string );
return $big5_strings;
}
}