Make WordPress Core

Ticket #33750: 33750.diff

File 33750.diff, 1.9 KB (added by jubstuff, 8 years ago)
  • src/wp-includes/general-template.php

     
    18961896function the_date( $d = '', $before = '', $after = '', $echo = true ) {
    18971897        global $currentday, $previousday;
    18981898
    1899         if ( $currentday != $previousday ) {
     1899        if ( is_new_day() ) {
    19001900                $the_date = $before . get_the_date( $d ) . $after;
    19011901                $previousday = $currentday;
    19021902
  • tests/phpunit/tests/functions.php

     
    671671                $json = wp_json_encode( $data, 0, 1 );
    672672                $this->assertFalse( $json );
    673673        }
     674
     675        /**
     676         * @ticket 33750
     677         */
     678        function test_the_date() {
     679
     680                ob_start();
     681                the_date();
     682                $actual = ob_get_clean();
     683                $this->assertEquals( '', $actual );
     684
     685                $GLOBALS['post']        = $this->factory->post->create_and_get( array(
     686                        'post_date' => '2015-09-16 08:00:00'
     687                ) );
     688
     689                ob_start();
     690                $GLOBALS['currentday']  = '18.09.15';
     691                $GLOBALS['previousday'] = '17.09.15';
     692                the_date();
     693                $actual = ob_get_clean();
     694                $this->assertEquals( 'September 16, 2015', $actual );
     695
     696                ob_start();
     697                $GLOBALS['currentday']  = '18.09.15';
     698                $GLOBALS['previousday'] = '17.09.15';
     699                the_date( 'Y' );
     700                $actual = ob_get_clean();
     701                $this->assertEquals( '2015', $actual );
     702
     703                ob_start();
     704                $GLOBALS['currentday']  = '18.09.15';
     705                $GLOBALS['previousday'] = '17.09.15';
     706                the_date( 'Y', 'before ', ' after' );
     707                $actual = ob_get_clean();
     708                $this->assertEquals( 'before 2015 after', $actual );
     709
     710                ob_start();
     711                $GLOBALS['currentday']  = '18.09.15';
     712                $GLOBALS['previousday'] = '17.09.15';
     713                the_date( 'Y', 'before ', ' after', false );
     714                $actual = ob_get_clean();
     715                $this->assertEquals( '', $actual );
     716
     717
     718
     719        }
    674720}