WordPress.org

Make WordPress Core

Changeset 338 in tests


Ignore:
Timestamp:
03/01/2011 05:48:36 PM (7 years ago)
Author:
duck_
Message:

More WP_Query properties and in order listed in WP_Query. Test verbose rules.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_query.php

    r337 r338  
    77
    88class TestWPQueryVars extends _WPDataset1 {
    9     var $use_verbose_page_rules = true;
    10 
    119    function setUp() {
    1210        parent::setUp();
     
    1513        create_initial_taxonomies();
    1614        $wp_rewrite->flush_rules();
    17 
    18         // setting verbose page rules here is not going to have an effect.
    19         // also, does it make sense to force and test verbose page rules for a non-verbose permalink structure?
    20         //$wp_rewrite->use_verbose_page_rules = $this->use_verbose_page_rules;
    2115    }
    2216
     
    5246    function assertQueryTrue(/* ... */) {
    5347        global $wp_query;
    54 
    5548        $all = array(
    56             'is_admin', 'is_archive', 'is_attachment', 'is_author', 'is_category', 'is_tag', 'is_comments_popup', 'is_date',
    57             'is_day', 'is_feed', 'is_home', 'is_month', 'is_page', 'is_paged', 'is_plugin_page', 'is_preview', 'is_robots',
    58             'is_search', 'is_single', 'is_time', 'is_trackback', 'is_year', 'is_404', 'is_comment_feed',
     49            'is_single', 'is_preview', 'is_page', 'is_archive', 'is_date', 'is_year', 'is_month', 'is_day', 'is_time',
     50            'is_author', 'is_category', 'is_tag', 'is_tax', 'is_search', 'is_feed', 'is_comment_feed', 'is_trackback',
     51            'is_home', 'is_404', 'is_comments_popup', 'is_paged', 'is_admin', 'is_attachment', 'is_singular', 'is_robots',
     52            'is_posts_page', 'is_post_type_archive',
    5953        );
    6054        $true = func_get_args();
     
    108102        $page_id = $this->_get_post_id_by_name('about');
    109103        $this->http(get_permalink($page_id));
    110         $this->assertQueryTrue('is_page');
     104        $this->assertQueryTrue('is_page','is_singular');
    111105    }
    112106
     
    115109        $this->http(get_permalink($page_id));
    116110
    117         $this->assertQueryTrue('is_page');
     111        $this->assertQueryTrue('is_page','is_singular');
    118112    }
    119113
     
    122116        $this->http(get_permalink($page_id));
    123117
    124         $this->assertQueryTrue('is_page');
     118        $this->assertQueryTrue('is_page','is_singular');
    125119    }
    126120
     
    129123        $this->http(get_permalink($page_id));
    130124
    131         $this->assertQueryTrue('is_page');
     125        $this->assertQueryTrue('is_page','is_singular');
    132126    }
    133127
     
    141135
    142136            // make sure the correct wp_query flags are set
    143             $this->assertQueryTrue('is_page', 'is_trackback');
     137            $this->assertQueryTrue('is_page','is_singular','is_trackback');
    144138
    145139            // make sure the correct page was fetched
     
    158152
    159153            // make sure the correct wp_query flags are set
    160             $this->assertQueryTrue('is_page', 'is_feed', 'is_comment_feed');
     154            $this->assertQueryTrue('is_page', 'is_singular', 'is_feed', 'is_comment_feed');
    161155
    162156            // make sure the correct page was fetched
     
    176170
    177171            // make sure the correct wp_query flags are set
    178             $this->assertQueryTrue('is_page', 'is_feed', 'is_comment_feed');
     172            $this->assertQueryTrue('is_page', 'is_singular', 'is_feed', 'is_comment_feed');
    179173
    180174            // make sure the correct page was fetched
     
    193187
    194188            // make sure the correct wp_query flags are set
    195             $this->assertQueryTrue('is_page', 'is_paged');
     189            $this->assertQueryTrue('is_page', 'is_singular', 'is_paged');
    196190
    197191            // make sure the correct page was fetched
     
    208202        $this->http('/about/2/');
    209203
    210         $this->assertQueryTrue('is_page');
     204        $this->assertQueryTrue('is_page', 'is_singular');
    211205    }
    212206
     
    225219        foreach ($feeds as $feed) {
    226220            $this->http("/feed/{$feed}/");
    227 
    228221            $this->assertQueryTrue('is_feed');
    229222        }
     
    232225        foreach ($feeds as $feed) {
    233226            $this->http("/{$feed}/");
    234 
    235227            $this->assertQueryTrue('is_feed');
    236228        }
     
    239231
    240232    function test_main_feed() {
    241 
    242233        $types = array('rss2', 'rss', 'atom');
    243234        foreach ($types as $type) {
     
    246237        }
    247238    }
    248 
    249239
    250240    // 'page/?([0-9]{1,})/?$' => 'index.php?&paged=$matches[1]',
     
    503493            $permalink = get_permalink($id);
    504494            $this->http("{$permalink}trackback/");
    505             $this->assertQueryTrue('is_single', 'is_trackback');
     495            $this->assertQueryTrue('is_single', 'is_singular', 'is_trackback');
    506496        }
    507497    }
     
    516506            foreach ($types as $type) {
    517507                    $this->http("{$permalink}feed/{$type}");
    518                     $this->assertQueryTrue('is_single', 'is_feed', 'is_comment_feed');
     508                    $this->assertQueryTrue('is_single', 'is_singular', 'is_feed', 'is_comment_feed');
    519509            }
    520510
     
    523513            foreach ($types as $type) {
    524514                    $this->http("{$permalink}{$type}");
    525                     $this->assertQueryTrue('is_single', 'is_feed', 'is_comment_feed');
     515                    $this->assertQueryTrue('is_single', 'is_singular', 'is_feed', 'is_comment_feed');
    526516            }
    527517
     
    535525        $this->http('/2007/09/04/a-post-with-multiple-pages/page/2/');
    536526        // should is_paged be true also?
    537         $this->assertQueryTrue('is_single');
     527        $this->assertQueryTrue('is_single', 'is_singular');
    538528    }
    539529
     
    544534        $this->http('/2007/09/04/a-post-with-multiple-pages/2/');
    545535        // should is_paged be true also?
    546         $this->assertQueryTrue('is_single');
     536        $this->assertQueryTrue('is_single', 'is_singular');
    547537       
    548538    }
     
    553543        $permalink = get_attachment_link(8);
    554544        $this->http($permalink);
    555         $this->assertQueryTrue('is_attachment');
     545        $this->assertQueryTrue('is_attachment', 'is_singular');
    556546    }
    557547
     
    563553    // '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
    564554    // '[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?attachment=$matches[1]&feed=$matches[2]',
    565     //
    566555}
    567556
    568 class TestWPQueryShortPageRules extends TestWPQueryVars {
    569     var $use_verbose_page_rules = false;
     557class TestWPQueryVerbosePageRules extends TestWPQueryVars {
     558    function setUp() {
     559        parent::setUp();
     560        global $wp_rewrite;
     561        $wp_rewrite->set_permalink_structure('/%author%/%year%/%postname%/');
     562        create_initial_taxonomies();
     563        $wp_rewrite->flush_rules();
     564    }
    570565}
    571566
    572 
    573567?>
Note: See TracChangeset for help on using the changeset viewer.