Drop support for model_timezone and view_timezone options in TimeType and DateType.
This commit is contained in:
parent
009fd4ddc1
commit
849fb29984
@ -7,6 +7,7 @@ CHANGELOG
|
|||||||
* added "html5" option to Date, Time and DateTimeFormType to be able to
|
* added "html5" option to Date, Time and DateTimeFormType to be able to
|
||||||
enable/disable HTML5 input date when widget option is "single_text"
|
enable/disable HTML5 input date when widget option is "single_text"
|
||||||
* added "label_format" option with possible placeholders "%name%" and "%id%"
|
* added "label_format" option with possible placeholders "%name%" and "%id%"
|
||||||
|
* [BC BREAK] drop support for model_timezone and view_timezone options in TimeType and DateType
|
||||||
|
|
||||||
2.5.0
|
2.5.0
|
||||||
------
|
------
|
||||||
|
@ -57,8 +57,8 @@ class DateType extends AbstractType
|
|||||||
|
|
||||||
if ('single_text' === $options['widget']) {
|
if ('single_text' === $options['widget']) {
|
||||||
$builder->addViewTransformer(new DateTimeToLocalizedStringTransformer(
|
$builder->addViewTransformer(new DateTimeToLocalizedStringTransformer(
|
||||||
$options['model_timezone'],
|
'UTC',
|
||||||
$options['view_timezone'],
|
'UTC',
|
||||||
$dateFormat,
|
$dateFormat,
|
||||||
$timeFormat,
|
$timeFormat,
|
||||||
$calendar,
|
$calendar,
|
||||||
@ -105,7 +105,7 @@ class DateType extends AbstractType
|
|||||||
->add('month', $options['widget'], $monthOptions)
|
->add('month', $options['widget'], $monthOptions)
|
||||||
->add('day', $options['widget'], $dayOptions)
|
->add('day', $options['widget'], $dayOptions)
|
||||||
->addViewTransformer(new DateTimeToArrayTransformer(
|
->addViewTransformer(new DateTimeToArrayTransformer(
|
||||||
$options['model_timezone'], $options['view_timezone'], array('year', 'month', 'day')
|
'UTC', 'UTC', array('year', 'month', 'day')
|
||||||
))
|
))
|
||||||
->setAttribute('formatter', $formatter)
|
->setAttribute('formatter', $formatter)
|
||||||
;
|
;
|
||||||
@ -113,15 +113,15 @@ class DateType extends AbstractType
|
|||||||
|
|
||||||
if ('string' === $options['input']) {
|
if ('string' === $options['input']) {
|
||||||
$builder->addModelTransformer(new ReversedTransformer(
|
$builder->addModelTransformer(new ReversedTransformer(
|
||||||
new DateTimeToStringTransformer($options['model_timezone'], $options['model_timezone'], 'Y-m-d')
|
new DateTimeToStringTransformer('UTC', 'UTC', 'Y-m-d')
|
||||||
));
|
));
|
||||||
} elseif ('timestamp' === $options['input']) {
|
} elseif ('timestamp' === $options['input']) {
|
||||||
$builder->addModelTransformer(new ReversedTransformer(
|
$builder->addModelTransformer(new ReversedTransformer(
|
||||||
new DateTimeToTimestampTransformer($options['model_timezone'], $options['model_timezone'])
|
new DateTimeToTimestampTransformer('UTC', 'UTC')
|
||||||
));
|
));
|
||||||
} elseif ('array' === $options['input']) {
|
} elseif ('array' === $options['input']) {
|
||||||
$builder->addModelTransformer(new ReversedTransformer(
|
$builder->addModelTransformer(new ReversedTransformer(
|
||||||
new DateTimeToArrayTransformer($options['model_timezone'], $options['model_timezone'], array('year', 'month', 'day'))
|
new DateTimeToArrayTransformer('UTC', 'UTC', array('year', 'month', 'day'))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class TimeType extends AbstractType
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ('single_text' === $options['widget']) {
|
if ('single_text' === $options['widget']) {
|
||||||
$builder->addViewTransformer(new DateTimeToStringTransformer($options['model_timezone'], $options['view_timezone'], $format));
|
$builder->addViewTransformer(new DateTimeToStringTransformer('UTC', 'UTC', $format));
|
||||||
} else {
|
} else {
|
||||||
$hourOptions = $minuteOptions = $secondOptions = array(
|
$hourOptions = $minuteOptions = $secondOptions = array(
|
||||||
'error_bubbling' => true,
|
'error_bubbling' => true,
|
||||||
@ -109,20 +109,20 @@ class TimeType extends AbstractType
|
|||||||
$builder->add('second', $options['widget'], $secondOptions);
|
$builder->add('second', $options['widget'], $secondOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
$builder->addViewTransformer(new DateTimeToArrayTransformer($options['model_timezone'], $options['view_timezone'], $parts, 'text' === $options['widget']));
|
$builder->addViewTransformer(new DateTimeToArrayTransformer('UTC', 'UTC', $parts, 'text' === $options['widget']));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('string' === $options['input']) {
|
if ('string' === $options['input']) {
|
||||||
$builder->addModelTransformer(new ReversedTransformer(
|
$builder->addModelTransformer(new ReversedTransformer(
|
||||||
new DateTimeToStringTransformer($options['model_timezone'], $options['model_timezone'], 'H:i:s')
|
new DateTimeToStringTransformer('UTC', 'UTC', 'H:i:s')
|
||||||
));
|
));
|
||||||
} elseif ('timestamp' === $options['input']) {
|
} elseif ('timestamp' === $options['input']) {
|
||||||
$builder->addModelTransformer(new ReversedTransformer(
|
$builder->addModelTransformer(new ReversedTransformer(
|
||||||
new DateTimeToTimestampTransformer($options['model_timezone'], $options['model_timezone'])
|
new DateTimeToTimestampTransformer('UTC', 'UTC')
|
||||||
));
|
));
|
||||||
} elseif ('array' === $options['input']) {
|
} elseif ('array' === $options['input']) {
|
||||||
$builder->addModelTransformer(new ReversedTransformer(
|
$builder->addModelTransformer(new ReversedTransformer(
|
||||||
new DateTimeToArrayTransformer($options['model_timezone'], $options['model_timezone'], $parts)
|
new DateTimeToArrayTransformer('UTC', 'UTC', $parts)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,8 +197,6 @@ class TimeType extends AbstractType
|
|||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'with_minutes' => true,
|
'with_minutes' => true,
|
||||||
'with_seconds' => false,
|
'with_seconds' => false,
|
||||||
'model_timezone' => null,
|
|
||||||
'view_timezone' => null,
|
|
||||||
'empty_value' => $emptyValue, // deprecated
|
'empty_value' => $emptyValue, // deprecated
|
||||||
'placeholder' => $placeholder,
|
'placeholder' => $placeholder,
|
||||||
'html5' => true,
|
'html5' => true,
|
||||||
|
@ -17,6 +17,8 @@ use Symfony\Component\Intl\Util\IntlTestHelper;
|
|||||||
|
|
||||||
class DateTypeTest extends TypeTestCase
|
class DateTypeTest extends TypeTestCase
|
||||||
{
|
{
|
||||||
|
private $defaultTimezone;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@ -25,6 +27,13 @@ class DateTypeTest extends TypeTestCase
|
|||||||
IntlTestHelper::requireFullIntl($this);
|
IntlTestHelper::requireFullIntl($this);
|
||||||
|
|
||||||
\Locale::setDefault('de_AT');
|
\Locale::setDefault('de_AT');
|
||||||
|
|
||||||
|
$this->defaultTimezone = date_default_timezone_get();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
date_default_timezone_set($this->defaultTimezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,8 +59,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
public function testSubmitFromSingleTextDateTimeWithDefaultFormat()
|
public function testSubmitFromSingleTextDateTimeWithDefaultFormat()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
));
|
));
|
||||||
@ -66,8 +73,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
));
|
));
|
||||||
@ -82,8 +87,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
));
|
));
|
||||||
@ -98,8 +101,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'timestamp',
|
'input' => 'timestamp',
|
||||||
));
|
));
|
||||||
@ -116,8 +117,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
));
|
));
|
||||||
@ -137,8 +136,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
public function testSubmitFromText()
|
public function testSubmitFromText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'widget' => 'text',
|
'widget' => 'text',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -159,8 +156,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
public function testSubmitFromChoice()
|
public function testSubmitFromChoice()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -181,8 +176,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
public function testSubmitFromChoiceEmpty()
|
public function testSubmitFromChoiceEmpty()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
));
|
));
|
||||||
@ -202,8 +195,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
public function testSubmitFromInputDateTimeDifferentPattern()
|
public function testSubmitFromInputDateTimeDifferentPattern()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'format' => 'MM*yyyy*dd',
|
'format' => 'MM*yyyy*dd',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
@ -218,8 +209,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
public function testSubmitFromInputStringDifferentPattern()
|
public function testSubmitFromInputStringDifferentPattern()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'format' => 'MM*yyyy*dd',
|
'format' => 'MM*yyyy*dd',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
@ -234,8 +223,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
public function testSubmitFromInputTimestampDifferentPattern()
|
public function testSubmitFromInputTimestampDifferentPattern()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'format' => 'MM*yyyy*dd',
|
'format' => 'MM*yyyy*dd',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'timestamp',
|
'input' => 'timestamp',
|
||||||
@ -252,8 +239,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
public function testSubmitFromInputRawDifferentPattern()
|
public function testSubmitFromInputRawDifferentPattern()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'format' => 'MM*yyyy*dd',
|
'format' => 'MM*yyyy*dd',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
@ -370,27 +355,12 @@ class DateTypeTest extends TypeTestCase
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetDataWithDifferentTimezones()
|
public function testSetDataWithDifferentTimezoneDateTime()
|
||||||
{
|
{
|
||||||
|
date_default_timezone_set('Pacific/Tahiti');
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
'format' => \IntlDateFormatter::MEDIUM,
|
||||||
'model_timezone' => 'America/New_York',
|
|
||||||
'view_timezone' => 'Pacific/Tahiti',
|
|
||||||
'input' => 'string',
|
|
||||||
'widget' => 'single_text',
|
|
||||||
));
|
|
||||||
|
|
||||||
$form->setData('2010-06-02');
|
|
||||||
|
|
||||||
$this->assertEquals('01.06.2010', $form->getViewData());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSetDataWithDifferentTimezonesDateTime()
|
|
||||||
{
|
|
||||||
$form = $this->factory->create('date', null, array(
|
|
||||||
'format' => \IntlDateFormatter::MEDIUM,
|
|
||||||
'model_timezone' => 'America/New_York',
|
|
||||||
'view_timezone' => 'Pacific/Tahiti',
|
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
@ -400,7 +370,7 @@ class DateTypeTest extends TypeTestCase
|
|||||||
$form->setData($dateTime);
|
$form->setData($dateTime);
|
||||||
|
|
||||||
$this->assertDateTimeEquals($dateTime, $form->getData());
|
$this->assertDateTimeEquals($dateTime, $form->getData());
|
||||||
$this->assertEquals('01.06.2010', $form->getViewData());
|
$this->assertEquals('02.06.2010', $form->getViewData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testYearsOption()
|
public function testYearsOption()
|
||||||
@ -495,8 +465,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -510,8 +478,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -529,8 +495,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -548,8 +512,6 @@ class DateTypeTest extends TypeTestCase
|
|||||||
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
$this->markTestIncomplete('Needs to be reimplemented using validators');
|
||||||
|
|
||||||
$form = $this->factory->create('date', null, array(
|
$form = $this->factory->create('date', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'widget' => 'choice',
|
'widget' => 'choice',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -17,18 +17,25 @@ use Symfony\Component\Intl\Util\IntlTestHelper;
|
|||||||
|
|
||||||
class TimeTypeTest extends TypeTestCase
|
class TimeTypeTest extends TypeTestCase
|
||||||
{
|
{
|
||||||
|
private $defaultTimezone;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
IntlTestHelper::requireIntl($this);
|
IntlTestHelper::requireIntl($this);
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->defaultTimezone = date_default_timezone_get();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
date_default_timezone_set($this->defaultTimezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubmitDateTime()
|
public function testSubmitDateTime()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -48,8 +55,6 @@ class TimeTypeTest extends TypeTestCase
|
|||||||
public function testSubmitString()
|
public function testSubmitString()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -67,8 +72,6 @@ class TimeTypeTest extends TypeTestCase
|
|||||||
public function testSubmitTimestamp()
|
public function testSubmitTimestamp()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'input' => 'timestamp',
|
'input' => 'timestamp',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -88,8 +91,6 @@ class TimeTypeTest extends TypeTestCase
|
|||||||
public function testSubmitArray()
|
public function testSubmitArray()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -107,8 +108,6 @@ class TimeTypeTest extends TypeTestCase
|
|||||||
public function testSubmitDatetimeSingleText()
|
public function testSubmitDatetimeSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
@ -122,8 +121,6 @@ class TimeTypeTest extends TypeTestCase
|
|||||||
public function testSubmitDatetimeSingleTextWithoutMinutes()
|
public function testSubmitDatetimeSingleTextWithoutMinutes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'with_minutes' => false,
|
'with_minutes' => false,
|
||||||
@ -138,8 +135,6 @@ class TimeTypeTest extends TypeTestCase
|
|||||||
public function testSubmitArraySingleText()
|
public function testSubmitArraySingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
@ -158,8 +153,6 @@ class TimeTypeTest extends TypeTestCase
|
|||||||
public function testSubmitArraySingleTextWithoutMinutes()
|
public function testSubmitArraySingleTextWithoutMinutes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'with_minutes' => false,
|
'with_minutes' => false,
|
||||||
@ -178,8 +171,6 @@ class TimeTypeTest extends TypeTestCase
|
|||||||
public function testSubmitArraySingleTextWithSeconds()
|
public function testSubmitArraySingleTextWithSeconds()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'input' => 'array',
|
'input' => 'array',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
@ -200,8 +191,6 @@ class TimeTypeTest extends TypeTestCase
|
|||||||
public function testSubmitStringSingleText()
|
public function testSubmitStringSingleText()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
));
|
));
|
||||||
@ -215,8 +204,6 @@ class TimeTypeTest extends TypeTestCase
|
|||||||
public function testSubmitStringSingleTextWithoutMinutes()
|
public function testSubmitStringSingleTextWithoutMinutes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'input' => 'string',
|
'input' => 'string',
|
||||||
'widget' => 'single_text',
|
'widget' => 'single_text',
|
||||||
'with_minutes' => false,
|
'with_minutes' => false,
|
||||||
@ -231,8 +218,6 @@ class TimeTypeTest extends TypeTestCase
|
|||||||
public function testSetDataWithoutMinutes()
|
public function testSetDataWithoutMinutes()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'with_minutes' => false,
|
'with_minutes' => false,
|
||||||
));
|
));
|
||||||
@ -245,8 +230,6 @@ class TimeTypeTest extends TypeTestCase
|
|||||||
public function testSetDataWithSeconds()
|
public function testSetDataWithSeconds()
|
||||||
{
|
{
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
'model_timezone' => 'UTC',
|
|
||||||
'view_timezone' => 'UTC',
|
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
@ -256,53 +239,23 @@ class TimeTypeTest extends TypeTestCase
|
|||||||
$this->assertEquals(array('hour' => 3, 'minute' => 4, 'second' => 5), $form->getViewData());
|
$this->assertEquals(array('hour' => 3, 'minute' => 4, 'second' => 5), $form->getViewData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetDataDifferentTimezones()
|
public function testSetDataWithTimezoneDateTime()
|
||||||
{
|
{
|
||||||
|
date_default_timezone_set('Asia/Hong_Kong');
|
||||||
|
|
||||||
$form = $this->factory->create('time', null, array(
|
$form = $this->factory->create('time', null, array(
|
||||||
'model_timezone' => 'America/New_York',
|
|
||||||
'view_timezone' => 'Asia/Hong_Kong',
|
|
||||||
'input' => 'string',
|
|
||||||
'with_seconds' => true,
|
|
||||||
));
|
|
||||||
|
|
||||||
$dateTime = new \DateTime('2013-01-01 12:04:05');
|
|
||||||
$dateTime->setTimezone(new \DateTimeZone('America/New_York'));
|
|
||||||
|
|
||||||
$form->setData($dateTime->format('H:i:s'));
|
|
||||||
|
|
||||||
$outputTime = clone $dateTime;
|
|
||||||
$outputTime->setTimezone(new \DateTimeZone('Asia/Hong_Kong'));
|
|
||||||
|
|
||||||
$displayedData = array(
|
|
||||||
'hour' => (int) $outputTime->format('H'),
|
|
||||||
'minute' => (int) $outputTime->format('i'),
|
|
||||||
'second' => (int) $outputTime->format('s'),
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals($displayedData, $form->getViewData());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSetDataDifferentTimezonesDateTime()
|
|
||||||
{
|
|
||||||
$form = $this->factory->create('time', null, array(
|
|
||||||
'model_timezone' => 'America/New_York',
|
|
||||||
'view_timezone' => 'Asia/Hong_Kong',
|
|
||||||
'input' => 'datetime',
|
'input' => 'datetime',
|
||||||
'with_seconds' => true,
|
'with_seconds' => true,
|
||||||
));
|
));
|
||||||
|
|
||||||
$dateTime = new \DateTime('12:04:05');
|
$dateTime = new \DateTime('12:04:05', new \DateTimeZone('America/New_York'));
|
||||||
$dateTime->setTimezone(new \DateTimeZone('America/New_York'));
|
|
||||||
|
|
||||||
$form->setData($dateTime);
|
$form->setData($dateTime);
|
||||||
|
|
||||||
$outputTime = clone $dateTime;
|
|
||||||
$outputTime->setTimezone(new \DateTimeZone('Asia/Hong_Kong'));
|
|
||||||
|
|
||||||
$displayedData = array(
|
$displayedData = array(
|
||||||
'hour' => (int) $outputTime->format('H'),
|
'hour' => 12,
|
||||||
'minute' => (int) $outputTime->format('i'),
|
'minute' => 4,
|
||||||
'second' => (int) $outputTime->format('s'),
|
'second' => 5,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertDateTimeEquals($dateTime, $form->getData());
|
$this->assertDateTimeEquals($dateTime, $form->getData());
|
||||||
|
Reference in New Issue
Block a user