WordPress.org

Make WordPress Core

Ticket #40411: 40411.patch

File 40411.patch, 2.1 KB (added by johnbillion, 2 years ago)
  • tests/phpunit/includes/testcase.php

    diff --git tests/phpunit/includes/testcase.php tests/phpunit/includes/testcase.php
    index c77511d3a4..8e845db704 100644
    class WP_UnitTestCase extends PHPUnit_Framework_TestCase { 
    627627        /**
    628628         * Check each of the WP_Query is_* functions/properties against expected boolean value.
    629629         *
    630          * Any properties that are listed by name as parameters will be expected to be true; any others are
     630         * Any properties that are listed by name as parameters will be expected to be true; all others are
    631631         * expected to be false. For example, assertQueryTrue('is_single', 'is_feed') means is_single()
    632632         * and is_feed() must be true and everything else must be false to pass.
    633633         *
    class WP_UnitTestCase extends PHPUnit_Framework_TestCase { 
    668668                $true = func_get_args();
    669669
    670670                foreach ( $true as $true_thing ) {
    671                         $this->assertContains( $true_thing, $all, "{$true_thing}() is not handled by assertQueryTrue()." );
     671                        $this->assertContains( $true_thing, $all, "Unknown conditional: {$true_thing}." );
    672672                }
    673673
    674674                $passed = true;
    675                 $not_false = $not_true = array(); // properties that were not set to expected values
     675                $message = '';
    676676
    677677                foreach ( $all as $query_thing ) {
    678678                        $result = is_callable( $query_thing ) ? call_user_func( $query_thing ) : $wp_query->$query_thing;
    679679
    680680                        if ( in_array( $query_thing, $true ) ) {
    681681                                if ( ! $result ) {
    682                                         array_push( $not_true, $query_thing );
     682                                        $message .= $query_thing . ' is false but is expected to be true. ' . PHP_EOL;
    683683                                        $passed = false;
    684684                                }
    685685                        } else if ( $result ) {
    686                                 array_push( $not_false, $query_thing );
     686                                $message .= $query_thing . ' is true but is expected to be false. ' . PHP_EOL;
    687687                                $passed = false;
    688688                        }
    689689                }
    690690
    691                 $message = '';
    692                 if ( count($not_true) )
    693                         $message .= implode( $not_true, ', ' ) . ' is expected to be true. ';
    694                 if ( count($not_false) )
    695                         $message .= implode( $not_false, ', ' ) . ' is expected to be false.';
    696                 $this->assertTrue( $passed, $message );
     691                if ( ! $passed ) {
     692                        $this->fail( $message );
     693                }
    697694        }
    698695
    699696        function unlink( $file ) {