mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Date/Time: Make sure get_the_date() and related functions return correct time if the format was specified as false.
Technically, the `$format` argument should always be a string, but passing `false` used to work before [47808], so this restores backward compatibility. The list of affected functions: * `get_the_date()` * `get_the_time()` * `get_comment_date()` * `get_comment_time()` Props wittich, Rarst, akabarikalpesh, SergeyBiryukov. Fixes #51184. git-svn-id: https://develop.svn.wordpress.org/trunk@48912 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
49
tests/phpunit/tests/date/getCommentDate.php
Normal file
49
tests/phpunit/tests/date/getCommentDate.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @group date
|
||||
* @group datetime
|
||||
* @group comment
|
||||
*/
|
||||
class Tests_Date_Get_Comment_Date extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 51184
|
||||
*/
|
||||
function test_get_comment_date_returns_correct_time_with_comment_id() {
|
||||
$c = self::factory()->comment->create( array( 'comment_date' => '2020-08-29 01:51:00' ) );
|
||||
|
||||
$this->assertEquals( 'August 29, 2020', get_comment_date( 'F j, Y', $c ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 51184
|
||||
*/
|
||||
function test_get_comment_date_returns_correct_time_with_empty_format() {
|
||||
$c = self::factory()->comment->create( array( 'comment_date' => '2020-08-29 01:51:00' ) );
|
||||
|
||||
$this->assertEquals( 'August 29, 2020', get_comment_date( '', $c ) );
|
||||
$this->assertEquals( 'August 29, 2020', get_comment_date( false, $c ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 51184
|
||||
*/
|
||||
function test_get_comment_time_returns_correct_time() {
|
||||
$c = self::factory()->comment->create( array( 'comment_date' => '2020-08-29 01:51:00' ) );
|
||||
|
||||
$GLOBALS['comment'] = get_comment( $c );
|
||||
$this->assertEquals( '1:51 am', get_comment_time( 'g:i a' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 51184
|
||||
*/
|
||||
function test_get_comment_time_returns_correct_time_with_empty_format() {
|
||||
$c = self::factory()->comment->create( array( 'comment_date' => '2020-08-29 01:51:00' ) );
|
||||
|
||||
$GLOBALS['comment'] = get_comment( $c );
|
||||
$this->assertEquals( '1:51 am', get_comment_time( '' ) );
|
||||
$this->assertEquals( '1:51 am', get_comment_time( false ) );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user