Codeception\TestCase\WPTestCase::assertQueryTrue PHP Method

assertQueryTrue() public method

Any properties that are listed by name as parameters will be expected to be true; any others are expected to be false. For example, assertQueryTrue('is_single', 'is_feed') means is_single() and is_feed() must be true and everything else must be false to pass.
public assertQueryTrue ( )
    function assertQueryTrue()
    {
        global $wp_query;
        $all = array('is_404', 'is_admin', 'is_archive', 'is_attachment', 'is_author', 'is_category', 'is_comment_feed', 'is_comments_popup', 'is_date', 'is_day', 'is_embed', 'is_feed', 'is_home', 'is_month', 'is_page', 'is_paged', 'is_post_type_archive', 'is_posts_page', 'is_preview', 'is_robots', 'is_search', 'is_single', 'is_singular', 'is_tag', 'is_tax', 'is_time', 'is_trackback', 'is_year');
        $true = func_get_args();
        $passed = true;
        $not_false = $not_true = array();
        // properties that were not set to expected values
        foreach ($all as $query_thing) {
            $result = is_callable($query_thing) ? call_user_func($query_thing) : $wp_query->{$query_thing};
            if (in_array($query_thing, $true)) {
                if (!$result) {
                    array_push($not_true, $query_thing);
                    $passed = false;
                }
            } else {
                if ($result) {
                    array_push($not_false, $query_thing);
                    $passed = false;
                }
            }
        }
        $message = '';
        if (count($not_true)) {
            $message .= implode($not_true, ', ') . ' is expected to be true. ';
        }
        if (count($not_false)) {
            $message .= implode($not_false, ', ') . ' is expected to be false.';
        }
        $this->assertTrue($passed, $message);
    }