Changeset 34073 for trunk/tests/phpunit/tests/query.php
- Timestamp:
- 09/12/2015 03:36:12 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/query.php
r33850 r34073 418 418 $this->assertEqualSets( array( $p1, $p2, $p3 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) ); 419 419 } 420 421 /** 422 * @ticket 31355 423 */ 424 public function test_pages_dont_404_when_queried_post_id_is_modified() { 425 $post_id = $this->factory->post->create( array( 'post_title' => 'A Test Page', 'post_type' => 'page' ) ); 426 427 add_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) ); 428 429 $url = get_permalink( $post_id ); 430 $this->go_to( $url ); 431 432 remove_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) ); 433 434 $this->assertFalse( $GLOBALS['wp_query']->is_404() ); 435 $this->assertEquals( $post_id, $GLOBALS['wp_query']->post->ID ); 436 } 437 438 /** 439 * @ticket 31355 440 */ 441 public function test_custom_hierarchical_post_types_404_when_queried_post_id_is_modified() { 442 global $wp_rewrite; 443 444 register_post_type( 'guide', array( 'name' => 'Guide', 'public' => true, 'hierarchical' => true ) ); 445 $wp_rewrite->flush_rules(); 446 $post_id = $this->factory->post->create( array( 'post_title' => 'A Test Guide', 'post_type' => 'guide' ) ); 447 448 add_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) ); 449 450 $url = get_permalink( $post_id ); 451 $this->go_to( $url ); 452 453 remove_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) ); 454 455 $this->assertFalse( $GLOBALS['wp_query']->is_404() ); 456 $this->assertEquals( $post_id, $GLOBALS['wp_query']->post->ID ); 457 } 458 459 public function filter_parse_query_to_modify_queried_post_id( $query ) { 460 $post = get_queried_object(); 461 } 420 462 }
Note: See TracChangeset
for help on using the changeset viewer.