From 25ede80cab3089dbcc3bb61d3ce6134ff35f1b8d Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sun, 27 Nov 2016 00:07:49 +0000 Subject: [PATCH] Build/Test Tools: When testing the output of `wp_list_pages()`, use a known and fixed date for each post so the tests don't fail when the date changes between the beginning and end of a test. Props xrmx Fixes #38688 git-svn-id: https://develop.svn.wordpress.org/trunk@39363 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/post/listPages.php | 48 +++++++++++++++----------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/tests/phpunit/tests/post/listPages.php b/tests/phpunit/tests/post/listPages.php index d2146312dd..a550c389ed 100644 --- a/tests/phpunit/tests/post/listPages.php +++ b/tests/phpunit/tests/post/listPages.php @@ -3,6 +3,8 @@ class Tests_List_Pages extends WP_UnitTestCase { var $pages; + protected $time = null; + /* $defaults = array( 'depth' => 0, @@ -27,16 +29,18 @@ class Tests_List_Pages extends WP_UnitTestCase { parent::setUp(); global $wpdb; $wpdb->query( 'TRUNCATE ' . $wpdb->prefix . 'posts' ); + $this->time = time(); + $post_date = date( 'Y-m-d H:i:s', $this->time ); $pages = array(); self::factory()->user->create(); - $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 1' ) ); - $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 2' ) ); - $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 3', 'post_author' => '2' ) ); + $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 1', 'post_date' => $post_date ) ); + $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 2', 'post_date' => $post_date ) ); + $pages[] = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Parent 3', 'post_author' => '2', 'post_date' => $post_date ) ); foreach ( $pages as $page ) { - $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 1' ) ); - $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 2' ) ); - $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 3' ) ); + $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 1', 'post_date' => $post_date ) ); + $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 2', 'post_date' => $post_date ) ); + $this->pages[$page] = self::factory()->post->create( array( 'post_parent' => $page, 'post_type' => 'page', 'post_title' => 'Child 3', 'post_date' => $post_date ) ); } } @@ -89,9 +93,10 @@ class Tests_List_Pages extends WP_UnitTestCase { 'depth' => 1, 'show_date' => true ); - $expected['show_date'] = '