Make WordPress Core


Ignore:
Timestamp:
05/22/2019 09:57:29 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Date/Time: Bring some consistency to the_date() and the_weekday_date():

  • Make the_date() always apply the the filter and return a value.
  • Use is_new_day() in the_weekday_date().
  • Add a unit test for the_weekday_date().

Fixes #47354.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions.php

    r45270 r45378  
    914914        $json = wp_json_encode( $data, 0, 1 );
    915915        $this->assertFalse( $json );
    916     }
    917 
    918     /**
    919      * @ticket 33750
    920      */
    921     function test_the_date() {
    922         ob_start();
    923         the_date();
    924         $actual = ob_get_clean();
    925         $this->assertEquals( '', $actual );
    926 
    927         $GLOBALS['post'] = self::factory()->post->create_and_get(
    928             array(
    929                 'post_date' => '2015-09-16 08:00:00',
    930             )
    931         );
    932 
    933         ob_start();
    934         $GLOBALS['currentday']  = '18.09.15';
    935         $GLOBALS['previousday'] = '17.09.15';
    936         the_date();
    937         $this->assertEquals( 'September 16, 2015', ob_get_clean() );
    938 
    939         ob_start();
    940         $GLOBALS['currentday']  = '18.09.15';
    941         $GLOBALS['previousday'] = '17.09.15';
    942         the_date( 'Y' );
    943         $this->assertEquals( '2015', ob_get_clean() );
    944 
    945         ob_start();
    946         $GLOBALS['currentday']  = '18.09.15';
    947         $GLOBALS['previousday'] = '17.09.15';
    948         the_date( 'Y', 'before ', ' after' );
    949         $this->assertEquals( 'before 2015 after', ob_get_clean() );
    950 
    951         ob_start();
    952         $GLOBALS['currentday']  = '18.09.15';
    953         $GLOBALS['previousday'] = '17.09.15';
    954         the_date( 'Y', 'before ', ' after', false );
    955         $this->assertEquals( '', ob_get_clean() );
    956916    }
    957917
Note: See TracChangeset for help on using the changeset viewer.