From ea89b1c9427f440ab94700e5e6e9a67059898ebd Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Sun, 30 Nov 2014 05:35:00 +0000 Subject: [PATCH] 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 --- tests/phpunit/tests/db/charset.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/phpunit/tests/db/charset.php b/tests/phpunit/tests/db/charset.php index 00f6e0b963..809d43e05d 100755 --- a/tests/phpunit/tests/db/charset.php +++ b/tests/phpunit/tests/db/charset.php @@ -76,19 +76,21 @@ class Tests_DB_Charset extends WP_UnitTestCase { ), ); - // big5 is a non-Unicode multibyte charset - $utf8 = "a\xe5\x85\xb1b"; // UTF-8 Character 20849 - $big5 = mb_convert_encoding( $utf8, 'BIG-5', 'UTF-8' ); - $conv_utf8 = mb_convert_encoding( $big5, 'UTF-8', 'BIG-5' ); - // Make sure PHP's multibyte conversions are working correctly - $this->assertNotEquals( $utf8, $big5 ); - $this->assertEquals( $utf8, $conv_utf8 ); + if ( function_exists( 'mb_convert_encoding' ) ) { + // big5 is a non-Unicode multibyte charset + $utf8 = "a\xe5\x85\xb1b"; // UTF-8 Character 20849 + $big5 = mb_convert_encoding( $utf8, 'BIG-5', 'UTF-8' ); + $conv_utf8 = mb_convert_encoding( $big5, 'UTF-8', 'BIG-5' ); + // Make sure PHP's multibyte conversions are working correctly + $this->assertNotEquals( $utf8, $big5 ); + $this->assertEquals( $utf8, $conv_utf8 ); - $fields['big5'] = array( - 'charset' => 'big5', - 'value' => $big5, - 'expected' => $big5 - ); + $fields['big5'] = array( + 'charset' => 'big5', + 'value' => $big5, + 'expected' => $big5 + ); + } // The data above is easy to edit. Now, prepare it for the data provider. $data_provider = $multiple = $multiple_expected = array();