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.

git-svn-id: https://develop.svn.wordpress.org/trunk@45378 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2019-05-22 21:57:29 +00:00
parent 36df800c3c
commit 48fb69f013
3 changed files with 96 additions and 65 deletions

View File

@@ -915,46 +915,6 @@ class Tests_Functions extends WP_UnitTestCase {
$this->assertFalse( $json );
}
/**
* @ticket 33750
*/
function test_the_date() {
ob_start();
the_date();
$actual = ob_get_clean();
$this->assertEquals( '', $actual );
$GLOBALS['post'] = self::factory()->post->create_and_get(
array(
'post_date' => '2015-09-16 08:00:00',
)
);
ob_start();
$GLOBALS['currentday'] = '18.09.15';
$GLOBALS['previousday'] = '17.09.15';
the_date();
$this->assertEquals( 'September 16, 2015', ob_get_clean() );
ob_start();
$GLOBALS['currentday'] = '18.09.15';
$GLOBALS['previousday'] = '17.09.15';
the_date( 'Y' );
$this->assertEquals( '2015', ob_get_clean() );
ob_start();
$GLOBALS['currentday'] = '18.09.15';
$GLOBALS['previousday'] = '17.09.15';
the_date( 'Y', 'before ', ' after' );
$this->assertEquals( 'before 2015 after', ob_get_clean() );
ob_start();
$GLOBALS['currentday'] = '18.09.15';
$GLOBALS['previousday'] = '17.09.15';
the_date( 'Y', 'before ', ' after', false );
$this->assertEquals( '', ob_get_clean() );
}
/**
* @ticket 36054
* @dataProvider datetime_provider