|
@@ 400-408 (lines=9) @@
|
| 397 |
|
$this->assertEquals('CustomDatetime', $field->getName()); |
| 398 |
|
} |
| 399 |
|
|
| 400 |
|
public function testSchemaDataDefaultsIncludesMinMax() |
| 401 |
|
{ |
| 402 |
|
$field = new DatetimeField('Datetime'); |
| 403 |
|
$field->setMinDatetime('2009-03-31 23:00:00'); |
| 404 |
|
$field->setMaxDatetime('2010-03-31 23:00:00'); |
| 405 |
|
$defaults = $field->getSchemaDataDefaults(); |
| 406 |
|
$this->assertEquals($defaults['data']['min'], '2009-03-31T23:00:00'); |
| 407 |
|
$this->assertEquals($defaults['data']['max'], '2010-03-31T23:00:00'); |
| 408 |
|
} |
| 409 |
|
|
| 410 |
|
public function testSchemaDataDefaultsAdjustsMinMaxToTimezone() |
| 411 |
|
{ |
|
@@ 410-422 (lines=13) @@
|
| 407 |
|
$this->assertEquals($defaults['data']['max'], '2010-03-31T23:00:00'); |
| 408 |
|
} |
| 409 |
|
|
| 410 |
|
public function testSchemaDataDefaultsAdjustsMinMaxToTimezone() |
| 411 |
|
{ |
| 412 |
|
date_default_timezone_set('Europe/Berlin'); |
| 413 |
|
// Berlin and Auckland have 12h time difference in northern hemisphere summer, but Berlin and Moscow only 2h. |
| 414 |
|
|
| 415 |
|
$field = new DatetimeField('Datetime'); |
| 416 |
|
$field->setTimezone('Pacific/Auckland'); |
| 417 |
|
$field->setMinDatetime('2009-01-31 11:00:00'); // server timezone |
| 418 |
|
$field->setMaxDatetime('2010-01-31 11:00:00'); // server timezone |
| 419 |
|
$defaults = $field->getSchemaDataDefaults(); |
| 420 |
|
$this->assertEquals($defaults['data']['min'], '2009-01-31T23:00:00'); // frontend timezone |
| 421 |
|
$this->assertEquals($defaults['data']['max'], '2010-01-31T23:00:00'); // frontend timezone |
| 422 |
|
} |
| 423 |
|
|
| 424 |
|
public function testAttributesIncludesMinMax() |
| 425 |
|
{ |
|
@@ 434-446 (lines=13) @@
|
| 431 |
|
$this->assertEquals($attrs['max'], '2010-03-31T23:00:00'); |
| 432 |
|
} |
| 433 |
|
|
| 434 |
|
public function testAttributesAdjustsMinMaxToTimezone() |
| 435 |
|
{ |
| 436 |
|
date_default_timezone_set('Europe/Berlin'); |
| 437 |
|
// Berlin and Auckland have 12h time difference in northern hemisphere summer, but Berlin and Moscow only 2h. |
| 438 |
|
|
| 439 |
|
$field = new DatetimeField('Datetime'); |
| 440 |
|
$field->setTimezone('Pacific/Auckland'); |
| 441 |
|
$field->setMinDatetime('2009-01-31 11:00:00'); // server timezone |
| 442 |
|
$field->setMaxDatetime('2010-01-31 11:00:00'); // server timezone |
| 443 |
|
$attrs = $field->getAttributes(); |
| 444 |
|
$this->assertEquals($attrs['min'], '2009-01-31T23:00:00'); // frontend timezone |
| 445 |
|
$this->assertEquals($attrs['max'], '2010-01-31T23:00:00'); // frontend timezone |
| 446 |
|
} |
| 447 |
|
|
| 448 |
|
protected function getMockForm() |
| 449 |
|
{ |