forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetCommentDate.php
More file actions
49 lines (40 loc) · 1.41 KB
/
getCommentDate.php
File metadata and controls
49 lines (40 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* @group date
* @group datetime
* @group comment
*/
class Tests_Date_Get_Comment_Date 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->assertEquals( '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->assertEquals( 'August 29, 2020', get_comment_date( '', $c ) );
$this->assertEquals( '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->assertEquals( '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->assertEquals( '1:51 am', get_comment_time( '' ) );
$this->assertEquals( '1:51 am', get_comment_time( false ) );
}
}