WordPress.org

Make WordPress Core

Changeset 48280


Ignore:
Timestamp:
07/02/2020 06:21:43 PM (16 months ago)
Author:
SergeyBiryukov
Message:

Tests: Further fix some issues with indeterminate sort ordering in Tests_List_Pages:

  • Make sure test_wp_list_pages_number() sorts by ID, as there are several pages with the same title.
  • Limit test_wp_list_pages_sort_column() to one level, as the child page fixtures don't have an author and cannot be reliably sorted by post_author.

Follow-up to [48157].

Props afercia.
See #50466.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/listPages.php

    r48200 r48280  
    297297    function test_wp_list_pages_number() {
    298298        $args = array(
    299             'echo'   => false,
    300             'number' => 1,
    301         );
    302 
    303         $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>
     299            'echo'        => false,
     300            'number'      => 1,
     301            'sort_column' => 'ID',
     302        );
     303
     304        $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>
    304305</ul></li>';
    305306
     
    310311        $args = array(
    311312            'echo'        => false,
     313            'depth'       => 1,
    312314            'sort_column' => 'post_author',
    313315            'sort_order'  => 'DESC',
    314316        );
    315317
    316         $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>
    317 <ul class=\'children\'>
    318     <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>
    319     <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>
    320     <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>
    321 </ul>
    322 </li>
    323 <li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a>
    324 <ul class=\'children\'>
    325     <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>
    326     <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>
    327     <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>
    328 </ul>
    329 </li>
    330 <li class="page_item page-item-' . self::$parent_2 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_2 ) . '">Parent 2</a>
    331 <ul class=\'children\'>
    332     <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>
    333     <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>
    334     <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>
    335 </ul>
    336 </li>
     318        $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></li>
     319<li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a></li>
     320<li class="page_item page-item-' . self::$parent_2 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_2 ) . '">Parent 2</a></li>
    337321</ul></li>';
    338322
Note: See TracChangeset for help on using the changeset viewer.