Changeset 31372 for trunk/tests/phpunit/tests/db/charset.php
- Timestamp:
- 02/09/2015 12:38:11 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/db/charset.php
r31349 r31372 123 123 */ 124 124 function test_strip_invalid_text( $data, $expected, $message ) { 125 if ( $data[0]['charset'] === 'koi8r' ) {126 self::$_wpdb->query( 'SET NAMES koi8r' );127 }128 125 $actual = self::$_wpdb->strip_invalid_text( $data ); 129 126 $this->assertSame( $expected, $actual, $message ); … … 135 132 function test_process_fields_failure() { 136 133 global $wpdb; 134 135 $charset = $wpdb->get_col_charset( $wpdb->posts, 'post_content' ); 136 if ( 'utf8' !== $charset && 'utf8mb4' !== $charset ) { 137 $this->markTestSkipped( 'This test requires a utf8 character set' ); 138 } 139 137 140 // \xf0\xff\xff\xff is invalid in utf8 and utf8mb4. 138 141 $data = array( 'post_content' => "H€llo\xf0\xff\xff\xffWorld¢" ); … … 144 147 */ 145 148 function data_process_field_charsets() { 146 $charset = $GLOBALS['wpdb']->charset; // This is how all tables were installed 149 if ( $GLOBALS['wpdb']->charset ) { 150 $charset = $GLOBALS['wpdb']->charset; 151 } else { 152 $charset = $GLOBALS['wpdb']->get_col_charset( $GLOBALS['wpdb']->posts, 'post_content' ); 153 } 154 147 155 // 'value' and 'format' are $data, 'charset' ends up as part of $expected 148 156 … … 221 229 function test_strip_invalid_text_for_column() { 222 230 global $wpdb; 231 232 $charset = $wpdb->get_col_charset( $wpdb->posts, 'post_content' ); 233 if ( 'utf8' !== $charset && 'utf8mb4' !== $charset ) { 234 $this->markTestSkipped( 'This test requires a utf8 character set' ); 235 } 236 223 237 // Invalid 3-byte and 4-byte sequences 224 238 $value = "H€llo\xe0\x80\x80World\xf0\xff\xff\xff¢"; … … 438 452 function test_invalid_characters_in_query() { 439 453 global $wpdb; 454 455 $charset = $wpdb->get_col_charset( $wpdb->posts, 'post_content' ); 456 if ( 'utf8' !== $charset && 'utf8mb4' !== $charset ) { 457 $this->markTestSkipped( 'This test requires a utf8 character set' ); 458 } 459 440 460 $this->assertFalse( $wpdb->query( "INSERT INTO {$wpdb->posts} (post_content) VALUES ('foo\xf0\xff\xff\xffbar')" ) ); 441 461 }
Note: See TracChangeset
for help on using the changeset viewer.