Skip to content

Commit 483e944

Browse files
Merge branch '5.3' into 5
2 parents b02ac10 + d7fa531 commit 483e944

File tree

5 files changed

+38
-34
lines changed

5 files changed

+38
-34
lines changed

tests/php/Forms/DateFieldDisabledTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class DateFieldDisabledTest extends SapphireTest
1212
protected function setUp(): void
1313
{
1414
parent::setUp();
15-
i18n::set_locale('en_NZ');
15+
// Set to an explicit locale so project-level locale swapping doesn't affect tests
16+
i18n::set_locale('en_US');
1617
DBDatetime::set_mock_now('2011-02-01 8:34:00');
1718
}
1819

@@ -22,7 +23,7 @@ public function testFieldToday()
2223
$actual = DateField_Disabled::create('Test')
2324
->setValue('2011-02-01')
2425
->Field();
25-
$expected = '<span class="readonly" id="Test">1/02/2011 (today)</span>';
26+
$expected = '<span class="readonly" id="Test">Feb 1, 2011 (today)</span>';
2627
$this->assertEquals($expected, $actual);
2728

2829
// Test today's date with time
@@ -38,14 +39,14 @@ public function testFieldWithDifferentDay()
3839
$actual = DateField_Disabled::create('Test')
3940
->setValue('2011-01-27')
4041
->Field();
41-
$expected = '<span class="readonly" id="Test">27/01/2011, 5 days ago</span>';
42+
$expected = '<span class="readonly" id="Test">Jan 27, 2011, 5 days ago</span>';
4243
$this->assertEquals($expected, $actual);
4344

4445
// Test future
4546
$actual = DateField_Disabled::create('Test')
4647
->setValue('2011-02-06')
4748
->Field();
48-
$expected = '<span class="readonly" id="Test">6/02/2011, in 5 days</span>';
49+
$expected = '<span class="readonly" id="Test">Feb 6, 2011, in 5 days</span>';
4950
$this->assertEquals($expected, $actual);
5051
}
5152

tests/php/Forms/DatetimeFieldTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class DatetimeFieldTest extends SapphireTest
2121
protected function setUp(): void
2222
{
2323
parent::setUp();
24-
i18n::set_locale('en_NZ');
24+
// Set to an explicit locale so project-level locale swapping doesn't affect tests
25+
i18n::set_locale('en_US');
2526
// Fix now to prevent race conditions
2627
DBDatetime::set_mock_now('2010-04-04');
2728
$this->timezone = date_default_timezone_get();
@@ -141,14 +142,14 @@ public function testSetValueWithLocalised()
141142

142143
$datetimeField
143144
->setHTML5(false)
144-
->setLocale('en_NZ');
145+
->setLocale('de_DE');
145146

146-
$datetimeField->setSubmittedValue('29/03/2003 11:00:00 pm');
147-
$this->assertEquals($datetimeField->dataValue(), '2003-03-29 23:00:00');
147+
$datetimeField->setSubmittedValue('29/03/2003 23:00:00');
148+
$this->assertEquals('2003-03-29 23:00:00', $datetimeField->dataValue());
148149

149150
// Some localisation packages exclude the ',' in default medium format
150151
$this->assertMatchesRegularExpression(
151-
'#29/03/2003(,)? 11:00:00 (PM|pm)#',
152+
'#29.03.2003(,)? 23:00:00#',
152153
$datetimeField->Value(),
153154
'User value is formatted, and in user timezone'
154155
);

tests/php/ORM/DBDateTest.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ protected function setUp(): void
2020
$this->oldError = error_reporting();
2121
// Validate setup
2222
assert(date_default_timezone_get() === 'UTC');
23-
i18n::set_locale('en_NZ');
23+
// Set to an explicit locale so project-level locale swapping doesn't affect tests
24+
i18n::set_locale('en_US');
2425
}
2526

