Make WordPress Core

Ticket #22074: test-get-pages-inc-exc.diff

File test-get-pages-inc-exc.diff, 921 bytes (added by wonderboymusic, 13 years ago)
  • tests/post.php

     
    520520
    521521                $this->assertEquals( 'publish', $post->post_status );
    522522        }
     523
     524        function test_get_pages_include_exclude() {
     525                $page_ids = array();
     526               
     527                foreach ( range( 1, 20 ) as $i )
     528                        $page_ids[] = $this->factory->post->create( array( 'post_type' => 'page' ) );
     529               
     530                $inc = array_slice( $page_ids, 0, 10 );
     531                sort( $inc );
     532                $exc = array_slice( $page_ids, 10 );
     533                sort( $exc );
     534               
     535                $include = get_pages( array( 'include' => $inc ) );
     536                $inc_result = wp_list_pluck( $include, 'ID' );
     537                sort( $inc_result );
     538                $this->assertEquals( $inc, $inc_result );
     539               
     540                $exclude = get_pages( array( 'exclude' => $exc ) );
     541                $exc_result = wp_list_pluck( $exclude, 'ID' );
     542                sort( $exc_result );
     543                $this->assertEquals( $inc, $exc_result );
     544        }
    523545}