Changeset 52010 for trunk/tests/phpunit/tests/db.php
- Timestamp:
- 11/04/2021 03:22:47 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/db.php
r51568 r52010 122 122 * @ticket 10041 123 123 */ 124 function test_esc_like() {124 public function test_esc_like() { 125 125 global $wpdb; 126 126 … … 158 158 * @param $result string The expected comparison result; '1' = true, '0' = false 159 159 */ 160 function test_like_query( $data, $like, $result ) {160 public function test_like_query( $data, $like, $result ) { 161 161 global $wpdb; 162 162 return $this->assertSame( $result, $wpdb->get_var( $wpdb->prepare( 'SELECT %s LIKE %s', $data, $wpdb->esc_like( $like ) ) ) ); 163 163 } 164 164 165 function data_like_query() {165 public function data_like_query() { 166 166 return array( 167 167 array( … … 221 221 * @ticket 18510 222 222 */ 223 function test_wpdb_supposedly_protected_properties() {223 public function test_wpdb_supposedly_protected_properties() { 224 224 global $wpdb; 225 225 … … 237 237 * @ticket 21212 238 238 */ 239 function test_wpdb_actually_protected_properties() {239 public function test_wpdb_actually_protected_properties() { 240 240 global $wpdb; 241 241 … … 252 252 * @ticket 18510 253 253 */ 254 function test_wpdb_nonexistent_properties() {254 public function test_wpdb_nonexistent_properties() { 255 255 global $wpdb; 256 256 … … 283 283 * @ticket 26847 284 284 */ 285 function test_set_sql_mode() {285 public function test_set_sql_mode() { 286 286 global $wpdb; 287 287 … … 303 303 * @ticket 26847 304 304 */ 305 function test_set_incompatible_sql_mode() {305 public function test_set_incompatible_sql_mode() { 306 306 global $wpdb; 307 307 … … 321 321 * @ticket 26847 322 322 */ 323 function test_set_allowed_incompatible_sql_mode() {323 public function test_set_allowed_incompatible_sql_mode() { 324 324 global $wpdb; 325 325 … … 354 354 * @expectedIncorrectUsage wpdb::prepare 355 355 */ 356 function test_prepare_without_arguments() {356 public function test_prepare_without_arguments() { 357 357 global $wpdb; 358 358 $id = 0; … … 363 363 } 364 364 365 function test_prepare_sprintf() {365 public function test_prepare_sprintf() { 366 366 global $wpdb; 367 367 … … 373 373 * @expectedIncorrectUsage wpdb::prepare 374 374 */ 375 function test_prepare_sprintf_invalid_args() {375 public function test_prepare_sprintf_invalid_args() { 376 376 global $wpdb; 377 377 … … 385 385 } 386 386 387 function test_prepare_vsprintf() {387 public function test_prepare_vsprintf() { 388 388 global $wpdb; 389 389 … … 395 395 * @expectedIncorrectUsage wpdb::prepare 396 396 */ 397 function test_prepare_vsprintf_invalid_args() {397 public function test_prepare_vsprintf_invalid_args() { 398 398 global $wpdb; 399 399 … … 472 472 } 473 473 474 function test_db_version() {474 public function test_db_version() { 475 475 global $wpdb; 476 476 … … 478 478 } 479 479 480 function test_get_caller() {480 public function test_get_caller() { 481 481 global $wpdb; 482 482 $str = $wpdb->get_caller(); … … 486 486 } 487 487 488 function test_has_cap() {488 public function test_has_cap() { 489 489 global $wpdb; 490 490 $this->assertTrue( $wpdb->has_cap( 'collation' ) ); … … 507 507 * @expectedDeprecated supports_collation 508 508 */ 509 function test_supports_collation() {509 public function test_supports_collation() { 510 510 global $wpdb; 511 511 $this->assertTrue( $wpdb->supports_collation() ); 512 512 } 513 513 514 function test_check_database_version() {514 public function test_check_database_version() { 515 515 global $wpdb; 516 516 $this->assertEmpty( $wpdb->check_database_version() ); 517 517 } 518 518 519 function test_bail() {519 public function test_bail() { 520 520 global $wpdb; 521 521 … … 524 524 } 525 525 526 function test_timers() {526 public function test_timers() { 527 527 global $wpdb; 528 528 … … 535 535 } 536 536 537 function test_get_col_info() {537 public function test_get_col_info() { 538 538 global $wpdb; 539 539 … … 545 545 } 546 546 547 function test_query_and_delete() {547 public function test_query_and_delete() { 548 548 global $wpdb; 549 549 $rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" ); … … 554 554 } 555 555 556 function test_get_row() {556 public function test_get_row() { 557 557 global $wpdb; 558 558 $rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" ); … … 577 577 * @ticket 45299 578 578 */ 579 function test_get_col( $query, $expected, $last_result, $column ) {579 public function test_get_col( $query, $expected, $last_result, $column ) { 580 580 global $wpdb; 581 581 … … 607 607 * @type int|string $column The column index to retrieve. 608 608 */ 609 function data_test_get_col() {609 public function data_test_get_col() { 610 610 global $wpdb; 611 611 … … 656 656 } 657 657 658 function test_replace() {658 public function test_replace() { 659 659 global $wpdb; 660 660 $rows1 = $wpdb->insert( $wpdb->users, array( 'display_name' => 'Walter Sobchak' ) ); … … 684 684 * @ticket 26106 685 685 */ 686 function test_empty_where_on_update() {686 public function test_empty_where_on_update() { 687 687 global $wpdb; 688 688 $suppress = $wpdb->suppress_errors( true ); … … 706 706 * @ticket 28155 707 707 */ 708 function test_mysqli_flush_sync() {708 public function test_mysqli_flush_sync() { 709 709 global $wpdb; 710 710 if ( ! $wpdb->use_mysqli ) { … … 742 742 * @ticket 32763 743 743 */ 744 function data_get_table_from_query() {744 public function data_get_table_from_query() { 745 745 $table = 'a_test_table_name'; 746 746 $more_tables = array( … … 866 866 * @ticket 21212 867 867 */ 868 function test_get_table_from_query( $query, $table ) {868 public function test_get_table_from_query( $query, $table ) { 869 869 $this->assertSame( $table, self::$_wpdb->get_table_from_query( $query ) ); 870 870 } 871 871 872 function data_get_table_from_query_false() {872 public function data_get_table_from_query_false() { 873 873 $table = 'a_test_table_name'; 874 874 return array( … … 881 881 * @ticket 21212 882 882 */ 883 function test_get_table_from_query_false( $query ) {883 public function test_get_table_from_query_false( $query ) { 884 884 $this->assertFalse( self::$_wpdb->get_table_from_query( $query ) ); 885 885 } … … 888 888 * @ticket 38751 889 889 */ 890 function data_get_escaped_table_from_show_query() {890 public function data_get_escaped_table_from_show_query() { 891 891 return array( 892 892 // Equality. … … 908 908 * @ticket 38751 909 909 */ 910 function test_get_escaped_table_from_show_query( $query, $table ) {910 public function test_get_escaped_table_from_show_query( $query, $table ) { 911 911 $this->assertSame( $table, self::$_wpdb->get_table_from_query( $query ) ); 912 912 } … … 915 915 * @ticket 21212 916 916 */ 917 function data_process_field_formats() {917 public function data_process_field_formats() { 918 918 $core_db_fields_no_format_specified = array( 919 919 array( … … 1023 1023 * @ticket 21212 1024 1024 */ 1025 function test_process_field_formats( $data, $format, $expected, $message ) {1025 public function test_process_field_formats( $data, $format, $expected, $message ) { 1026 1026 $actual = self::$_wpdb->process_field_formats( $data, $format ); 1027 1027 $this->assertSame( $expected, $actual, $message ); … … 1031 1031 * @ticket 21212 1032 1032 */ 1033 function test_process_fields() {1033 public function test_process_fields() { 1034 1034 global $wpdb; 1035 1035 … … 1061 1061 * @depends test_process_fields 1062 1062 */ 1063 function test_process_fields_on_nonexistent_table( $data ) {1063 public function test_process_fields_on_nonexistent_table( $data ) { 1064 1064 self::$_wpdb->suppress_errors( true ); 1065 1065 $data = array( 'post_content' => '¡foo foo foo!' ); … … 1071 1071 * @ticket 21212 1072 1072 */ 1073 function test_pre_get_table_charset_filter() {1073 public function test_pre_get_table_charset_filter() { 1074 1074 add_filter( 'pre_get_table_charset', array( $this, 'filter_pre_get_table_charset' ), 10, 2 ); 1075 1075 $charset = self::$_wpdb->get_table_charset( 'some_table' ); … … 1078 1078 $this->assertSame( $charset, 'fake_charset' ); 1079 1079 } 1080 function filter_pre_get_table_charset( $charset, $table ) {1080 public function filter_pre_get_table_charset( $charset, $table ) { 1081 1081 return 'fake_charset'; 1082 1082 } … … 1085 1085 * @ticket 21212 1086 1086 */ 1087 function test_pre_get_col_charset_filter() {1087 public function test_pre_get_col_charset_filter() { 1088 1088 add_filter( 'pre_get_col_charset', array( $this, 'filter_pre_get_col_charset' ), 10, 3 ); 1089 1089 $charset = self::$_wpdb->get_col_charset( 'some_table', 'some_col' ); … … 1092 1092 $this->assertSame( $charset, 'fake_col_charset' ); 1093 1093 } 1094 function filter_pre_get_col_charset( $charset, $table, $column ) {1094 public function filter_pre_get_col_charset( $charset, $table, $column ) { 1095 1095 return 'fake_col_charset'; 1096 1096 } … … 1099 1099 * @ticket 15158 1100 1100 */ 1101 function test_null_insert() {1101 public function test_null_insert() { 1102 1102 global $wpdb; 1103 1103 … … 1121 1121 * @ticket 15158 1122 1122 */ 1123 function test_null_update_value() {1123 public function test_null_update_value() { 1124 1124 global $wpdb; 1125 1125 … … 1159 1159 * @ticket 15158 1160 1160 */ 1161 function test_null_update_where() {1161 public function test_null_update_where() { 1162 1162 global $wpdb; 1163 1163 … … 1197 1197 * @ticket 15158 1198 1198 */ 1199 function test_null_delete() {1199 public function test_null_delete() { 1200 1200 global $wpdb; 1201 1201 … … 1233 1233 * @ticket 34903 1234 1234 */ 1235 function test_close() {1235 public function test_close() { 1236 1236 global $wpdb; 1237 1237 … … 1252 1252 * @ticket 36917 1253 1253 */ 1254 function test_charset_not_determined_when_disconnected() {1254 public function test_charset_not_determined_when_disconnected() { 1255 1255 global $wpdb; 1256 1256 … … 1270 1270 * @ticket 36917 1271 1271 */ 1272 function test_charset_switched_to_utf8mb4() {1272 public function test_charset_switched_to_utf8mb4() { 1273 1273 global $wpdb; 1274 1274 … … 1289 1289 * @ticket 36917 1290 1290 */ 1291 function test_collate_switched_to_utf8mb4_520() {1291 public function test_collate_switched_to_utf8mb4_520() { 1292 1292 global $wpdb; 1293 1293 … … 1308 1308 * @ticket 36917 1309 1309 */ 1310 function test_non_unicode_collations() {1310 public function test_non_unicode_collations() { 1311 1311 global $wpdb; 1312 1312 … … 1326 1326 * @ticket 37982 1327 1327 */ 1328 function test_charset_switched_to_utf8() {1328 public function test_charset_switched_to_utf8() { 1329 1329 global $wpdb; 1330 1330 … … 1345 1345 * @dataProvider data_prepare_with_placeholders 1346 1346 */ 1347 function test_prepare_with_placeholders_and_individual_args( $sql, $values, $incorrect_usage, $expected ) {1347 public function test_prepare_with_placeholders_and_individual_args( $sql, $values, $incorrect_usage, $expected ) { 1348 1348 global $wpdb; 1349 1349 … … 1364 1364 * @dataProvider data_prepare_with_placeholders 1365 1365 */ 1366 function test_prepare_with_placeholders_and_array_args( $sql, $values, $incorrect_usage, $expected ) {1366 public function test_prepare_with_placeholders_and_array_args( $sql, $values, $incorrect_usage, $expected ) { 1367 1367 global $wpdb; 1368 1368 … … 1380 1380 } 1381 1381 1382 function data_prepare_with_placeholders() {1382 public function data_prepare_with_placeholders() { 1383 1383 global $wpdb; 1384 1384 … … 1558 1558 * @dataProvider data_escape_and_prepare 1559 1559 */ 1560 function test_escape_and_prepare( $escape, $sql, $values, $incorrect_usage, $expected ) {1560 public function test_escape_and_prepare( $escape, $sql, $values, $incorrect_usage, $expected ) { 1561 1561 global $wpdb; 1562 1562 … … 1575 1575 } 1576 1576 1577 function data_escape_and_prepare() {1577 public function data_escape_and_prepare() { 1578 1578 global $wpdb; 1579 1579 return array( … … 1605 1605 * @expectedIncorrectUsage wpdb::prepare 1606 1606 */ 1607 function test_double_prepare() {1607 public function test_double_prepare() { 1608 1608 global $wpdb; 1609 1609 … … 1615 1615 } 1616 1616 1617 function test_prepare_numeric_placeholders_float_args() {1617 public function test_prepare_numeric_placeholders_float_args() { 1618 1618 global $wpdb; 1619 1619 … … 1630 1630 } 1631 1631 1632 function test_prepare_numeric_placeholders_float_array() {1632 public function test_prepare_numeric_placeholders_float_array() { 1633 1633 global $wpdb; 1634 1634 … … 1644 1644 } 1645 1645 1646 function test_query_unescapes_placeholders() {1646 public function test_query_unescapes_placeholders() { 1647 1647 global $wpdb; 1648 1648 … … 1663 1663 } 1664 1664 1665 function test_esc_sql_with_unsupported_placeholder_type() {1665 public function test_esc_sql_with_unsupported_placeholder_type() { 1666 1666 global $wpdb; 1667 1667
Note: See TracChangeset
for help on using the changeset viewer.