forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpDate.php
More file actions
64 lines (47 loc) · 1.26 KB
/
wpDate.php
File metadata and controls
64 lines (47 loc) · 1.26 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* @group date
* @group datetime
* @covers ::wp_date
*/
class Tests_Date_wpDate extends WP_UnitTestCase {
/** @var WP_Locale */
private $wp_locale_original;
public function setUp() {
global $wp_locale;
parent::setUp();
$this->wp_locale_original = clone $wp_locale;
}
public function tearDown() {
global $wp_locale;
$wp_locale = $this->wp_locale_original;
parent::tearDown();
}
/**
* @ticket 28636
*/
public function test_should_return_false_on_invalid_timestamp() {
$this->assertFalse( wp_date( DATE_RFC3339, 'invalid' ) );
}
/**
* @ticket 48319
*/
public function test_should_not_escape_localized_numbers() {
global $wp_locale;
$wp_locale->month = array( 10 => '10月' );
$utc = new DateTimeZone( 'UTC' );
$datetime = new DateTimeImmutable( '2019-10-17', $utc );
$this->assertSame( '10月', wp_date( 'F', $datetime->getTimestamp(), $utc ) );
}
/**
* @ticket 48319
*/
public function test_should_keep_localized_slashes() {
global $wp_locale;
$string = 'A \ B';
$wp_locale->month = array( 10 => $string );
$utc = new DateTimeZone( 'UTC' );
$datetime = new DateTimeImmutable( '2019-10-17', $utc );
$this->assertSame( $string, wp_date( 'F', $datetime->getTimestamp(), $utc ) );
}
}