WordPress.org

Make WordPress Core

Changeset 30631


Ignore:
Timestamp:
11/30/14 05:35:00 (3 years ago)
Author:
pento
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/db/charset.php

    r30375 r30631  
    7777        ); 
    7878 
    79         // big5 is a non-Unicode multibyte charset 
    80         $utf8 = "a\xe5\x85\xb1b"; // UTF-8 Character 20849 
    81         $big5 = mb_convert_encoding( $utf8, 'BIG-5', 'UTF-8' ); 
    82         $conv_utf8 = mb_convert_encoding( $big5, 'UTF-8', 'BIG-5' ); 
    83         // Make sure PHP's multibyte conversions are working correctly 
    84         $this->assertNotEquals( $utf8, $big5 ); 
    85         $this->assertEquals( $utf8, $conv_utf8 ); 
    86  
    87         $fields['big5'] = array( 
    88             'charset'  => 'big5', 
    89             'value'    => $big5, 
    90             'expected' => $big5 
    91         ); 
     79        if ( function_exists( 'mb_convert_encoding' ) ) { 
     80            // big5 is a non-Unicode multibyte charset 
     81            $utf8 = "a\xe5\x85\xb1b"; // UTF-8 Character 20849 
     82            $big5 = mb_convert_encoding( $utf8, 'BIG-5', 'UTF-8' ); 
     83            $conv_utf8 = mb_convert_encoding( $big5, 'UTF-8', 'BIG-5' ); 
     84            // Make sure PHP's multibyte conversions are working correctly 
     85            $this->assertNotEquals( $utf8, $big5 ); 
     86            $this->assertEquals( $utf8, $conv_utf8 ); 
     87 
     88            $fields['big5'] = array( 
     89                'charset'  => 'big5', 
     90                'value'    => $big5, 
     91                'expected' => $big5 
     92            ); 
     93        } 
    9294 
    9395        // The data above is easy to edit. Now, prepare it for the data provider. 
Note: See TracChangeset for help on using the changeset viewer.