forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocale.php
More file actions
116 lines (104 loc) · 5.64 KB
/
locale.php
File metadata and controls
116 lines (104 loc) · 5.64 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/**
* @group l10n
* @group i18n
*/
class Tests_Locale extends WP_UnitTestCase {
/**
* @var WP_Locale
*/
protected $locale;
public function setUp() {
parent::setUp();
$this->locale = new WP_Locale();
}
public function test_get_weekday() {
$this->assertSame( __( 'Sunday' ), $this->locale->get_weekday( 0 ) );
$this->assertSame( __( 'Monday' ), $this->locale->get_weekday( 1 ) );
$this->assertSame( __( 'Tuesday' ), $this->locale->get_weekday( 2 ) );
$this->assertSame( __( 'Wednesday' ), $this->locale->get_weekday( 3 ) );
$this->assertSame( __( 'Thursday' ), $this->locale->get_weekday( 4 ) );
$this->assertSame( __( 'Friday' ), $this->locale->get_weekday( 5 ) );
$this->assertSame( __( 'Saturday' ), $this->locale->get_weekday( 6 ) );
}
public function test_get_weekday_undefined_index() {
if ( PHP_VERSION_ID >= 80000 ) {
$this->expectException( 'PHPUnit_Framework_Error_Warning' );
} else {
$this->expectException( 'PHPUnit_Framework_Error_Notice' );
}
$this->locale->get_weekday( 7 );
}
public function test_get_weekday_initial() {
$this->assertSame( __( 'S' ), $this->locale->get_weekday_initial( __( 'Sunday' ) ) );
$this->assertSame( __( 'M' ), $this->locale->get_weekday_initial( __( 'Monday' ) ) );
$this->assertSame( __( 'T' ), $this->locale->get_weekday_initial( __( 'Tuesday' ) ) );
$this->assertSame( __( 'W' ), $this->locale->get_weekday_initial( __( 'Wednesday' ) ) );
$this->assertSame( __( 'T' ), $this->locale->get_weekday_initial( __( 'Thursday' ) ) );
$this->assertSame( __( 'F' ), $this->locale->get_weekday_initial( __( 'Friday' ) ) );
$this->assertSame( __( 'S' ), $this->locale->get_weekday_initial( __( 'Saturday' ) ) );
}
public function test_get_weekday_abbrev() {
$this->assertSame( __( 'Sun' ), $this->locale->get_weekday_abbrev( __( 'Sunday' ) ) );
$this->assertSame( __( 'Mon' ), $this->locale->get_weekday_abbrev( __( 'Monday' ) ) );
$this->assertSame( __( 'Tue' ), $this->locale->get_weekday_abbrev( __( 'Tuesday' ) ) );
$this->assertSame( __( 'Wed' ), $this->locale->get_weekday_abbrev( __( 'Wednesday' ) ) );
$this->assertSame( __( 'Thu' ), $this->locale->get_weekday_abbrev( __( 'Thursday' ) ) );
$this->assertSame( __( 'Fri' ), $this->locale->get_weekday_abbrev( __( 'Friday' ) ) );
$this->assertSame( __( 'Sat' ), $this->locale->get_weekday_abbrev( __( 'Saturday' ) ) );
}
public function test_get_month() {
$this->assertSame( __( 'January' ), $this->locale->get_month( 1 ) );
$this->assertSame( __( 'February' ), $this->locale->get_month( 2 ) );
$this->assertSame( __( 'March' ), $this->locale->get_month( 3 ) );
$this->assertSame( __( 'April' ), $this->locale->get_month( 4 ) );
$this->assertSame( __( 'May' ), $this->locale->get_month( 5 ) );
$this->assertSame( __( 'June' ), $this->locale->get_month( 6 ) );
$this->assertSame( __( 'July' ), $this->locale->get_month( 7 ) );
$this->assertSame( __( 'August' ), $this->locale->get_month( 8 ) );
$this->assertSame( __( 'September' ), $this->locale->get_month( 9 ) );
$this->assertSame( __( 'October' ), $this->locale->get_month( 10 ) );
$this->assertSame( __( 'November' ), $this->locale->get_month( 11 ) );
$this->assertSame( __( 'December' ), $this->locale->get_month( 12 ) );
}
public function test_get_month_leading_zero() {
$this->assertSame( __( 'January' ), $this->locale->get_month( '01' ) );
$this->assertSame( __( 'February' ), $this->locale->get_month( '02' ) );
$this->assertSame( __( 'March' ), $this->locale->get_month( '03' ) );
$this->assertSame( __( 'April' ), $this->locale->get_month( '04' ) );
$this->assertSame( __( 'May' ), $this->locale->get_month( '05' ) );
$this->assertSame( __( 'June' ), $this->locale->get_month( '06' ) );
$this->assertSame( __( 'July' ), $this->locale->get_month( '07' ) );
$this->assertSame( __( 'August' ), $this->locale->get_month( '08' ) );
$this->assertSame( __( 'September' ), $this->locale->get_month( '09' ) );
}
public function test_get_month_abbrev() {
$this->assertSame( __( 'Jan' ), $this->locale->get_month_abbrev( __( 'January' ) ) );
$this->assertSame( __( 'Feb' ), $this->locale->get_month_abbrev( __( 'February' ) ) );
$this->assertSame( __( 'Mar' ), $this->locale->get_month_abbrev( __( 'March' ) ) );
$this->assertSame( __( 'Apr' ), $this->locale->get_month_abbrev( __( 'April' ) ) );
$this->assertSame( __( 'May' ), $this->locale->get_month_abbrev( __( 'May' ) ) );
$this->assertSame( __( 'Jun' ), $this->locale->get_month_abbrev( __( 'June' ) ) );
$this->assertSame( __( 'Jul' ), $this->locale->get_month_abbrev( __( 'July' ) ) );
$this->assertSame( __( 'Aug' ), $this->locale->get_month_abbrev( __( 'August' ) ) );
$this->assertSame( __( 'Sep' ), $this->locale->get_month_abbrev( __( 'September' ) ) );
$this->assertSame( __( 'Oct' ), $this->locale->get_month_abbrev( __( 'October' ) ) );
$this->assertSame( __( 'Nov' ), $this->locale->get_month_abbrev( __( 'November' ) ) );
$this->assertSame( __( 'Dec' ), $this->locale->get_month_abbrev( __( 'December' ) ) );
}
public function test_get_meridiem() {
$this->assertSame( __( 'am' ), $this->locale->get_meridiem( 'am' ) );
$this->assertSame( __( 'AM' ), $this->locale->get_meridiem( 'AM' ) );
$this->assertSame( __( 'pm' ), $this->locale->get_meridiem( 'pm' ) );
$this->assertSame( __( 'PM' ), $this->locale->get_meridiem( 'PM' ) );
}
public function test_is_rtl() {
$this->assertFalse( $this->locale->is_rtl() );
$this->locale->text_direction = 'foo';
$this->assertFalse( $this->locale->is_rtl() );
$this->locale->text_direction = 'rtl';
$this->assertTrue( $this->locale->is_rtl() );
$this->locale->text_direction = 'ltr';
$this->assertFalse( $this->locale->is_rtl() );
}
}