wordpress-develop/tests/phpunit/tests/date/getCommentDate.php
Sergey Biryukov 2a6b527f73 Tests: Improve the @group annotation accuracy and consistency.
Includes removing `.php` from some older group names, because most of the groups are no longer named based on the file containing the function, and sometimes functions move around, making the file-based group name inaccurate.

Props afercia, aristath, poena, SergeyBiryukov.
See #59647.

git-svn-id: https://develop.svn.wordpress.org/trunk@56971 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-19 13:51:04 +00:00

52 lines
1.4 KiB
PHP

<?php
/**
* @group date
* @group datetime
* @group comment
*
* @covers ::get_comment_date
*/
class Tests_Date_GetCommentDate extends WP_UnitTestCase {
/**
* @ticket 51184
*/
public 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->assertSame( 'August 29, 2020', get_comment_date( 'F j, Y', $c ) );
}
/**
* @ticket 51184
*/
public 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->assertSame( 'August 29, 2020', get_comment_date( '', $c ) );
$this->assertSame( 'August 29, 2020', get_comment_date( false, $c ) );
}
/**
* @ticket 51184
*/
public 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->assertSame( '1:51 am', get_comment_time( 'g:i a' ) );
}
/**
* @ticket 51184
*/
public 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->assertSame( '1:51 am', get_comment_time( '' ) );
$this->assertSame( '1:51 am', get_comment_time( false ) );
}
}