Changeset 47122 for trunk/tests/phpunit/tests/db/charset.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/db/charset.php
r46586 r47122 73 73 ), 74 74 'ascii' => array( 75 // ascii gets special treatment, make sure it's covered 75 // ascii gets special treatment, make sure it's covered. 76 76 'charset' => 'ascii', 77 77 'value' => 'Hello World', … … 83 83 ), 84 84 'ascii_char_length' => array( 85 // ascii gets special treatment, make sure it's covered 85 // ascii gets special treatment, make sure it's covered. 86 86 'charset' => 'ascii', 87 87 'value' => str_repeat( 'A', 11 ), … … 93 93 ), 94 94 'ascii_byte_length' => array( 95 // ascii gets special treatment, make sure it's covered 95 // ascii gets special treatment, make sure it's covered. 96 96 'charset' => 'ascii', 97 97 'value' => str_repeat( 'A', 11 ), … … 103 103 ), 104 104 'utf8' => array( 105 // utf8 only allows <= 3-byte chars 105 // utf8 only allows <= 3-byte chars. 106 106 'charset' => 'utf8', 107 107 'value' => "H€llo\xf0\x9f\x98\x88World¢", … … 113 113 ), 114 114 'utf8_23char_length' => array( 115 // utf8 only allows <= 3-byte chars 115 // utf8 only allows <= 3-byte chars. 116 116 'charset' => 'utf8', 117 117 'value' => str_repeat( '²3', 10 ), … … 123 123 ), 124 124 'utf8_23byte_length' => array( 125 // utf8 only allows <= 3-byte chars 125 // utf8 only allows <= 3-byte chars. 126 126 'charset' => 'utf8', 127 127 'value' => str_repeat( '²3', 10 ), … … 133 133 ), 134 134 'utf8_3char_length' => array( 135 // utf8 only allows <= 3-byte chars 135 // utf8 only allows <= 3-byte chars. 136 136 'charset' => 'utf8', 137 137 'value' => str_repeat( '3', 11 ), … … 143 143 ), 144 144 'utf8_3byte_length' => array( 145 // utf8 only allows <= 3-byte chars 145 // utf8 only allows <= 3-byte chars. 146 146 'charset' => 'utf8', 147 147 'value' => str_repeat( '3', 11 ), … … 153 153 ), 154 154 'utf8mb3' => array( 155 // utf8mb3 should behave the same an utf8 155 // utf8mb3 should behave the same an utf8. 156 156 'charset' => 'utf8mb3', 157 157 'value' => "H€llo\xf0\x9f\x98\x88World¢", … … 163 163 ), 164 164 'utf8mb3_23char_length' => array( 165 // utf8mb3 should behave the same an utf8 165 // utf8mb3 should behave the same an utf8. 166 166 'charset' => 'utf8mb3', 167 167 'value' => str_repeat( '²3', 10 ), … … 173 173 ), 174 174 'utf8mb3_23byte_length' => array( 175 // utf8mb3 should behave the same an utf8 175 // utf8mb3 should behave the same an utf8. 176 176 'charset' => 'utf8mb3', 177 177 'value' => str_repeat( '²3', 10 ), … … 183 183 ), 184 184 'utf8mb3_3char_length' => array( 185 // utf8mb3 should behave the same an utf8 185 // utf8mb3 should behave the same an utf8. 186 186 'charset' => 'utf8mb3', 187 187 'value' => str_repeat( '3', 11 ), … … 193 193 ), 194 194 'utf8mb3_3byte_length' => array( 195 // utf8mb3 should behave the same an utf8 195 // utf8mb3 should behave the same an utf8. 196 196 'charset' => 'utf8mb3', 197 197 'value' => str_repeat( '3', 10 ), … … 203 203 ), 204 204 'utf8mb4' => array( 205 // utf8mb4 allows 4-byte characters, too 205 // utf8mb4 allows 4-byte characters, too. 206 206 'charset' => 'utf8mb4', 207 207 'value' => "H€llo\xf0\x9f\x98\x88World¢", … … 213 213 ), 214 214 'utf8mb4_234char_length' => array( 215 // utf8mb4 allows 4-byte characters, too 215 // utf8mb4 allows 4-byte characters, too. 216 216 'charset' => 'utf8mb4', 217 217 'value' => str_repeat( '²3𝟜', 10 ), … … 223 223 ), 224 224 'utf8mb4_234byte_length' => array( 225 // utf8mb4 allows 4-byte characters, too 225 // utf8mb4 allows 4-byte characters, too. 226 226 'charset' => 'utf8mb4', 227 227 'value' => str_repeat( '²3𝟜', 10 ), … … 233 233 ), 234 234 'utf8mb4_4char_length' => array( 235 // utf8mb4 allows 4-byte characters, too 235 // utf8mb4 allows 4-byte characters, too. 236 236 'charset' => 'utf8mb4', 237 237 'value' => str_repeat( '𝟜', 11 ), … … 243 243 ), 244 244 'utf8mb4_4byte_length' => array( 245 // utf8mb4 allows 4-byte characters, too 245 // utf8mb4 allows 4-byte characters, too. 246 246 'charset' => 'utf8mb4', 247 247 'value' => str_repeat( '𝟜', 10 ), … … 327 327 'length' => false, 328 328 // Don't set 'ascii' => true/false. 329 // That's a different codepath than it being unset even if330 // three's onlyonly ASCII in the value.329 // That's a different codepath than it being unset 330 // even if there's only ASCII in the value. 331 331 ), 332 332 'cp1251_char_length' => array( … … 406 406 ), 407 407 'false' => array( 408 // false is a column with no character set (ie, a number column)408 // False is a column with no character set (i.e. a number column). 409 409 'charset' => false, 410 410 'value' => 100, … … 415 415 416 416 if ( function_exists( 'mb_convert_encoding' ) ) { 417 // big5 is a non-Unicode multibyte charset 418 $utf8 = "a\xe5\x85\xb1b"; // UTF-8 Character 20849 417 // big5 is a non-Unicode multibyte charset. 418 $utf8 = "a\xe5\x85\xb1b"; // UTF-8 Character 20849. 419 419 $big5 = mb_convert_encoding( $utf8, 'BIG-5', 'UTF-8' ); 420 420 $conv_utf8 = mb_convert_encoding( $big5, 'UTF-8', 'BIG-5' ); 421 // Make sure PHP's multibyte conversions are working correctly 421 // Make sure PHP's multibyte conversions are working correctly. 422 422 $this->assertNotEquals( $utf8, $big5 ); 423 423 $this->assertEquals( $utf8, $conv_utf8 ); … … 536 536 } 537 537 538 // 'value' and 'format' are $data, 'charset' ends up as part of $expected 538 // 'value' and 'format' are $data, 'charset' ends up as part of $expected. 539 539 540 540 $no_string_fields = array( … … 564 564 ); 565 565 566 // This is the same data used in process_field_charsets_for_nonexistent_table() 566 // This is the same data used in process_field_charsets_for_nonexistent_table(). 567 567 $non_ascii_string_fields = array( 568 568 'post_content' => array( … … 648 648 } 649 649 650 // Invalid 3-byte and 4-byte sequences 650 // Invalid 3-byte and 4-byte sequences. 651 651 $value = "H€llo\xe0\x80\x80World\xf0\xff\xff\xff¢"; 652 652 $expected = 'H€lloWorld¢'; … … 865 865 $data = array( 866 866 array( 867 // binary tables don't get stripped868 '( a VARCHAR(50) CHARACTER SET utf8, b BINARY )', // create869 "('foo\xf0\x9f\x98\x88bar', 'foo')", // query870 "('foo\xf0\x9f\x98\x88bar', 'foo')", // expected result867 // Binary tables don't get stripped. 868 '( a VARCHAR(50) CHARACTER SET utf8, b BINARY )', // Create. 869 "('foo\xf0\x9f\x98\x88bar', 'foo')", // Query. 870 "('foo\xf0\x9f\x98\x88bar', 'foo')", // Expected result. 871 871 ), 872 872 array( 873 // utf8/utf8mb4 tables default to utf8 873 // utf8/utf8mb4 tables default to utf8. 874 874 '( a VARCHAR(50) CHARACTER SET utf8, b VARCHAR(50) CHARACTER SET utf8mb4 )', 875 875 "('foo\xf0\x9f\x98\x88bar', 'foo')", … … 965 965 array( 966 966 // utf8_bin tables don't need extra sanity checking. 967 '( a VARCHAR(50) COLLATE utf8_bin )', // create968 true, // expected result967 '( a VARCHAR(50) COLLATE utf8_bin )', // Create. 968 true, // Expected result. 969 969 ), 970 970 array( … … 1035 1035 global $wpdb; 1036 1036 1037 // TEXT column 1037 // TEXT column. 1038 1038 $stripped = $wpdb->strip_invalid_text_for_column( $wpdb->comments, 'comment_content', str_repeat( 'A', 65536 ) ); 1039 1039 $this->assertEquals( 65535, strlen( $stripped ) ); 1040 1040 1041 // VARCHAR column 1041 // VARCHAR column. 1042 1042 $stripped = $wpdb->strip_invalid_text_for_column( $wpdb->comments, 'comment_agent', str_repeat( 'A', 256 ) ); 1043 1043 $this->assertEquals( 255, strlen( $stripped ) );
Note: See TracChangeset
for help on using the changeset viewer.