Changeset 40416
- Timestamp:
- 04/11/2017 10:48:00 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/testcase.php
r40347 r40416 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; a nyothers are630 * 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. … … 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 values675 $message = ''; 676 676 677 677 foreach ( $all as $query_thing ) { … … 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
Note: See TracChangeset
for help on using the changeset viewer.