diff --git tests/phpunit/includes/testcase.php tests/phpunit/includes/testcase.php
index c77511d3a4..8e845db704 100644
|
|
class WP_UnitTestCase extends PHPUnit_Framework_TestCase { |
627 | 627 | /** |
628 | 628 | * Check each of the WP_Query is_* functions/properties against expected boolean value. |
629 | 629 | * |
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 |
631 | 631 | * expected to be false. For example, assertQueryTrue('is_single', 'is_feed') means is_single() |
632 | 632 | * and is_feed() must be true and everything else must be false to pass. |
633 | 633 | * |
… |
… |
class WP_UnitTestCase extends PHPUnit_Framework_TestCase { |
668 | 668 | $true = func_get_args(); |
669 | 669 | |
670 | 670 | 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}." ); |
672 | 672 | } |
673 | 673 | |
674 | 674 | $passed = true; |
675 | | $not_false = $not_true = array(); // properties that were not set to expected values |
| 675 | $message = ''; |
676 | 676 | |
677 | 677 | foreach ( $all as $query_thing ) { |
678 | 678 | $result = is_callable( $query_thing ) ? call_user_func( $query_thing ) : $wp_query->$query_thing; |
679 | 679 | |
680 | 680 | if ( in_array( $query_thing, $true ) ) { |
681 | 681 | if ( ! $result ) { |
682 | | array_push( $not_true, $query_thing ); |
| 682 | $message .= $query_thing . ' is false but is expected to be true. ' . PHP_EOL; |
683 | 683 | $passed = false; |
684 | 684 | } |
685 | 685 | } else if ( $result ) { |
686 | | array_push( $not_false, $query_thing ); |
| 686 | $message .= $query_thing . ' is true but is expected to be false. ' . PHP_EOL; |
687 | 687 | $passed = false; |
688 | 688 | } |
689 | 689 | } |
690 | 690 | |
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 | } |
697 | 694 | } |
698 | 695 | |
699 | 696 | function unlink( $file ) { |