Changeset 32162 for trunk/tests/phpunit/tests/db/charset.php
- Timestamp:
- 04/20/2015 04:45:12 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/db/charset.php
r31953 r32162 464 464 $this->assertFalse( $wpdb->query( "INSERT INTO {$wpdb->posts} (post_content) VALUES ('foo\xf0\xff\xff\xffbar')" ) ); 465 465 } 466 467 /** 468 * @ticket 21212 469 */ 470 function data_table_collation_check() { 471 $table_name = 'table_collation_check'; 472 $data = array( 473 array( 474 // utf8_bin tables don't need extra sanity checking. 475 "( a VARCHAR(50) COLLATE utf8_bin )", // create 476 true // expected result 477 ), 478 array( 479 // Neither do utf8_general_ci tables. 480 "( a VARCHAR(50) COLLATE utf8_general_ci )", 481 true 482 ), 483 array( 484 // utf8_unicode_ci tables do. 485 "( a VARCHAR(50) COLLATE utf8_unicode_ci )", 486 false 487 ), 488 array( 489 // utf8_bin tables don't need extra sanity checking, 490 // except for when they're not just utf8_bin. 491 "( a VARCHAR(50) COLLATE utf8_bin, b VARCHAR(50) COLLATE big5_chinese_ci )", 492 false 493 ), 494 array( 495 // utf8_bin tables don't need extra sanity checking 496 // when the other columns aren't strings. 497 "( a VARCHAR(50) COLLATE utf8_bin, b INT )", 498 true 499 ), 500 ); 501 502 foreach( $data as &$value ) { 503 $this_table_name = $table_name . '_' . rand_str( 5 ); 504 505 $value[0] = "CREATE TABLE $this_table_name {$value[0]}"; 506 $value[2] = "SELECT * FROM $this_table_name"; 507 $value[3] = "DROP TABLE IF EXISTS $this_table_name"; 508 } 509 unset( $value ); 510 511 return $data; 512 } 513 514 515 /** 516 * @dataProvider data_table_collation_check 517 * @ticket 21212 518 */ 519 function test_table_collation_check( $create, $expected, $query, $drop ) { 520 self::$_wpdb->query( $drop ); 521 522 self::$_wpdb->query( $create ); 523 524 $return = self::$_wpdb->check_safe_collation( $query ); 525 $this->assertEquals( $expected, $return ); 526 527 self::$_wpdb->query( $drop ); 528 } 466 529 }
Note: See TracChangeset
for help on using the changeset viewer.