0,
'show_date' => '',
'date_format' => get_option('date_format'),
'child_of' => 0,
'exclude' => '',
'title_li' => __('Pages'),
'echo' => 1,
'authors' => '',
'sort_column' => 'menu_order, post_title',
'link_before' => '',
'link_after' => '',
'walker' => '',
'include' => '',
'post_type' => 'page',
'post_status' => 'publish',
);
*/
function setUp() {
parent::setUp();
global $wpdb;
$wpdb->query( 'TRUNCATE ' . $wpdb->prefix . 'posts' );
$pages = array();
$this->factory->user->create();
$pages[] = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 1' ) );
$pages[] = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 2' ) );
$pages[] = $this->factory->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 3', 'post_author' => '2' ) );
foreach ( $pages as $page ) {
$this->pages[$page] = $this->factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 1' ) );
$this->pages[$page] = $this->factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 2' ) );
$this->pages[$page] = $this->factory->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 3' ) );
}
}
function test_wp_list_pages_default() {
$args = array(
'echo' => false
);
$expected['default'] = '
Pages';
$actual = wp_list_pages( $args );
$this->AssertEquals( $expected['default'], $actual );
}
function test_wp_list_pages_depth() {
$args = array(
'echo' => false,
'depth' => 1
);
$expected['depth'] = 'Pages';
$actual = wp_list_pages( $args );
$this->AssertEquals( $expected['depth'], $actual );
}
function test_wp_list_pages_show_date() {
$args = array(
'echo' => false,
'depth' => 1,
'show_date' => true
);
$expected['show_date'] = 'Pages';
$actual = wp_list_pages( $args );
$this->AssertEquals( $expected['show_date'], $actual );
}
function test_wp_list_pages_date_format() {
$args = array(
'echo' => false,
'show_date' => true,
'date_format' => 'l, F j, Y'
);
$expected['date_format'] = 'Pages- Parent 1 ' . date( 'l, F j, Y' ) . '
- Child 1 ' . date( 'l, F j, Y' ) . '
- Child 2 ' . date( 'l, F j, Y' ) . '
- Child 3 ' . date( 'l, F j, Y' ) . '
- Parent 2 ' . date( 'l, F j, Y' ) . '
- Child 1 ' . date( 'l, F j, Y' ) . '
- Child 2 ' . date( 'l, F j, Y' ) . '
- Child 3 ' . date( 'l, F j, Y' ) . '
- Parent 3 ' . date( 'l, F j, Y' ) . '
- Child 1 ' . date( 'l, F j, Y' ) . '
- Child 2 ' . date( 'l, F j, Y' ) . '
- Child 3 ' . date( 'l, F j, Y' ) . '
';
$actual = wp_list_pages( $args );
$this->AssertEquals( $expected['date_format'], $actual );
}
function test_wp_list_pages_child_of() {
$args = array(
'echo' => false,
'child_of' => 2
);
$expected['child_of'] = 'Pages';
$actual = wp_list_pages( $args );
$this->AssertEquals( $expected['child_of'], $actual );
}
function test_wp_list_pages_exclude() {
$args = array(
'echo' => false,
'exclude' => '2, 2'
);
$expected['exclude'] = 'Pages';
$actual = wp_list_pages( $args );
$this->AssertEquals( $expected['exclude'], $actual );
}
function test_wp_list_pages_title_li() {
$args = array(
'echo' => false,
'depth' => 1,
'title_li' => 'PageTitle'
);
$expected['title_li'] = 'PageTitle';
$actual = wp_list_pages( $args );
$this->AssertEquals( $expected['title_li'], $actual );
}
function test_wp_list_pages_echo() {
$args = array(
'echo' => true,
'depth' => 1
);
$expected['echo'] = 'Pages';
ob_start();
wp_list_pages( $args );
$actual = ob_get_clean();
$this->AssertEquals( $expected['echo'], $actual );
}
function test_wp_list_pages_authors() {
$args = array(
'echo' => false,
'authors' => '2',
);
$expected['authors'] = 'Pages';
$actual = wp_list_pages( $args );
$this->AssertEquals( $expected['authors'], $actual );
}
function test_wp_list_pages_number() {
$args = array(
'echo' => false,
'number' => 1,
);
$expected['number'] = 'Pages';
$actual = wp_list_pages( $args );
$this->AssertEquals( $expected['number'], $actual );
}
function test_wp_list_pages_sort_column() {
$args = array(
'echo' => false,
'sort_column' => 'post_author',
'sort_order' => 'DESC'
);
$expected['sort_column'] = 'Pages';
$actual = wp_list_pages( $args );
$this->AssertEquals( $expected['sort_column'], $actual );
}
function test_wp_list_pages_link_before() {
$args = array(
'echo' => false,
'link_before' => 'BEFORE'
);
$expected['link_before'] = 'Pages';
$actual = wp_list_pages( $args );
$this->AssertEquals( $expected['link_before'], $actual );
}
function test_wp_list_pages_link_after() {
$args = array(
'echo' => false,
'link_after' => 'AFTER'
);
$expected['link_after'] = 'Pages';
$actual = wp_list_pages( $args );
$this->AssertEquals( $expected['link_after'], $actual );
}
function test_wp_list_pages_include() {
$args = array(
'echo' => false,
'include' => '1,3'
);
$expected['include'] = 'Pages';
$actual = wp_list_pages( $args );
$this->AssertEquals( $expected['include'], $actual );
}
function test_wp_list_pages_exclude_tree() {
$args = array(
'echo' => false,
'exclude_tree' => '2, 3'
);
$expected['exclude'] = 'Pages';
$actual = wp_list_pages( $args );
$this->AssertEquals( $expected['exclude'], $actual );
}
/**
* @ticket 27326
*/
function test_wp_list_page_combo_exclude_depth() {
$args = array(
'echo' => false,
'exclude' => '3',
'depth' => 3
);
$expected['exclude_depth'] = 'Pages';
$actual = wp_list_pages( $args );
$this->AssertEquals( $expected['exclude_depth'], $actual );
}
}