2627
protected function tearDown(): void
@@ -48,42 +49,42 @@ protected function restoreNotices()
4849
public function testNiceDate()
4950
{
5051
$this->assertEquals(
51-
'31/03/2008',
52+
'Mar 31, 2008',
5253
DBField::create_field('Date', 1206968400)->Nice(),
5354
"Date->Nice() works with timestamp integers"
5455
);
5556
$this->assertEquals(
56-
'30/03/2008',
57+
'Mar 30, 2008',
5758
DBField::create_field('Date', 1206882000)->Nice(),
5859
"Date->Nice() works with timestamp integers"
5960
);
6061
$this->assertEquals(
61-
'31/03/2008',
62+
'Mar 31, 2008',
6263
DBField::create_field('Date', '1206968400')->Nice(),
6364
"Date->Nice() works with timestamp strings"
6465
);
6566
$this->assertEquals(
66-
'30/03/2008',
67+
'Mar 30, 2008',
6768
DBField::create_field('Date', '1206882000')->Nice(),
6869
"Date->Nice() works with timestamp strings"
6970
);
7071
$this->assertEquals(
71-
'4/03/2003',
72+
'Mar 4, 2003',
7273
DBField::create_field('Date', '4.3.2003')->Nice(),
7374
"Date->Nice() works with D.M.YYYY format"
7475
);
7576
$this->assertEquals(
76-
'4/03/2003',
77+
'Mar 4, 2003',
7778
DBField::create_field('Date', '04.03.2003')->Nice(),
7879
"Date->Nice() works with DD.MM.YYYY format"
7980
);
8081
$this->assertEquals(
81-
'4/03/2003',
82+
'Mar 4, 2003',
8283
DBField::create_field('Date', '2003-3-4')->Nice(),
8384
"Date->Nice() works with YYYY-M-D format"
8485
);
8586
$this->assertEquals(
86-
'4/03/2003',
87+
'Mar 4, 2003',
8788
DBField::create_field('Date', '2003-03-04')->Nice(),
8889
"Date->Nice() works with YYYY-MM-DD format"
8990
);
@@ -107,7 +108,7 @@ public function testInvertedYearCorrection()
107108
{
108109
// iso8601 expects year first, but support year last
109110
$this->assertEquals(
110-
'4/03/2003',
111+
'Mar 4, 2003',
111112
DBField::create_field('Date', '04-03-2003')->Nice(),
112113
"Date->Nice() works with DD-MM-YYYY format"
113114
);
@@ -152,32 +153,32 @@ public function testShortMonth()
152153
public function testLongDate()
153154
{
154155
$this->assertEquals(
155-
'31 March 2008',
156+
'March 31, 2008',
156157
DBField::create_field('Date', 1206968400)->Long(),
157158
"Date->Long() works with numeric timestamp"
158159
);
159160
$this->assertEquals(
160-
'31 March 2008',
161+
'March 31, 2008',
161162
DBField::create_field('Date', '1206968400')->Long(),
162163
"Date->Long() works with string timestamp"
163164
);
164165
$this->assertEquals(
165-
'30 March 2008',
166+
'March 30, 2008',
166167
DBField::create_field('Date', 1206882000)->Long(),
167168
"Date->Long() works with numeric timestamp"
168169
);
169170
$this->assertEquals(
170-
'30 March 2008',
171+
'March 30, 2008',
171172
DBField::create_field('Date', '1206882000')->Long(),
172173
"Date->Long() works with numeric timestamp"
173174
);
174175
$this->assertEquals(
175-
'3 April 2003',
176+
'April 3, 2003',
176177
DBField::create_field('Date', '2003-4-3')->Long(),
177178
"Date->Long() works with YYYY-M-D"
178179
);
179180
$this->assertEquals(
180-
'3 April 2003',
181+
'April 3, 2003',
181182
DBField::create_field('Date', '3.4.2003')->Long(),
182183
"Date->Long() works with D.M.YYYY"
183184
);
@@ -186,7 +187,7 @@ public function testLongDate()
186187
public function testFull()
187188
{
188189
$this->assertEquals(
189-
'Monday, 31 March 2008',
190+
'Monday, March 31, 2008',
190191
DBField::create_field('Date', 1206968400)->Full(),
191192
"Date->Full() works with timestamp integers"
192193
);

tests/php/ORM/DBDatetimeTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class DBDatetimeTest extends SapphireTest
1414
protected function setUp(): void
1515
{
1616
parent::setUp();
17-
i18n::set_locale('en_NZ');
17+
// Set to an explicit locale so project-level locale swapping doesn't affect tests
18+
i18n::set_locale('en_US');
1819
}
1920

2021
public function testNowWithSystemDate()
@@ -126,23 +127,23 @@ public function testNice()
126127
$date = DBDatetime::create_field('Datetime', '2001-12-11 22:10:59');
127128

128129
// note: Some localisation packages exclude the ',' in default medium format
129-
i18n::set_locale('en_NZ');
130-
$this->assertMatchesRegularExpression('#11/12/2001(,)? 10:10 PM#i', $date->Nice());
130+
i18n::set_locale('de_DE');
131+
$this->assertMatchesRegularExpression('#11.12.2001(,)? 22:10#i', $date->Nice());
131132

132133
i18n::set_locale('en_US');
133-
$this->assertMatchesRegularExpression('#Dec 11(,)? 2001(,)? 10:10 PM#i', $date->Nice());
134+
$this->assertMatchesRegularExpression('#Dec 11(,)? 2001(,)? 10:10\hPM#iu', $date->Nice());
134135
}
135136

136137
public function testDate()
137138
{
138139
$date = DBDatetime::create_field('Datetime', '2001-12-31 22:10:59');
139-
$this->assertEquals('31/12/2001', $date->Date());
140+
$this->assertEquals('Dec 31, 2001', $date->Date());
140141
}
141142

142143
public function testTime()
143144
{
144145
$date = DBDatetime::create_field('Datetime', '2001-12-31 22:10:59');
145-
$this->assertMatchesRegularExpression('#10:10:59 PM#i', $date->Time());
146+
$this->assertMatchesRegularExpression('#10:10:59\hPM#iu', $date->Time());
146147
}
147148

148149
public function testTime24()

tests/php/ORM/DBTimeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ public function testParse($input, $expected)
4848
public function testNice()
4949
{
5050
$time = DBTime::create_field('Time', '17:15:55');
51-
$this->assertMatchesRegularExpression('#5:15:55 PM#i', $time->Nice());
51+
$this->assertMatchesRegularExpression('#5:15:55\hPM#iu', $time->Nice());
5252
}
5353

5454
public function testShort()
5555
{
5656
$time = DBTime::create_field('Time', '17:15:55');
57-
$this->assertMatchesRegularExpression('#5:15 PM#i', $time->Short());
57+
$this->assertMatchesRegularExpression('#5:15\hPM#iu', $time->Short());
5858
}
5959
}

0 commit comments

Comments
 (0)