17
17
18
18
class DateTypeTest extends TypeTestCase
19
19
{
20
+ private $ defaultTimezone ;
21
+
20
22
protected function setUp ()
21
23
{
22
24
parent ::setUp ();
@@ -25,6 +27,13 @@ protected function setUp()
25
27
IntlTestHelper::requireFullIntl ($ this );
26
28
27
29
\Locale::setDefault ('de_AT ' );
30
+
31
+ $ this ->defaultTimezone = date_default_timezone_get ();
32
+ }
33
+
34
+ protected function tearDown ()
35
+ {
36
+ date_default_timezone_set ($ this ->defaultTimezone );
28
37
}
29
38
30
39
/**
@@ -50,8 +59,6 @@ public function testInvalidInputOption()
50
59
public function testSubmitFromSingleTextDateTimeWithDefaultFormat ()
51
60
{
52
61
$ form = $ this ->factory ->create ('date ' , null , array (
53
- 'model_timezone ' => 'UTC ' ,
54
- 'view_timezone ' => 'UTC ' ,
55
62
'widget ' => 'single_text ' ,
56
63
'input ' => 'datetime ' ,
57
64
));
@@ -66,8 +73,6 @@ public function testSubmitFromSingleTextDateTime()
66
73
{
67
74
$ form = $ this ->factory ->create ('date ' , null , array (
68
75
'format ' => \IntlDateFormatter::MEDIUM ,
69
- 'model_timezone ' => 'UTC ' ,
70
- 'view_timezone ' => 'UTC ' ,
71
76
'widget ' => 'single_text ' ,
72
77
'input ' => 'datetime ' ,
73
78
));
@@ -82,8 +87,6 @@ public function testSubmitFromSingleTextString()
82
87
{
83
88
$ form = $ this ->factory ->create ('date ' , null , array (
84
89
'format ' => \IntlDateFormatter::MEDIUM ,
85
- 'model_timezone ' => 'UTC ' ,
86
- 'view_timezone ' => 'UTC ' ,
87
90
'widget ' => 'single_text ' ,
88
91
'input ' => 'string ' ,
89
92
));
@@ -98,8 +101,6 @@ public function testSubmitFromSingleTextTimestamp()
98
101
{
99
102
$ form = $ this ->factory ->create ('date ' , null , array (
100
103
'format ' => \IntlDateFormatter::MEDIUM ,
101
- 'model_timezone ' => 'UTC ' ,
102
- 'view_timezone ' => 'UTC ' ,
103
104
'widget ' => 'single_text ' ,
104
105
'input ' => 'timestamp ' ,
105
106
));
@@ -116,8 +117,6 @@ public function testSubmitFromSingleTextRaw()
116
117
{
117
118
$ form = $ this ->factory ->create ('date ' , null , array (
118
119
'format ' => \IntlDateFormatter::MEDIUM ,
119
- 'model_timezone ' => 'UTC ' ,
120
- 'view_timezone ' => 'UTC ' ,
121
120
'widget ' => 'single_text ' ,
122
121
'input ' => 'array ' ,
123
122
));
@@ -137,8 +136,6 @@ public function testSubmitFromSingleTextRaw()
137
136
public function testSubmitFromText ()
138
137
{
139
138
$ form = $ this ->factory ->create ('date ' , null , array (
140
- 'model_timezone ' => 'UTC ' ,
141
- 'view_timezone ' => 'UTC ' ,
142
139
'widget ' => 'text ' ,
143
140
));
144
141
@@ -159,8 +156,6 @@ public function testSubmitFromText()
159
156
public function testSubmitFromChoice ()
160
157
{
161
158
$ form = $ this ->factory ->create ('date ' , null , array (
162
- 'model_timezone ' => 'UTC ' ,
163
- 'view_timezone ' => 'UTC ' ,
164
159
'widget ' => 'choice ' ,
165
160
));
166
161
@@ -181,8 +176,6 @@ public function testSubmitFromChoice()
181
176
public function testSubmitFromChoiceEmpty ()
182
177
{
183
178
$ form = $ this ->factory ->create ('date ' , null , array (
184
- 'model_timezone ' => 'UTC ' ,
185
- 'view_timezone ' => 'UTC ' ,
186
179
'widget ' => 'choice ' ,
187
180
'required ' => false ,
188
181
));
@@ -202,8 +195,6 @@ public function testSubmitFromChoiceEmpty()
202
195
public function testSubmitFromInputDateTimeDifferentPattern ()
203
196
{
204
197
$ form = $ this ->factory ->create ('date ' , null , array (
205
- 'model_timezone ' => 'UTC ' ,
206
- 'view_timezone ' => 'UTC ' ,
207
198
'format ' => 'MM*yyyy*dd ' ,
208
199
'widget ' => 'single_text ' ,
209
200
'input ' => 'datetime ' ,
@@ -218,8 +209,6 @@ public function testSubmitFromInputDateTimeDifferentPattern()
218
209
public function testSubmitFromInputStringDifferentPattern ()
219
210
{
220
211
$ form = $ this ->factory ->create ('date ' , null , array (
221
- 'model_timezone ' => 'UTC ' ,
222
- 'view_timezone ' => 'UTC ' ,
223
212
'format ' => 'MM*yyyy*dd ' ,
224
213
'widget ' => 'single_text ' ,
225
214
'input ' => 'string ' ,
@@ -234,8 +223,6 @@ public function testSubmitFromInputStringDifferentPattern()
234
223
public function testSubmitFromInputTimestampDifferentPattern ()
235
224
{
236
225
$ form = $ this ->factory ->create ('date ' , null , array (
237
- 'model_timezone ' => 'UTC ' ,
238
- 'view_timezone ' => 'UTC ' ,
239
226
'format ' => 'MM*yyyy*dd ' ,
240
227
'widget ' => 'single_text ' ,
241
228
'input ' => 'timestamp ' ,
@@ -252,8 +239,6 @@ public function testSubmitFromInputTimestampDifferentPattern()
252
239
public function testSubmitFromInputRawDifferentPattern ()
253
240
{
254
241
$ form = $ this ->factory ->create ('date ' , null , array (
255
- 'model_timezone ' => 'UTC ' ,
256
- 'view_timezone ' => 'UTC ' ,
257
242
'format ' => 'MM*yyyy*dd ' ,
258
243
'widget ' => 'single_text ' ,
259
244
'input ' => 'array ' ,
@@ -370,27 +355,12 @@ public function testThrowExceptionIfDaysIsInvalid()
370
355
));
371
356
}
372
357
373
- public function testSetDataWithDifferentTimezones ()
358
+ public function testSetDataWithDifferentTimezoneDateTime ()
374
359
{
375
- $ form = $ this ->factory ->create ('date ' , null , array (
376
- 'format ' => \IntlDateFormatter::MEDIUM ,
377
- 'model_timezone ' => 'America/New_York ' ,
378
- 'view_timezone ' => 'Pacific/Tahiti ' ,
379
- 'input ' => 'string ' ,
380
- 'widget ' => 'single_text ' ,
381
- ));
360
+ date_default_timezone_set ('Pacific/Tahiti ' );
382
361
383
- $ form ->setData ('2010-06-02 ' );
384
-
385
- $ this ->assertEquals ('01.06.2010 ' , $ form ->getViewData ());
386
- }
387
-
388
- public function testSetDataWithDifferentTimezonesDateTime ()
389
- {
390
362
$ form = $ this ->factory ->create ('date ' , null , array (
391
363
'format ' => \IntlDateFormatter::MEDIUM ,
392
- 'model_timezone ' => 'America/New_York ' ,
393
- 'view_timezone ' => 'Pacific/Tahiti ' ,
394
364
'input ' => 'datetime ' ,
395
365
'widget ' => 'single_text ' ,
396
366
));
@@ -400,7 +370,7 @@ public function testSetDataWithDifferentTimezonesDateTime()
400
370
$ form ->setData ($ dateTime );
401
371
402
372
$ this ->assertDateTimeEquals ($ dateTime , $ form ->getData ());
403
- $ this ->assertEquals ('01 .06.2010 ' , $ form ->getViewData ());
373
+ $ this ->assertEquals ('02 .06.2010 ' , $ form ->getViewData ());
404
374
}
405
375
406
376
public function testYearsOption ()
@@ -495,8 +465,6 @@ public function testIsPartiallyFilledReturnsFalseIfSingleText()
495
465
$ this ->markTestIncomplete ('Needs to be reimplemented using validators ' );
496
466
497
467
$ form = $ this ->factory ->create ('date ' , null , array (
498
- 'model_timezone ' => 'UTC ' ,
499
- 'view_timezone ' => 'UTC ' ,
500
468
'widget ' => 'single_text ' ,
501
469
));
502
470
@@ -510,8 +478,6 @@ public function testIsPartiallyFilledReturnsFalseIfChoiceAndCompletelyEmpty()
510
478
$ this ->markTestIncomplete ('Needs to be reimplemented using validators ' );
511
479
512
480
$ form = $ this ->factory ->create ('date ' , null , array (
513
- 'model_timezone ' => 'UTC ' ,
514
- 'view_timezone ' => 'UTC ' ,
515
481
'widget ' => 'choice ' ,
516
482
));
517
483
@@ -529,8 +495,6 @@ public function testIsPartiallyFilledReturnsFalseIfChoiceAndCompletelyFilled()
529
495
$ this ->markTestIncomplete ('Needs to be reimplemented using validators ' );
530
496
531
497
$ form = $ this ->factory ->create ('date ' , null , array (
532
- 'model_timezone ' => 'UTC ' ,
533
- 'view_timezone ' => 'UTC ' ,
534
498
'widget ' => 'choice ' ,
535
499
));
536
500
@@ -548,8 +512,6 @@ public function testIsPartiallyFilledReturnsTrueIfChoiceAndDayEmpty()
548
512
$ this ->markTestIncomplete ('Needs to be reimplemented using validators ' );
549
513
550
514
$ form = $ this ->factory ->create ('date ' , null , array (
551
- 'model_timezone ' => 'UTC ' ,
552
- 'view_timezone ' => 'UTC ' ,
553
515
'widget ' => 'choice ' ,
554
516
));
555
517
0 commit comments