Make WordPress Core

Changeset 669 in tests


Ignore:
Timestamp:
04/12/2012 06:28:52 AM (14 years ago)
Author:
markjaquith
Message:

Canonical redirect tests for "page-on-front" situation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_canonical.php

    r635 r669  
    215215
    216216                );
     217        }
     218}
     219
     220class WP_Canonical_PageOnFront extends WP_Canonical {
     221        var $special_pages = array();
     222
     223        function SetUp() {
     224                global $wp_rewrite;
     225                parent::SetUp();
     226                $this->special_pages['blog' ] = wp_insert_post( array( 'post_type' => 'page', 'post_status' => 'publish', 'post_title' => 'blog-page'  ) );
     227                $this->special_pages['front'] = wp_insert_post( array( 'post_type' => 'page', 'post_status' => 'publish', 'post_title' => 'front-page' ) );
     228                update_option( 'show_on_front', 'page' );
     229                update_option( 'page_for_posts', $this->special_pages['blog'] );
     230                update_option( 'page_on_front', $this->special_pages['front'] );
     231                $wp_rewrite->flush_rules();
     232        }
     233
     234        function tearDown() {
     235                parent::tearDown();
     236                update_option( 'show_on_front', 'posts' );
     237               
     238                delete_option( 'page_for_posts' );
     239                delete_option( 'page_on_front' );
     240                delete_option( 'permalink_structure' );
     241
     242                foreach ( $this->special_pages as $p )
     243                        wp_delete_post( $p );
     244                global $wp_rewrite;
     245                $wp_rewrite->set_permalink_structure('');
     246                $wp_rewrite->flush_rules();
     247
     248                $_GET = array();
     249        }
     250
     251        function data() {
     252                /* Format:
     253                 * [0]: $test_url,
     254                 * [1]: expected results: Any of the following can be used
     255                 *      array( 'url': expected redirection location, 'qv': expected query vars to be set via the rewrite AND $_GET );
     256                 *      array( expected query vars to be set, same as 'qv' above )
     257                 *      (string) expected redirect location
     258                 * [3]: (optional) The ticket the test refers to, Can be skipped if unknown.
     259                 */
     260                 return array(
     261                         // Check against an odd redirect: #20385
     262                         array( '/page/2/', '/page/2/' ),
     263                         // The page designated as the front page should redirect to the front of the site
     264                         array( '/front-page/', '/' ),
     265                         array( '/blog-page/?paged=2', '/blog-page/page/2/' ),
     266                 );
    217267        }
    218268}
Note: See TracChangeset for help on using the changeset viewer.