Make WordPress Core

Ticket #38688: 0001-tests-call-date-once-per-test.patch

File 0001-tests-call-date-once-per-test.patch, 4.7 KB (added by xrmx, 8 years ago)

Call date once per test

  • tests/phpunit/tests/post/listPages.php

    From c0adf779c94cc0a83e293e6bce1340102940d11a Mon Sep 17 00:00:00 2001
    From: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
    Date: Fri, 11 Nov 2016 20:24:20 +0100
    Subject: [PATCH] tests: call date once per test
    
    So we can run tests around midnight :)
    
    See #38688
    
    diff --git tests/phpunit/tests/post/listPages.php tests/phpunit/tests/post/listPages.php
    index d214631..19995c4 100644
    class Tests_List_Pages extends WP_UnitTestCase { 
    8989                        'depth' => 1,
    9090                        'show_date' => true
    9191                );
    92                 $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( 'F j, Y' ) . '</li>
    93 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a> ' . date( 'F j, Y' ) . '</li>
    94 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a> ' . date( 'F j, Y' ) . '</li>
     92                $date = date( 'F j, Y' );
     93                $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>
     94<li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a> ' . $date . '</li>
     95<li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a> ' . $date . '</li>
    9596</ul></li>';
    9697                $actual = wp_list_pages( $args );
    9798                $this->AssertEquals( $expected['show_date'], $actual );
    class Tests_List_Pages extends WP_UnitTestCase { 
    103104                        'show_date' => true,
    104105                        'date_format' => 'l, F j, Y'
    105106                );
    106                 $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( 'l, F j, Y' ) . '
     107                $date = date( 'l, F j, Y' );
     108                $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 . '
    107109<ul class=\'children\'>
    108         <li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1</a> ' . date( 'l, F j, Y' ) . '</li>
    109         <li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">Child 2</a> ' . date( 'l, F j, Y' ) . '</li>
    110         <li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">Child 3</a> ' . date( 'l, F j, Y' ) . '</li>
     110        <li class="page_item page-item-4"><a href="' . get_permalink( 4 ) . '">Child 1</a> ' . $date . '</li>
     111        <li class="page_item page-item-5"><a href="' . get_permalink( 5 ) . '">Child 2</a> ' . $date . '</li>
     112        <li class="page_item page-item-6"><a href="' . get_permalink( 6 ) . '">Child 3</a> ' . $date . '</li>
    111113</ul>
    112114</li>
    113 <li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a> ' . date( 'l, F j, Y' ) . '
     115<li class="page_item page-item-2 page_item_has_children"><a href="' . get_permalink( 2 ) . '">Parent 2</a> ' . $date . '
    114116<ul class=\'children\'>
    115         <li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">Child 1</a> ' . date( 'l, F j, Y' ) . '</li>
    116         <li class="page_item page-item-8"><a href="' . get_permalink( 8 ) . '">Child 2</a> ' . date( 'l, F j, Y' ) . '</li>
    117         <li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">Child 3</a> ' . date( 'l, F j, Y' ) . '</li>
     117        <li class="page_item page-item-7"><a href="' . get_permalink( 7 ) . '">Child 1</a> ' . $date . '</li>
     118        <li class="page_item page-item-8"><a href="' . get_permalink( 8 ) . '">Child 2</a> ' . $date . '</li>
     119        <li class="page_item page-item-9"><a href="' . get_permalink( 9 ) . '">Child 3</a> ' . $date . '</li>
    118120</ul>
    119121</li>
    120 <li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a> ' . date( 'l, F j, Y' ) . '
     122<li class="page_item page-item-3 page_item_has_children"><a href="' . get_permalink( 3 ) . '">Parent 3</a> ' . $date . '
    121123<ul class=\'children\'>
    122         <li class="page_item page-item-10"><a href="' . get_permalink( 10 ) . '">Child 1</a> ' . date( 'l, F j, Y' ) . '</li>
    123         <li class="page_item page-item-11"><a href="' . get_permalink( 11 ) . '">Child 2</a> ' . date( 'l, F j, Y' ) . '</li>
    124         <li class="page_item page-item-12"><a href="' . get_permalink( 12 ) . '">Child 3</a> ' . date( 'l, F j, Y' ) . '</li>
     124        <li class="page_item page-item-10"><a href="' . get_permalink( 10 ) . '">Child 1</a> ' . $date . '</li>
     125        <li class="page_item page-item-11"><a href="' . get_permalink( 11 ) . '">Child 2</a> ' . $date . '</li>
     126        <li class="page_item page-item-12"><a href="' . get_permalink( 12 ) . '">Child 3</a> ' . $date . '</li>
    125127</ul>
    126128</li>
    127129</ul></li>';