Changeset 25972
- Timestamp:
- 10/28/2013 09:49:27 PM (12 years ago)
- Location:
- trunk/tests/phpunit/tests
- Files:
-
- 2 edited
-
post.php (modified) (1 diff)
-
post/getPages.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post.php
r25578 r25972 830 830 return $counts; 831 831 } 832 833 /**834 * @ticket 22074835 */836 function test_get_pages_include_exclude() {837 $page_ids = array();838 839 foreach ( range( 1, 20 ) as $i )840 $page_ids[] = $this->factory->post->create( array( 'post_type' => 'page' ) );841 842 $inc = array_slice( $page_ids, 0, 10 );843 sort( $inc );844 $exc = array_slice( $page_ids, 10 );845 sort( $exc );846 847 $include = get_pages( array( 'include' => $inc ) );848 $inc_result = wp_list_pluck( $include, 'ID' );849 sort( $inc_result );850 $this->assertEquals( $inc, $inc_result );851 852 $exclude = get_pages( array( 'exclude' => $exc ) );853 $exc_result = wp_list_pluck( $exclude, 'ID' );854 sort( $exc_result );855 $this->assertEquals( $inc, $exc_result );856 }857 858 function test_get_pages_parent() {859 $page_id1 = $this->factory->post->create( array( 'post_type' => 'page' ) );860 $page_id2 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) );861 $page_id3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id2 ) );862 $page_id4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) );863 864 $pages = get_pages( array( 'parent' => 0, 'hierarchical' => false ) );865 $this->assertEqualSets( array( $page_id1 ), wp_list_pluck( $pages, 'ID' ) );866 867 $pages = get_pages( array( 'parent' => $page_id1, 'hierarchical' => false ) );868 $this->assertEqualSets( array( $page_id2, $page_id4 ), wp_list_pluck( $pages, 'ID' ) );869 870 $pages = get_pages( array( 'parent' => array( $page_id1, $page_id2 ), 'hierarchical' => false ) );871 $this->assertEqualSets( array( $page_id2, $page_id3, $page_id4 ), wp_list_pluck( $pages, 'ID' ) );872 873 $pages = get_pages( array( 'parent' => 0 ) );874 $this->assertEqualSets( array( $page_id1 ), wp_list_pluck( $pages, 'ID' ) );875 876 $pages = get_pages( array( 'parent' => $page_id1 ) );877 $this->assertEqualSets( array( $page_id2, $page_id4 ), wp_list_pluck( $pages, 'ID' ) );878 879 $pages = get_pages( array( 'parent' => array( $page_id1, $page_id2 ) ) );880 $this->assertEqualSets( array( $page_id2, $page_id3, $page_id4 ), wp_list_pluck( $pages, 'ID' ) );881 }882 832 } -
trunk/tests/phpunit/tests/post/getPages.php
r25160 r25972 109 109 110 110 /** 111 * @ticket 22074 112 */ 113 function test_get_pages_include_exclude() { 114 $page_ids = array(); 115 116 foreach ( range( 1, 20 ) as $i ) 117 $page_ids[] = $this->factory->post->create( array( 'post_type' => 'page' ) ); 118 119 $inc = array_slice( $page_ids, 0, 10 ); 120 sort( $inc ); 121 $exc = array_slice( $page_ids, 10 ); 122 sort( $exc ); 123 124 $include = get_pages( array( 'include' => $inc ) ); 125 $inc_result = wp_list_pluck( $include, 'ID' ); 126 sort( $inc_result ); 127 $this->assertEquals( $inc, $inc_result ); 128 129 $exclude = get_pages( array( 'exclude' => $exc ) ); 130 $exc_result = wp_list_pluck( $exclude, 'ID' ); 131 sort( $exc_result ); 132 $this->assertEquals( $inc, $exc_result ); 133 } 134 135 /** 136 * @ticket 9470 137 */ 138 function test_get_pages_parent() { 139 $page_id1 = $this->factory->post->create( array( 'post_type' => 'page' ) ); 140 $page_id2 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) ); 141 $page_id3 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id2 ) ); 142 $page_id4 = $this->factory->post->create( array( 'post_type' => 'page', 'post_parent' => $page_id1 ) ); 143 144 $pages = get_pages( array( 'parent' => 0, 'hierarchical' => false ) ); 145 $this->assertEqualSets( array( $page_id1 ), wp_list_pluck( $pages, 'ID' ) ); 146 147 $pages = get_pages( array( 'parent' => $page_id1, 'hierarchical' => false ) ); 148 $this->assertEqualSets( array( $page_id2, $page_id4 ), wp_list_pluck( $pages, 'ID' ) ); 149 150 $pages = get_pages( array( 'parent' => array( $page_id1, $page_id2 ), 'hierarchical' => false ) ); 151 $this->assertEqualSets( array( $page_id2, $page_id3, $page_id4 ), wp_list_pluck( $pages, 'ID' ) ); 152 153 $pages = get_pages( array( 'parent' => 0 ) ); 154 $this->assertEqualSets( array( $page_id1 ), wp_list_pluck( $pages, 'ID' ) ); 155 156 $pages = get_pages( array( 'parent' => $page_id1 ) ); 157 $this->assertEqualSets( array( $page_id2, $page_id4 ), wp_list_pluck( $pages, 'ID' ) ); 158 159 $pages = get_pages( array( 'parent' => array( $page_id1, $page_id2 ) ) ); 160 $this->assertEqualSets( array( $page_id2, $page_id3, $page_id4 ), wp_list_pluck( $pages, 'ID' ) ); 161 } 162 163 /** 111 164 * @ticket 22389 112 165 */
Note: See TracChangeset
for help on using the changeset viewer.