Changeset 29039 for trunk/tests/phpunit/tests/query/conditionals.php
- Timestamp:
- 07/09/2014 04:03:17 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/query/conditionals.php
r28966 r29039 693 693 } 694 694 695 /** 696 * @ticket 16802 697 */ 698 function test_is_single_with_parent() { 699 // Use custom hierarchical post type 700 $post_type = 'test_hierarchical'; 701 702 register_post_type( $post_type, array( 703 'hierarchical' => true, 704 'rewrite' => true, 705 'has_archive' => true, 706 'public' => true 707 ) ); 708 709 // Create parent and child posts 710 $parent_id = $this->factory->post->create( array( 711 'post_type' => $post_type, 712 'post_name' => 'foo' 713 ) ); 714 715 $post_id = $this->factory->post->create( array( 716 'post_type' => $post_type, 717 'post_name' => 'bar', 718 'post_parent' => $parent_id 719 ) ); 720 721 // Tests 722 $this->go_to( "/?p=$post_id&post_type=$post_type" ); 723 724 $post = get_queried_object(); 725 $q = $GLOBALS['wp_query']; 726 727 $this->assertTrue( is_single() ); 728 $this->assertFalse( $q->is_page ); 729 $this->assertTrue( $q->is_single ); 730 $this->assertFalse( $q->is_attachment ); 731 $this->assertTrue( is_single( $post ) ); 732 $this->assertTrue( is_single( $post->ID ) ); 733 $this->assertTrue( is_single( $post->post_title ) ); 734 $this->assertTrue( is_single( $post->post_name ) ); 735 $this->assertTrue( is_single( 'foo/bar' ) ); 736 $this->assertFalse( is_single( $parent_id ) ); 737 $this->assertFalse( is_single( 'foo/bar/baz' ) ); 738 $this->assertFalse( is_single( 'bar/bar' ) ); 739 $this->assertFalse( is_single( 'foo' ) ); 740 } 741 695 742 function test_is_page() { 696 743 $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); … … 708 755 $this->assertTrue( is_page( $post->post_title ) ); 709 756 $this->assertTrue( is_page( $post->post_name ) ); 757 } 758 759 /** 760 * @ticket 16802 761 */ 762 function test_is_page_with_parent() { 763 $parent_id = $this->factory->post->create( array( 764 'post_type' => 'page', 765 'post_name' => 'foo', 766 ) ); 767 $post_id = $this->factory->post->create( array( 768 'post_type' => 'page', 769 'post_name' => 'bar', 770 'post_parent' => $parent_id, 771 ) ); 772 $this->go_to( "/?page_id=$post_id" ); 773 774 $post = get_queried_object(); 775 $q = $GLOBALS['wp_query']; 776 777 $this->assertTrue( is_page() ); 778 $this->assertFalse( $q->is_single ); 779 $this->assertTrue( $q->is_page ); 780 $this->assertFalse( $q->is_attachment ); 781 $this->assertTrue( is_page( $post ) ); 782 $this->assertTrue( is_page( $post->ID ) ); 783 $this->assertTrue( is_page( $post->post_title ) ); 784 $this->assertTrue( is_page( $post->post_name ) ); 785 $this->assertTrue( is_page( 'foo/bar' ) ); 786 $this->assertFalse( is_page( $parent_id ) ); 787 $this->assertFalse( is_page( 'foo/bar/baz' ) ); 788 $this->assertFalse( is_page( 'bar/bar' ) ); 789 $this->assertFalse( is_page( 'foo' ) ); 710 790 } 711 791
Note: See TracChangeset
for help on using the changeset viewer.