Ticket #46500: 46500.diff
File 46500.diff, 4.9 KB (added by , 5 years ago) |
---|
-
tests/phpunit/includes/abstract-testcase.php
360 360 } 361 361 362 362 public function _create_temporary_tables( $query ) { 363 if ( 'CREATE TABLE' === substr( trim( $query ), 0, 12 )) {363 if ( strpos( trim( $query ), 'CREATE TABLE' ) === 0 ) { 364 364 return substr_replace( trim( $query ), 'CREATE TEMPORARY TABLE', 0, 12 ); 365 365 } 366 366 return $query; … … 367 367 } 368 368 369 369 public function _drop_temporary_tables( $query ) { 370 if ( 'DROP TABLE' === substr( trim( $query ), 0, 10 )) {370 if ( strpos( trim( $query ), 'DROP TABLE' ) === 0 ) { 371 371 return substr_replace( trim( $query ), 'DROP TEMPORARY TABLE', 0, 10 ); 372 372 } 373 373 return $query; … … 457 457 * first parameter of the `_deprecated_function()` or `_deprecated_argument()` call. 458 458 */ 459 459 public function setExpectedDeprecated( $deprecated ) { 460 array_push( $this->expected_deprecated, $deprecated );460 $this->expected_deprecated[] = $deprecated; 461 461 } 462 462 463 463 /** … … 469 469 * source `_doing_it_wrong()` call. 470 470 */ 471 471 public function setExpectedIncorrectUsage( $doing_it_wrong ) { 472 array_push( $this->expected_doing_it_wrong, $doing_it_wrong );472 $this->expected_doing_it_wrong[] = $doing_it_wrong; 473 473 } 474 474 475 475 /** … … 494 494 } 495 495 496 496 public function deprecated_function_run( $function ) { 497 if ( ! in_array( $function, $this->caught_deprecated ) ) {497 if ( ! in_array( $function, $this->caught_deprecated, true ) ) { 498 498 $this->caught_deprecated[] = $function; 499 499 } 500 500 } 501 501 502 502 public function doing_it_wrong_run( $function ) { 503 if ( ! in_array( $function, $this->caught_doing_it_wrong ) ) {503 if ( ! in_array( $function, $this->caught_doing_it_wrong, true ) ) { 504 504 $this->caught_doing_it_wrong[] = $function; 505 505 } 506 506 } … … 510 510 } 511 511 512 512 public function assertNotWPError( $actual, $message = '' ) { 513 if ( is_wp_error( $actual ) && '' === $message) {513 if ( '' === $message && is_wp_error( $actual ) ) { 514 514 $message = $actual->get_error_message(); 515 515 } 516 516 $this->assertNotInstanceOf( 'WP_Error', $actual, $message ); … … 529 529 530 530 public function assertEqualFields( $object, $fields ) { 531 531 foreach ( $fields as $field_name => $field_value ) { 532 if ( $object->$field_name != $field_value ) {532 if ( $object->$field_name !== $field_value ) { 533 533 $this->fail(); 534 534 } 535 535 } … … 687 687 foreach ( $tickets as $ticket ) { 688 688 if ( is_numeric( $ticket ) ) { 689 689 $this->knownWPBug( $ticket ); 690 } elseif ( 'Plugin' == substr( $ticket, 0, 6 )) {690 } elseif ( strpos( $ticket, 'Plugin' ) === 0 ) { 691 691 $ticket = substr( $ticket, 6 ); 692 692 if ( $ticket && is_numeric( $ticket ) ) { 693 693 $this->knownPluginBug( $ticket ); … … 704 704 * @param int $ticket_id Ticket number. 705 705 */ 706 706 public function knownWPBug( $ticket_id ) { 707 if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( $ticket_id, self::$forced_tickets ) ) {707 if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( $ticket_id, self::$forced_tickets, true ) ) { 708 708 return; 709 709 } 710 710 if ( ! TracTickets::isTracTicketClosed( 'https://core.trac.wordpress.org', $ticket_id ) ) { … … 733 733 * @param int $ticket_id Ticket number. 734 734 */ 735 735 public function knownPluginBug( $ticket_id ) { 736 if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'Plugin' . $ticket_id, self::$forced_tickets ) ) {736 if ( WP_TESTS_FORCE_KNOWN_BUGS || in_array( 'Plugin' . $ticket_id, self::$forced_tickets, true ) ) { 737 737 return; 738 738 } 739 739 if ( ! TracTickets::isTracTicketClosed( 'https://plugins.trac.wordpress.org', $ticket_id ) ) { … … 849 849 foreach ( $all as $query_thing ) { 850 850 $result = is_callable( $query_thing ) ? call_user_func( $query_thing ) : $wp_query->$query_thing; 851 851 852 if ( in_array( $query_thing, $true ) ) {852 if ( in_array( $query_thing, $true, true ) ) { 853 853 if ( ! $result ) { 854 854 $message .= $query_thing . ' is false but is expected to be true. ' . PHP_EOL; 855 855 $passed = false; … … 874 874 */ 875 875 public function unlink( $file ) { 876 876 $exists = is_file( $file ); 877 if ( $exists && ! in_array( $file, self::$ignore_files ) ) {877 if ( $exists && ! in_array( $file, self::$ignore_files, true ) ) { 878 878 //error_log( $file ); 879 879 unlink( $file ); 880 880 } elseif ( ! $exists ) { … … 892 892 public function rmdir( $path ) { 893 893 $files = $this->files_in_dir( $path ); 894 894 foreach ( $files as $file ) { 895 if ( ! in_array( $file, self::$ignore_files ) ) {895 if ( ! in_array( $file, self::$ignore_files, true ) ) { 896 896 $this->unlink( $file ); 897 897 } 898 898 } … … 1018 1018 public static function delete_user( $user_id ) { 1019 1019 if ( is_multisite() ) { 1020 1020 return wpmu_delete_user( $user_id ); 1021 } else {1022 return wp_delete_user( $user_id );1023 1021 } 1022 1023 return wp_delete_user( $user_id ); 1024 1024 } 1025 1025 1026 1026 /**