WPDB Unit Tests: Fix a fatal error that occurs in the `test_strip_invalid_text()` test if the `mbstring` extension isn't activated in PHP.

git-svn-id: https://develop.svn.wordpress.org/trunk@30631 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2014-11-30 05:35:00 +00:00
parent 9d74e43a4b
commit ea89b1c942
1 changed files with 14 additions and 12 deletions

View File

@ -76,19 +76,21 @@ class Tests_DB_Charset extends WP_UnitTestCase {
), ),
); );
// big5 is a non-Unicode multibyte charset if ( function_exists( 'mb_convert_encoding' ) ) {
$utf8 = "a\xe5\x85\xb1b"; // UTF-8 Character 20849 // big5 is a non-Unicode multibyte charset
$big5 = mb_convert_encoding( $utf8, 'BIG-5', 'UTF-8' ); $utf8 = "a\xe5\x85\xb1b"; // UTF-8 Character 20849
$conv_utf8 = mb_convert_encoding( $big5, 'UTF-8', 'BIG-5' ); $big5 = mb_convert_encoding( $utf8, 'BIG-5', 'UTF-8' );
// Make sure PHP's multibyte conversions are working correctly $conv_utf8 = mb_convert_encoding( $big5, 'UTF-8', 'BIG-5' );
$this->assertNotEquals( $utf8, $big5 ); // Make sure PHP's multibyte conversions are working correctly
$this->assertEquals( $utf8, $conv_utf8 ); $this->assertNotEquals( $utf8, $big5 );
$this->assertEquals( $utf8, $conv_utf8 );
$fields['big5'] = array( $fields['big5'] = array(
'charset' => 'big5', 'charset' => 'big5',
'value' => $big5, 'value' => $big5,
'expected' => $big5 'expected' => $big5
); );
}
// The data above is easy to edit. Now, prepare it for the data provider. // The data above is easy to edit. Now, prepare it for the data provider.
$data_provider = $multiple = $multiple_expected = array(); $data_provider = $multiple = $multiple_expected = array();