Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#50466 closed defect (bug) (fixed)

Random PHP test failures, take 2

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.5 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords:
Focuses: Cc:

Description

Background: #48145

After [48155], there is a test failure on Travis that appears to be unrelated to the commit:

1) Tests_List_Pages::test_wp_list_pages_sort_column
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 	<li class="page_item page-item-1802"><a href="http://example.org/?page_id=1802">Child 3</a></li>\n
 </ul>\n
 </li>\n
+<li class="page_item page-item-1792 page_item_has_children"><a href="http://example.org/?page_id=1792">Parent 2</a>\n
+<ul class='children'>\n
+	<li class="page_item page-item-1797"><a href="http://example.org/?page_id=1797">Child 1</a></li>\n
+	<li class="page_item page-item-1798"><a href="http://example.org/?page_id=1798">Child 2</a></li>\n
+	<li class="page_item page-item-1799"><a href="http://example.org/?page_id=1799">Child 3</a></li>\n
+</ul>\n
+</li>\n
 <li class="page_item page-item-1791 page_item_has_children"><a href="http://example.org/?page_id=1791">Parent 1</a>\n
 <ul class='children'>\n
 	<li class="page_item page-item-1794"><a href="http://example.org/?page_id=1794">Child 1</a></li>\n
 	<li class="page_item page-item-1795"><a href="http://example.org/?page_id=1795">Child 2</a></li>\n
 	<li class="page_item page-item-1796"><a href="http://example.org/?page_id=1796">Child 3</a></li>\n
-</ul>\n
-</li>\n
-<li class="page_item page-item-1792 page_item_has_children"><a href="http://example.org/?page_id=1792">Parent 2</a>\n
-<ul class='children'>\n
-	<li class="page_item page-item-1797"><a href="http://example.org/?page_id=1797">Child 1</a></li>\n
-	<li class="page_item page-item-1798"><a href="http://example.org/?page_id=1798">Child 2</a></li>\n
-	<li class="page_item page-item-1799"><a href="http://example.org/?page_id=1799">Child 3</a></li>\n
 </ul>\n
 </li>\n
 </ul></li>'
/var/www/tests/phpunit/includes/abstract-testcase.php:668
/var/www/tests/phpunit/tests/post/listPages.php:330

Looks like it's caused by indeterminate sort ordering in test_wp_list_pages_sort_column() when trying to sort these pages by post_author in descending order:

  • Parent 3: post_author: 2
  • Parent 1: post_author: 0
  • Parent 2: post_author: 0

By adding an author to Parent 1 too we can make sure the test works as expected.

Change History (4)

#1 @SergeyBiryukov
4 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 48157:

Tests: Add a post author to "Parent 1" page fixture in tests/post/listPages.php.

This avoids indeterminate ordering in test_wp_list_pages_sort_column().

Fixes #50466.

#2 @SergeyBiryukov
4 years ago

In 48176:

Tests: Reformat test_wp_list_pages_discarded_whitespace() for better readability.

See #50466, #49542.

This ticket was mentioned in Slack in #core by sergey. View the logs.


4 years ago

#4 @SergeyBiryukov
4 years ago

In 48280:

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.

Note: See TracTickets for help on using tickets.