Changeset 904 in tests for trunk/tests/canonical.php
- Timestamp:
- 07/18/2012 07:01:41 PM (12 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/canonical.php
r903 r904 9 9 * @group query 10 10 */ 11 class WP_Test_Canonical extends WP_UnitTestCase {11 class Tests_Canonical extends WP_UnitTestCase { 12 12 13 13 // This can be defined in a subclass of this class which contains it's own data() method, those tests will be run against the specified permastruct … … 273 273 } 274 274 } 275 276 /**277 * @group canonical278 * @group rewrite279 * @group query280 */281 class WP_Canonical_PageOnFront extends WP_Test_Canonical {282 function setUp() {283 parent::setUp();284 global $wp_rewrite;285 update_option( 'show_on_front', 'page' );286 update_option( 'page_for_posts', $this->factory->post->create( array( 'post_title' => 'blog-page', 'post_type' => 'page' ) ) );287 update_option( 'page_on_front', $this->factory->post->create( array( 'post_title' => 'front-page', 'post_type' => 'page' ) ) );288 $wp_rewrite->init();289 flush_rewrite_rules();290 }291 292 function data() {293 /* Format:294 * [0]: $test_url,295 * [1]: expected results: Any of the following can be used296 * array( 'url': expected redirection location, 'qv': expected query vars to be set via the rewrite AND $_GET );297 * array( expected query vars to be set, same as 'qv' above )298 * (string) expected redirect location299 * [3]: (optional) The ticket the test refers to, Can be skipped if unknown.300 */301 return array(302 // Check against an odd redirect303 array( '/page/2/', '/page/2/', 20385 ),304 // The page designated as the front page should redirect to the front of the site305 array( '/front-page/', '/' ),306 array( '/blog-page/?paged=2', '/blog-page/page/2/' ),307 );308 }309 }310 311 /**312 * @group canonical313 * @group rewrite314 * @group query315 */316 class WP_Canonical_CustomRules extends WP_Test_Canonical {317 function setUp() {318 parent::setUp();319 global $wp_rewrite;320 // Add a custom Rewrite rule to test category redirections.321 $wp_rewrite->add_rule('ccr/(.+?)/sort/(asc|desc)', 'index.php?category_name=$matches[1]&order=$matches[2]', 'top'); // ccr = Custom_Cat_Rule322 $wp_rewrite->flush_rules();323 }324 325 function data() {326 /* Format:327 * [0]: $test_url,328 * [1]: expected results: Any of the following can be used329 * array( 'url': expected redirection location, 'qv': expected query vars to be set via the rewrite AND $_GET );330 * array( expected query vars to be set, same as 'qv' above )331 * (string) expected redirect location332 * [3]: (optional) The ticket the test refers to, Can be skipped if unknown.333 */334 return array(335 // Custom Rewrite rules leading to Categories336 array( '/ccr/uncategorized/sort/asc/', array( 'url' => '/ccr/uncategorized/sort/asc/', 'qv' => array( 'category_name' => 'uncategorized', 'order' => 'asc' ) ) ),337 array( '/ccr/uncategorized/sort/desc/', array( 'url' => '/ccr/uncategorized/sort/desc/', 'qv' => array( 'category_name' => 'uncategorized', 'order' => 'desc' ) ) ),338 array( '/ccr/uncategorized/sort/desc/?year=2008', array( 'url' => '/ccr/uncategorized/sort/desc/?year=2008', 'qv' => array( 'category_name' => 'uncategorized', 'order' => 'desc', 'year' => '2008' ) ), 17661 ),339 );340 }341 }342 343 /**344 * @group canonical345 * @group rewrite346 * @group query347 */348 class WP_Canonical_NoRewrite extends WP_Test_Canonical {349 350 var $structure = '';351 352 // These test cases are run against the test handler in WP_Canonical353 354 function data() {355 /* Format:356 * [0]: $test_url,357 * [1]: expected results: Any of the following can be used358 * array( 'url': expected redirection location, 'qv': expected query vars to be set via the rewrite AND $_GET );359 * array( expected query vars to be set, same as 'qv' above )360 * (string) expected redirect location361 * [3]: (optional) The ticket the test refers to, Can be skipped if unknown.362 */363 return array(364 array( '/?p=123', '/?p=123' ),365 366 // This post_type arg should be stripped, because p=1 exists, and does not have post_type= in its query string367 array( '/?post_type=fake-cpt&p=1', '/?p=1' ),368 369 // Strip an existing but incorrect post_type arg370 array( '/?post_type=page&page_id=1', '/?p=1' ),371 372 array( '/?p=358 ', array('url' => '/?p=358', 'qv' => array('p' => '358') ) ), // Trailing spaces373 array( '/?p=358%20', array('url' => '/?p=358', 'qv' => array('p' => '358') ) ),374 375 array( '/?page_id=1', '/?p=1' ), // redirect page_id to p (should cover page_id|p|attachment_id to one another376 array( '/?page_id=1&post_type=revision', '/?p=1' ),377 378 );379 }380 }
Note: See TracChangeset
for help on using the changeset viewer.