Make WordPress Core

Ticket #42903: 42903.patch

File 42903.patch, 39.1 KB (added by Frank Klein, 7 years ago)
  • tests/phpunit/tests/post/listPages.php

    diff --git tests/phpunit/tests/post/listPages.php tests/phpunit/tests/post/listPages.php
    index 1261d909b1..5cbca33400 100644
     
    11<?php
    22
    33class Tests_List_Pages extends WP_UnitTestCase {
    4         var $pages;
    5 
    6         protected $time = null;
    7 
    8         /*
    9         $defaults = array(
    10                 'depth' => 0,
    11                 'show_date' => '',
    12                 'date_format' => get_option('date_format'),
    13                 'child_of' => 0,
    14                 'exclude' => '',
    15                 'title_li' => __('Pages'),
    16                 'echo' => 1,
    17                 'authors' => '',
    18                 'sort_column' => 'menu_order, post_title',
    19                 'link_before' => '',
    20                 'link_after' => '',
    21                 'walker' => '',
    22                 'item_spacing' => 'preserve',
    23                 'include'      => '',
    24                 'post_type'    => 'page',
    25                 'post_status'  => 'publish',
    26         );
    27         */
    28         function setUp() {
    29                 parent::setUp();
    30                 global $wpdb;
    31                 $wpdb->query( 'TRUNCATE ' . $wpdb->prefix . 'posts' );
    32                 $this->time = time();
    33                 $post_date  = date( 'Y-m-d H:i:s', $this->time );
    34                 $pages      = array();
    35                 self::factory()->user->create();
    36                 $pages[] = self::factory()->post->create(
     4        /**
     5         * Author user id.
     6         *
     7         * @var int
     8         */
     9        public static $author;
     10
     11        /**
     12         * Parent page id.
     13         *
     14         * @var int
     15         */
     16        public static $parent_1;
     17
     18        /**
     19         * Parent page id.
     20         *
     21         * @var int
     22         */
     23        public static $parent_2;
     24
     25        /**
     26         * Parent page id.
     27         *
     28         * @var int
     29         */
     30        public static $parent_3;
     31
     32        /**
     33         * Child page ids.
     34         *
     35         * @var array
     36         */
     37        public static $children = array();
     38
     39        /**
     40         * Current timestamp cache, so that it is consistent across posts.
     41         *
     42         * @var int
     43         */
     44        public static $time;
     45
     46        public static function wpSetupBeforeClass() {
     47                self::$time = time();
     48
     49                $post_date = date( 'Y-m-d H:i:s', self::$time );
     50
     51                self::$parent_1 = self::factory()->post->create(
    3752                        array(
    3853                                'post_type'  => 'page',
    3954                                'post_title' => 'Parent 1',
    4055                                'post_date'  => $post_date,
    4156                        )
    4257                );
    43                 $pages[] = self::factory()->post->create(
     58
     59                self::$author = self::factory()->user->create( array( 'role' => 'author' ) );
     60
     61                self::$parent_2 = self::factory()->post->create(
    4462                        array(
    4563                                'post_type'  => 'page',
    4664                                'post_title' => 'Parent 2',
    4765                                'post_date'  => $post_date,
    4866                        )
    4967                );
    50                 $pages[] = self::factory()->post->create(
     68
     69                self::$parent_3 = self::factory()->post->create(
    5170                        array(
     71                                'post_author' => self::$author,
    5272                                'post_type'   => 'page',
    5373                                'post_title'  => 'Parent 3',
    54                                 'post_author' => '2',
    5574                                'post_date'   => $post_date,
    5675                        )
    5776                );
    5877
    59                 foreach ( $pages as $page ) {
    60                         $this->pages[ $page ] = self::factory()->post->create(
     78                foreach ( array( self::$parent_1, self::$parent_2, self::$parent_3 ) as $page ) {
     79                        self::$children[ $page ][] = self::factory()->post->create(
    6180                                array(
    6281                                        'post_parent' => $page,
    6382                                        'post_type'   => 'page',
    class Tests_List_Pages extends WP_UnitTestCase { 
    6584                                        'post_date'   => $post_date,
    6685                                )
    6786                        );
    68                         $this->pages[ $page ] = self::factory()->post->create(
     87                        self::$children[ $page ][] = self::factory()->post->create(
    6988                                array(
    7089                                        'post_parent' => $page,
    7190                                        'post_type'   => 'page',
    class Tests_List_Pages extends WP_UnitTestCase { 
    7392                                        'post_date'   => $post_date,
    7493                                )
    7594                        );
    76                         $this->pages[ $page ] = self::factory()->post->create(
     95                        self::$children[ $page ][] = self::factory()->post->create(
    7796                                array(
    7897                                        'post_parent' => $page,
    7998                                        'post_type'   => 'page',
    class Tests_List_Pages extends WP_UnitTestCase { 
    85104        }
    86105
    87106        function test_wp_list_pages_default() {
    88                 $args                = array(
     107                $args = array(
    89108                        'echo' => false,
    90109                );
    91                 $expected['default'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a>
     110
     111                $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a>
    92112<ul class=\'children\'>
    93         <li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1</a></li>
    94         <li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">Child 2</a></li>
    95         <li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">Child 3</a></li>
     113        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][0] ) . '">Child 1</a></li>
     114        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][1] ) . '">Child 2</a></li>
     115        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][2] ) . '">Child 3</a></li>
    96116</ul>
    97117</li>
    98 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a>
     118<li class="page_item page-item-' . self::$parent_2 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_2 ) . '">Parent 2</a>
    99119<ul class=\'children\'>
    100         <li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">Child 1</a></li>
    101         <li class="page_item page-item-8"><a href="' . get_permalink( 8 ) . '">Child 2</a></li>
    102         <li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">Child 3</a></li>
     120        <li class="page_item page-item-' . self::$children[ self::$parent_2 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][0] ) . '">Child 1</a></li>
     121        <li class="page_item page-item-' . self::$children[ self::$parent_2 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][1] ) . '">Child 2</a></li>
     122        <li class="page_item page-item-' . self::$children[ self::$parent_2 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][2] ) . '">Child 3</a></li>
    103123</ul>
    104124</li>
    105 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a>
     125<li class="page_item page-item-' . self::$parent_3 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a>
    106126<ul class=\'children\'>
    107         <li class="page_item page-item-10"><a href="' . get_permalink( 10 ) . '">Child 1</a></li>
    108         <li class="page_item page-item-11"><a href="' . get_permalink( 11 ) . '">Child 2</a></li>
    109         <li class="page_item page-item-12"><a href="' . get_permalink( 12 ) . '">Child 3</a></li>
     127        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][0] ) . '">Child 1</a></li>
     128        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][1] ) . '">Child 2</a></li>
     129        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][2] ) . '">Child 3</a></li>
    110130</ul>
    111131</li>
    112132</ul></li>';
    113                 $actual              = wp_list_pages( $args );
    114                 $this->AssertEquals( $expected['default'], $actual );
     133
     134                $this->AssertEquals( $expected, wp_list_pages( $args ) );
    115135        }
    116136
    117137        function test_wp_list_pages_depth() {
    118                 $args              = array(
     138                $args = array(
    119139                        'echo'  => false,
    120140                        'depth' => 1,
    121141                );
    122                 $expected['depth'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a></li>
    123 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a></li>
    124 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a></li>
     142
     143                $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a></li>
     144<li class="page_item page-item-' . self::$parent_2 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_2 ) . '">Parent 2</a></li>
     145<li class="page_item page-item-' . self::$parent_3 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a></li>
    125146</ul></li>';
    126                 $actual            = wp_list_pages( $args );
    127                 $this->AssertEquals( $expected['depth'], $actual );
     147
     148                $this->AssertEquals( $expected, wp_list_pages( $args ) );
    128149        }
    129150
    130151        function test_wp_list_pages_show_date() {
    131                 $args                  = array(
     152                $args = array(
    132153                        'echo'      => false,
    133154                        'depth'     => 1,
    134155                        'show_date' => true,
    135156                );
    136                 $date                  = date( get_option( 'date_format' ), $this->time );
    137                 $expected['show_date'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a> ' . $date . '</li>
    138 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a> ' . $date . '</li>
    139 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a> ' . $date . '</li>
     157                $date = date( get_option( 'date_format' ), self::$time );
     158
     159                $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a> ' . $date . '</li>
     160<li class="page_item page-item-' . self::$parent_2 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_2 ) . '">Parent 2</a> ' . $date . '</li>
     161<li class="page_item page-item-' . self::$parent_3 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a> ' . $date . '</li>
    140162</ul></li>';
    141                 $actual                = wp_list_pages( $args );
    142                 $this->AssertEquals( $expected['show_date'], $actual );
     163
     164                $this->AssertEquals( $expected, wp_list_pages( $args ) );
    143165        }
    144166
    145167        function test_wp_list_pages_date_format() {
    146                 $args                    = array(
     168                $args = array(
    147169                        'echo'        => false,
    148170                        'show_date'   => true,
    149171                        'date_format' => 'l, F j, Y',
    150172                );
    151                 $date                    = date( $args['date_format'], $this->time );
    152                 $expected['date_format'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a> ' . $date . '
     173                $date = date( $args['date_format'], self::$time );
     174
     175                $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a> ' . $date . '
    153176<ul class=\'children\'>
    154         <li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1</a> ' . $date . '</li>
    155         <li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">Child 2</a> ' . $date . '</li>
    156         <li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">Child 3</a> ' . $date . '</li>
     177        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][0] ) . '">Child 1</a> ' . $date . '</li>
     178        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][1] ) . '">Child 2</a> ' . $date . '</li>
     179        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][2] ) . '">Child 3</a> ' . $date . '</li>
    157180</ul>
    158181</li>
    159 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a> ' . $date . '
     182<li class="page_item page-item-' . self::$parent_2 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_2 ) . '">Parent 2</a> ' . $date . '
    160183<ul class=\'children\'>
    161         <li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">Child 1</a> ' . $date . '</li>
    162         <li class="page_item page-item-8"><a href="' . get_permalink( 8 ) . '">Child 2</a> ' . $date . '</li>
    163         <li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">Child 3</a> ' . $date . '</li>
     184        <li class="page_item page-item-' . self::$children[ self::$parent_2 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][0] ) . '">Child 1</a> ' . $date . '</li>
     185        <li class="page_item page-item-' . self::$children[ self::$parent_2 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][1] ) . '">Child 2</a> ' . $date . '</li>
     186        <li class="page_item page-item-' . self::$children[ self::$parent_2 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][2] ) . '">Child 3</a> ' . $date . '</li>
    164187</ul>
    165188</li>
    166 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a> ' . $date . '
     189<li class="page_item page-item-' . self::$parent_3 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a> ' . $date . '
    167190<ul class=\'children\'>
    168         <li class="page_item page-item-10"><a href="' . get_permalink( 10 ) . '">Child 1</a> ' . $date . '</li>
    169         <li class="page_item page-item-11"><a href="' . get_permalink( 11 ) . '">Child 2</a> ' . $date . '</li>
    170         <li class="page_item page-item-12"><a href="' . get_permalink( 12 ) . '">Child 3</a> ' . $date . '</li>
     191        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][0] ) . '">Child 1</a> ' . $date . '</li>
     192        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][1] ) . '">Child 2</a> ' . $date . '</li>
     193        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][2] ) . '">Child 3</a> ' . $date . '</li>
    171194</ul>
    172195</li>
    173196</ul></li>';
    174                 $actual                  = wp_list_pages( $args );
    175                 $this->AssertEquals( $expected['date_format'], $actual );
     197
     198                $this->AssertEquals( $expected, wp_list_pages( $args ) );
    176199        }
    177200
    178201        function test_wp_list_pages_child_of() {
    179                 $args                 = array(
     202                $args = array(
    180203                        'echo'     => false,
    181                         'child_of' => 2,
     204                        'child_of' => self::$parent_2,
    182205                );
    183                 $expected['child_of'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">Child 1</a></li>
    184 <li class="page_item page-item-8"><a href="' . get_permalink( 8 ) . '">Child 2</a></li>
    185 <li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">Child 3</a></li>
     206
     207                $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$children[ self::$parent_2 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][0] ) . '">Child 1</a></li>
     208<li class="page_item page-item-' . self::$children[ self::$parent_2 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][1] ) . '">Child 2</a></li>
     209<li class="page_item page-item-' . self::$children[ self::$parent_2 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][2] ) . '">Child 3</a></li>
    186210</ul></li>';
    187                 $actual               = wp_list_pages( $args );
    188                 $this->AssertEquals( $expected['child_of'], $actual );
     211
     212                $this->AssertEquals( $expected, wp_list_pages( $args ) );
    189213        }
    190214
    191215        function test_wp_list_pages_exclude() {
    192                 $args                = array(
     216                $args = array(
    193217                        'echo'    => false,
    194                         'exclude' => '2, 2',
     218                        'exclude' => self::$parent_2,
    195219                );
    196                 $expected['exclude'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a>
     220
     221                $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a>
    197222<ul class=\'children\'>
    198         <li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1</a></li>
    199         <li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">Child 2</a></li>
    200         <li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">Child 3</a></li>
     223        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][0] ) . '">Child 1</a></li>
     224        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][1] ) . '">Child 2</a></li>
     225        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][2] ) . '">Child 3</a></li>
    201226</ul>
    202227</li>
    203 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a>
     228<li class="page_item page-item-' . self::$parent_3 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a>
    204229<ul class=\'children\'>
    205         <li class="page_item page-item-10"><a href="' . get_permalink( 10 ) . '">Child 1</a></li>
    206         <li class="page_item page-item-11"><a href="' . get_permalink( 11 ) . '">Child 2</a></li>
    207         <li class="page_item page-item-12"><a href="' . get_permalink( 12 ) . '">Child 3</a></li>
     230        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][0] ) . '">Child 1</a></li>
     231        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][1] ) . '">Child 2</a></li>
     232        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][2] ) . '">Child 3</a></li>
    208233</ul>
    209234</li>
    210 <li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">Child 1</a></li>
    211 <li class="page_item page-item-8"><a href="' . get_permalink( 8 ) . '">Child 2</a></li>
    212 <li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">Child 3</a></li>
     235<li class="page_item page-item-' . self::$children[ self::$parent_2 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][0] ) . '">Child 1</a></li>
     236<li class="page_item page-item-' . self::$children[ self::$parent_2 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][1] ) . '">Child 2</a></li>
     237<li class="page_item page-item-' . self::$children[ self::$parent_2 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][2] ) . '">Child 3</a></li>
    213238</ul></li>';
    214                 $actual              = wp_list_pages( $args );
    215                 $this->AssertEquals( $expected['exclude'], $actual );
     239
     240                $this->AssertEquals( $expected, wp_list_pages( $args ) );
    216241        }
    217242
    218243        function test_wp_list_pages_title_li() {
    219                 $args                 = array(
     244                $args = array(
    220245                        'echo'     => false,
    221246                        'depth'    => 1,
    222247                        'title_li' => 'PageTitle',
    223248                );
    224                 $expected['title_li'] = '<li class="pagenav">PageTitle<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a></li>
    225 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a></li>
    226 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a></li>
     249
     250                $expected = '<li class="pagenav">PageTitle<ul><li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a></li>
     251<li class="page_item page-item-' . self::$parent_2 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_2 ) . '">Parent 2</a></li>
     252<li class="page_item page-item-' . self::$parent_3 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a></li>
    227253</ul></li>';
    228                 $actual               = wp_list_pages( $args );
    229                 $this->AssertEquals( $expected['title_li'], $actual );
     254
     255                $this->AssertEquals( $expected, wp_list_pages( $args ) );
    230256        }
    231257
    232258        function test_wp_list_pages_echo() {
    233                 $args             = array(
     259                $args = array(
    234260                        'echo'  => true,
    235261                        'depth' => 1,
    236262                );
    237                 $expected['echo'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a></li>
    238 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a></li>
    239 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a></li>
     263
     264                $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a></li>
     265<li class="page_item page-item-' . self::$parent_2 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_2 ) . '">Parent 2</a></li>
     266<li class="page_item page-item-' . self::$parent_3 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a></li>
    240267</ul></li>';
    241                 $this->expectOutputString( $expected['echo'] );
     268                $this->expectOutputString( $expected );
    242269                wp_list_pages( $args );
    243270        }
    244271
    245272        function test_wp_list_pages_authors() {
    246                 $args                = array(
     273                $args = array(
    247274                        'echo'    => false,
    248                         'authors' => '2',
     275                        'authors' => self::$author,
    249276                );
    250                 $expected['authors'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-3"><a href="' . get_permalink( 3 ) . '">Parent 3</a></li>
     277
     278                $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_3 . '"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a></li>
    251279</ul></li>';
    252                 $actual              = wp_list_pages( $args );
    253                 $this->AssertEquals( $expected['authors'], $actual );
     280
     281                $this->AssertEquals( $expected, wp_list_pages( $args ) );
    254282        }
    255283
    256284        function test_wp_list_pages_number() {
    257                 $args               = array(
     285                $args = array(
    258286                        'echo'   => false,
    259287                        'number' => 1,
    260288                );
    261                 $expected['number'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1</a></li>
     289
     290                $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$children[ self::$parent_1 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][0] ) . '">Child 1</a></li>
    262291</ul></li>';
    263                 $actual             = wp_list_pages( $args );
    264                 $this->AssertEquals( $expected['number'], $actual );
     292
     293                $this->AssertEquals( $expected, wp_list_pages( $args ) );
    265294        }
    266295
    267296        function test_wp_list_pages_sort_column() {
    268                 $args                    = array(
     297                $args = array(
    269298                        'echo'        => false,
    270299                        'sort_column' => 'post_author',
    271300                        'sort_order'  => 'DESC',
    272301                );
    273                 $expected['sort_column'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a>
     302
     303                $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_3 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a>
    274304<ul class=\'children\'>
    275         <li class="page_item page-item-10"><a href="' . get_permalink( 10 ) . '">Child 1</a></li>
    276         <li class="page_item page-item-11"><a href="' . get_permalink( 11 ) . '">Child 2</a></li>
    277         <li class="page_item page-item-12"><a href="' . get_permalink( 12 ) . '">Child 3</a></li>
     305        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][0] ) . '">Child 1</a></li>
     306        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][1] ) . '">Child 2</a></li>
     307        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][2] ) . '">Child 3</a></li>
    278308</ul>
    279309</li>
    280 <li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a>
     310<li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a>
    281311<ul class=\'children\'>
    282         <li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1</a></li>
    283         <li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">Child 2</a></li>
    284         <li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">Child 3</a></li>
     312        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][0] ) . '">Child 1</a></li>
     313        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][1] ) . '">Child 2</a></li>
     314        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][2] ) . '">Child 3</a></li>
    285315</ul>
    286316</li>
    287 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a>
     317<li class="page_item page-item-' . self::$parent_2 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_2 ) . '">Parent 2</a>
    288318<ul class=\'children\'>
    289         <li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">Child 1</a></li>
    290         <li class="page_item page-item-8"><a href="' . get_permalink( 8 ) . '">Child 2</a></li>
    291         <li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">Child 3</a></li>
     319        <li class="page_item page-item-' . self::$children[ self::$parent_2 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][0] ) . '">Child 1</a></li>
     320        <li class="page_item page-item-' . self::$children[ self::$parent_2 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][1] ) . '">Child 2</a></li>
     321        <li class="page_item page-item-' . self::$children[ self::$parent_2 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][2] ) . '">Child 3</a></li>
    292322</ul>
    293323</li>
    294324</ul></li>';
    295                 $actual                  = wp_list_pages( $args );
    296                 $this->AssertEquals( $expected['sort_column'], $actual );
     325
     326                $this->AssertEquals( $expected, wp_list_pages( $args ) );
    297327        }
    298328
    299329        function test_wp_list_pages_link_before() {
    300                 $args                    = array(
     330                $args = array(
    301331                        'echo'        => false,
    302332                        'link_before' => 'BEFORE',
    303333                );
    304                 $expected['link_before'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">BEFOREParent 1</a>
     334
     335                $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">BEFOREParent 1</a>
    305336<ul class=\'children\'>
    306         <li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">BEFOREChild 1</a></li>
    307         <li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">BEFOREChild 2</a></li>
    308         <li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">BEFOREChild 3</a></li>
     337        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][0] ) . '">BEFOREChild 1</a></li>
     338        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][1] ) . '">BEFOREChild 2</a></li>
     339        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][2] ) . '">BEFOREChild 3</a></li>
    309340</ul>
    310341</li>
    311 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">BEFOREParent 2</a>
     342<li class="page_item page-item-' . self::$parent_2 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_2 ) . '">BEFOREParent 2</a>
    312343<ul class=\'children\'>
    313         <li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">BEFOREChild 1</a></li>
    314         <li class="page_item page-item-8"><a href="' . get_permalink( 8 ) . '">BEFOREChild 2</a></li>
    315         <li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">BEFOREChild 3</a></li>
     344        <li class="page_item page-item-' . self::$children[ self::$parent_2 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][0] ) . '">BEFOREChild 1</a></li>
     345        <li class="page_item page-item-' . self::$children[ self::$parent_2 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][1] ) . '">BEFOREChild 2</a></li>
     346        <li class="page_item page-item-' . self::$children[ self::$parent_2 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][2] ) . '">BEFOREChild 3</a></li>
    316347</ul>
    317348</li>
    318 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">BEFOREParent 3</a>
     349<li class="page_item page-item-' . self::$parent_3 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_3 ) . '">BEFOREParent 3</a>
    319350<ul class=\'children\'>
    320         <li class="page_item page-item-10"><a href="' . get_permalink( 10 ) . '">BEFOREChild 1</a></li>
    321         <li class="page_item page-item-11"><a href="' . get_permalink( 11 ) . '">BEFOREChild 2</a></li>
    322         <li class="page_item page-item-12"><a href="' . get_permalink( 12 ) . '">BEFOREChild 3</a></li>
     351        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][0] ) . '">BEFOREChild 1</a></li>
     352        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][1] ) . '">BEFOREChild 2</a></li>
     353        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][2] ) . '">BEFOREChild 3</a></li>
    323354</ul>
    324355</li>
    325356</ul></li>';
    326                 $actual                  = wp_list_pages( $args );
    327                 $this->AssertEquals( $expected['link_before'], $actual );
     357
     358                $this->AssertEquals( $expected, wp_list_pages( $args ) );
    328359        }
    329360
    330361        function test_wp_list_pages_link_after() {
    331                 $args                   = array(
     362                $args = array(
    332363                        'echo'       => false,
    333364                        'link_after' => 'AFTER',
    334365                );
    335                 $expected['link_after'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1AFTER</a>
     366
     367                $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1AFTER</a>
    336368<ul class=\'children\'>
    337         <li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1AFTER</a></li>
    338         <li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">Child 2AFTER</a></li>
    339         <li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">Child 3AFTER</a></li>
     369        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][0] ) . '">Child 1AFTER</a></li>
     370        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][1] ) . '">Child 2AFTER</a></li>
     371        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][2] ) . '">Child 3AFTER</a></li>
    340372</ul>
    341373</li>
    342 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2AFTER</a>
     374<li class="page_item page-item-' . self::$parent_2 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_2 ) . '">Parent 2AFTER</a>
    343375<ul class=\'children\'>
    344         <li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">Child 1AFTER</a></li>
    345         <li class="page_item page-item-8"><a href="' . get_permalink( 8 ) . '">Child 2AFTER</a></li>
    346         <li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">Child 3AFTER</a></li>
     376        <li class="page_item page-item-' . self::$children[ self::$parent_2 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][0] ) . '">Child 1AFTER</a></li>
     377        <li class="page_item page-item-' . self::$children[ self::$parent_2 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][1] ) . '">Child 2AFTER</a></li>
     378        <li class="page_item page-item-' . self::$children[ self::$parent_2 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][2] ) . '">Child 3AFTER</a></li>
    347379</ul>
    348380</li>
    349 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3AFTER</a>
     381<li class="page_item page-item-' . self::$parent_3 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3AFTER</a>
    350382<ul class=\'children\'>
    351         <li class="page_item page-item-10"><a href="' . get_permalink( 10 ) . '">Child 1AFTER</a></li>
    352         <li class="page_item page-item-11"><a href="' . get_permalink( 11 ) . '">Child 2AFTER</a></li>
    353         <li class="page_item page-item-12"><a href="' . get_permalink( 12 ) . '">Child 3AFTER</a></li>
     383        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][0] ) . '">Child 1AFTER</a></li>
     384        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][1] ) . '">Child 2AFTER</a></li>
     385        <li class="page_item page-item-' . self::$children[ self::$parent_3 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][2] ) . '">Child 3AFTER</a></li>
    354386</ul>
    355387</li>
    356388</ul></li>';
    357                 $actual                 = wp_list_pages( $args );
    358                 $this->AssertEquals( $expected['link_after'], $actual );
     389
     390                $this->AssertEquals( $expected, wp_list_pages( $args ) );
    359391        }
    360392
    361393
    362394        function test_wp_list_pages_include() {
    363                 $args                = array(
     395                $args = array(
    364396                        'echo'    => false,
    365                         'include' => '1,3',
     397                        'include' => self::$parent_1 . ',' . self::$parent_3,
    366398                );
    367                 $expected['include'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1"><a href="' . get_permalink( 1 ) . '">Parent 1</a></li>
    368 <li class="page_item page-item-3"><a href="' . get_permalink( 3 ) . '">Parent 3</a></li>
     399
     400                $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . '"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a></li>
     401<li class="page_item page-item-' . self::$parent_3 . '"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a></li>
    369402</ul></li>';
    370                 $actual              = wp_list_pages( $args );
    371                 $this->AssertEquals( $expected['include'], $actual );
     403
     404                $this->AssertEquals( $expected, wp_list_pages( $args ) );
    372405        }
    373406
    374407        function test_wp_list_pages_exclude_tree() {
    375                 $args                = array(
     408                $args = array(
    376409                        'echo'         => false,
    377                         'exclude_tree' => '2, 3',
     410                        'exclude_tree' => self::$parent_2 . ',' . self::$parent_3,
    378411                );
    379                 $expected['exclude'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a>
     412
     413                $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a>
    380414<ul class=\'children\'>
    381         <li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1</a></li>
    382         <li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">Child 2</a></li>
    383         <li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">Child 3</a></li>
     415        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][0] ) . '">Child 1</a></li>
     416        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][1] ) . '">Child 2</a></li>
     417        <li class="page_item page-item-' . self::$children[ self::$parent_1 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][2] ) . '">Child 3</a></li>
    384418</ul>
    385419</li>
    386420</ul></li>';
    387                 $actual              = wp_list_pages( $args );
    388                 $this->AssertEquals( $expected['exclude'], $actual );
     421
     422                $this->AssertEquals( $expected, wp_list_pages( $args ) );
    389423        }
    390424
    391425        function test_wp_list_pages_discarded_whitespace() {
    392                 $args                = array(
     426                $args = array(
    393427                        'echo'         => false,
    394428                        'item_spacing' => 'discard',
    395429                );
    396                 $expected['default'] = '<li class="pagenav">Pages<ul><li class="page_item page-item-1 page_item_has_children"><a href="' . get_permalink( 1 ) . '">Parent 1</a><ul class=\'children\'><li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1</a></li><li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">Child 2</a></li><li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">Child 3</a></li></ul></li><li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a><ul class=\'children\'><li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">Child 1</a></li><li class="page_item page-item-8"><a href="' . get_permalink( 8 ) . '">Child 2</a></li><li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">Child 3</a></li></ul></li><li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a><ul class=\'children\'><li class="page_item page-item-10"><a href="' . get_permalink( 10 ) . '">Child 1</a></li><li class="page_item page-item-11"><a href="' . get_permalink( 11 ) . '">Child 2</a></li><li class="page_item page-item-12"><a href="' . get_permalink( 12 ) . '">Child 3</a></li></ul></li></ul></li>';
    397                 $actual              = wp_list_pages( $args );
    398                 $this->AssertEquals( $expected['default'], $actual );
     430
     431                $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a><ul class=\'children\'><li class="page_item page-item-' . self::$children[ self::$parent_1 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][0] ) . '">Child 1</a></li><li class="page_item page-item-' . self::$children[ self::$parent_1 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][1] ) . '">Child 2</a></li><li class="page_item page-item-' . self::$children[ self::$parent_1 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_1 ][2] ) . '">Child 3</a></li></ul></li><li class="page_item page-item-' . self::$parent_2 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_2 ) . '">Parent 2</a><ul class=\'children\'><li class="page_item page-item-' . self::$children[ self::$parent_2 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][0] ) . '">Child 1</a></li><li class="page_item page-item-' . self::$children[ self::$parent_2 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][1] ) . '">Child 2</a></li><li class="page_item page-item-' . self::$children[ self::$parent_2 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][2] ) . '">Child 3</a></li></ul></li><li class="page_item page-item-' . self::$parent_3 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a><ul class=\'children\'><li class="page_item page-item-' . self::$children[ self::$parent_3 ][0] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][0] ) . '">Child 1</a></li><li class="page_item page-item-' . self::$children[ self::$parent_3 ][1] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][1] ) . '">Child 2</a></li><li class="page_item page-item-' . self::$children[ self::$parent_3 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_3 ][2] ) . '">Child 3</a></li></ul></li></ul></li>';
     432
     433                $this->AssertEquals( $expected, wp_list_pages( $args ) );
    399434        }
    400435}