Make WordPress Core

Ticket #46500: 46500.diff

File 46500.diff, 4.9 KB (added by andizer, 5 years ago)
  • tests/phpunit/includes/abstract-testcase.php

     
    360360        }
    361361
    362362        public function _create_temporary_tables( $query ) {
    363                 if ( 'CREATE TABLE' === substr( trim( $query ), 0, 12 ) ) {
     363                if ( strpos( trim( $query ), 'CREATE TABLE' ) === 0 ) {
    364364                        return substr_replace( trim( $query ), 'CREATE TEMPORARY TABLE', 0, 12 );
    365365                }
    366366                return $query;
     
    367367        }
    368368
    369369        public function _drop_temporary_tables( $query ) {
    370                 if ( 'DROP TABLE' === substr( trim( $query ), 0, 10 ) ) {
     370                if ( strpos( trim( $query ), 'DROP TABLE' ) === 0 ) {
    371371                        return substr_replace( trim( $query ), 'DROP TEMPORARY TABLE', 0, 10 );
    372372                }
    373373                return $query;
     
    457457         *                           first parameter of the `_deprecated_function()` or `_deprecated_argument()` call.
    458458         */
    459459        public function setExpectedDeprecated( $deprecated ) {
    460                 array_push( $this->expected_deprecated, $deprecated );
     460                $this->expected_deprecated[] = $deprecated;
    461461        }
    462462
    463463        /**
     
    469469         *                           source `_doing_it_wrong()` call.
    470470         */
    471471        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;
    473473        }
    474474
    475475        /**
     
    494494        }
    495495
    496496        public function deprecated_function_run( $function ) {
    497                 if ( ! in_array( $function, $this->caught_deprecated ) ) {
     497                if ( ! in_array( $function, $this->caught_deprecated, true ) ) {
    498498                        $this->caught_deprecated[] = $function;
    499499                }
    500500        }
    501501
    502502        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 ) ) {
    504504                        $this->caught_doing_it_wrong[] = $function;
    505505                }
    506506        }
     
    510510        }
    511511
    512512        public function assertNotWPError( $actual, $message = '' ) {
    513                 if ( is_wp_error( $actual ) && '' === $message ) {
     513                if ( '' === $message && is_wp_error( $actual ) ) {
    514514                        $message = $actual->get_error_message();
    515515                }
    516516                $this->assertNotInstanceOf( 'WP_Error', $actual, $message );
     
    529529
    530530        public function assertEqualFields( $object, $fields ) {
    531531                foreach ( $fields as $field_name => $field_value ) {
    532                         if ( $object->$field_name != $field_value ) {
     532                        if ( $object->$field_name !== $field_value ) {
    533533                                $this->fail();
    534534                        }
    535535                }
     
    687687                foreach ( $tickets as $ticket ) {
    688688                        if ( is_numeric( $ticket ) ) {
    689689                                $this->knownWPBug( $ticket );
    690                         } elseif ( 'Plugin' == substr( $ticket, 0, 6 ) ) {
     690                        } elseif ( strpos( $ticket, 'Plugin' ) === 0 ) {
    691691                                $ticket = substr( $ticket, 6 );
    692692                                if ( $ticket && is_numeric( $ticket ) ) {
    693693                                        $this->knownPluginBug( $ticket );
     
    704704         * @param int $ticket_id Ticket number.
    705705         */
    706706        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 ) ) {
    708708                        return;
    709709                }
    710710                if ( ! TracTickets::isTracTicketClosed( 'https://core.trac.wordpress.org', $ticket_id ) ) {
     
    733733         * @param int $ticket_id Ticket number.
    734734         */
    735735        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 ) ) {
    737737                        return;
    738738                }
    739739                if ( ! TracTickets::isTracTicketClosed( 'https://plugins.trac.wordpress.org', $ticket_id ) ) {
     
    849849                foreach ( $all as $query_thing ) {
    850850                        $result = is_callable( $query_thing ) ? call_user_func( $query_thing ) : $wp_query->$query_thing;
    851851
    852                         if ( in_array( $query_thing, $true ) ) {
     852                        if ( in_array( $query_thing, $true, true ) ) {
    853853                                if ( ! $result ) {
    854854                                        $message .= $query_thing . ' is false but is expected to be true. ' . PHP_EOL;
    855855                                        $passed   = false;
     
    874874         */
    875875        public function unlink( $file ) {
    876876                $exists = is_file( $file );
    877                 if ( $exists && ! in_array( $file, self::$ignore_files ) ) {
     877                if ( $exists && ! in_array( $file, self::$ignore_files, true ) ) {
    878878                        //error_log( $file );
    879879                        unlink( $file );
    880880                } elseif ( ! $exists ) {
     
    892892        public function rmdir( $path ) {
    893893                $files = $this->files_in_dir( $path );
    894894                foreach ( $files as $file ) {
    895                         if ( ! in_array( $file, self::$ignore_files ) ) {
     895                        if ( ! in_array( $file, self::$ignore_files, true ) ) {
    896896                                $this->unlink( $file );
    897897                        }
    898898                }
     
    10181018        public static function delete_user( $user_id ) {
    10191019                if ( is_multisite() ) {
    10201020                        return wpmu_delete_user( $user_id );
    1021                 } else {
    1022                         return wp_delete_user( $user_id );
    10231021                }
     1022
     1023                return wp_delete_user( $user_id );
    10241024        }
    10251025
    10261026        /**