Merge branch '2.6' into 2.7
* 2.6: [Form] Fixed DateType/TimeType that were broken since849fb29984
and1c4a75a00a
[Debug] Skip unsilencing test on PHP7 [Profiler][Logger] fixed cycle odd/even.
This commit is contained in:
commit
c0ddd3da26
@ -88,10 +88,12 @@
|
||||
|
||||
{% if collector.logs %}
|
||||
<ul class="alt">
|
||||
{% set log_loop_index = 0 %}
|
||||
{% for log in collector.logs %}
|
||||
{% set is_deprecation = log.context.level is defined and log.context.type is defined and (constant('E_DEPRECATED') == log.context.type or constant('E_USER_DEPRECATED') == log.context.type) %}
|
||||
{% if priority == '-100' ? is_deprecation : log.priority >= priority %}
|
||||
<li class="{{ cycle(['odd', 'even'], loop.index) }}{% if log.context.scream is defined %} scream{% elseif log.priority >= 400 %} error{% elseif log.priority >= 300 %} warning{% endif %}">
|
||||
{% set log_loop_index = log_loop_index + 1 %}
|
||||
<li class="{{ cycle(['odd', 'even'], log_loop_index) }}{% if log.context.scream is defined %} scream{% elseif log.priority >= 400 %} error{% elseif log.priority >= 300 %} warning{% endif %}">
|
||||
{{ logger.display_message(loop.index, log, is_deprecation) }}
|
||||
</li>
|
||||
{% endif %}
|
||||
|
@ -61,6 +61,10 @@ class DebugClassLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testUnsilencing()
|
||||
{
|
||||
if (PHP_VERSION_ID >= 70000) {
|
||||
$this->markTestSkipped('PHP7 throws exceptions, unsilencing is not required anymore.');
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
$this->iniSet('log_errors', 0);
|
||||
|
@ -57,8 +57,8 @@ class DateType extends AbstractType
|
||||
|
||||
if ('single_text' === $options['widget']) {
|
||||
$builder->addViewTransformer(new DateTimeToLocalizedStringTransformer(
|
||||
null,
|
||||
null,
|
||||
$options['model_timezone'],
|
||||
$options['view_timezone'],
|
||||
$dateFormat,
|
||||
$timeFormat,
|
||||
$calendar,
|
||||
@ -105,7 +105,7 @@ class DateType extends AbstractType
|
||||
->add('month', $options['widget'], $monthOptions)
|
||||
->add('day', $options['widget'], $dayOptions)
|
||||
->addViewTransformer(new DateTimeToArrayTransformer(
|
||||
null, null, array('year', 'month', 'day')
|
||||
$options['model_timezone'], $options['view_timezone'], array('year', 'month', 'day')
|
||||
))
|
||||
->setAttribute('formatter', $formatter)
|
||||
;
|
||||
@ -113,15 +113,15 @@ class DateType extends AbstractType
|
||||
|
||||
if ('string' === $options['input']) {
|
||||
$builder->addModelTransformer(new ReversedTransformer(
|
||||
new DateTimeToStringTransformer(null, null, 'Y-m-d')
|
||||
new DateTimeToStringTransformer($options['model_timezone'], $options['model_timezone'], 'Y-m-d')
|
||||
));
|
||||
} elseif ('timestamp' === $options['input']) {
|
||||
$builder->addModelTransformer(new ReversedTransformer(
|
||||
new DateTimeToTimestampTransformer(null, null)
|
||||
new DateTimeToTimestampTransformer($options['model_timezone'], $options['model_timezone'])
|
||||
));
|
||||
} elseif ('array' === $options['input']) {
|
||||
$builder->addModelTransformer(new ReversedTransformer(
|
||||
new DateTimeToArrayTransformer(null, null, array('year', 'month', 'day'))
|
||||
new DateTimeToArrayTransformer($options['model_timezone'], $options['model_timezone'], array('year', 'month', 'day'))
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class TimeType extends AbstractType
|
||||
}
|
||||
|
||||
if ('single_text' === $options['widget']) {
|
||||
$builder->addViewTransformer(new DateTimeToStringTransformer(null, null, $format));
|
||||
$builder->addViewTransformer(new DateTimeToStringTransformer($options['model_timezone'], $options['view_timezone'], $format));
|
||||
} else {
|
||||
$hourOptions = $minuteOptions = $secondOptions = array(
|
||||
'error_bubbling' => true,
|
||||
@ -109,20 +109,20 @@ class TimeType extends AbstractType
|
||||
$builder->add('second', $options['widget'], $secondOptions);
|
||||
}
|
||||
|
||||
$builder->addViewTransformer(new DateTimeToArrayTransformer(null, null, $parts, 'text' === $options['widget']));
|
||||
$builder->addViewTransformer(new DateTimeToArrayTransformer($options['model_timezone'], $options['view_timezone'], $parts, 'text' === $options['widget']));
|
||||
}
|
||||
|
||||
if ('string' === $options['input']) {
|
||||
$builder->addModelTransformer(new ReversedTransformer(
|
||||
new DateTimeToStringTransformer(null, null, 'H:i:s')
|
||||
new DateTimeToStringTransformer($options['model_timezone'], $options['model_timezone'], 'H:i:s')
|
||||
));
|
||||
} elseif ('timestamp' === $options['input']) {
|
||||
$builder->addModelTransformer(new ReversedTransformer(
|
||||
new DateTimeToTimestampTransformer(null, null)
|
||||
new DateTimeToTimestampTransformer($options['model_timezone'], $options['model_timezone'])
|
||||
));
|
||||
} elseif ('array' === $options['input']) {
|
||||
$builder->addModelTransformer(new ReversedTransformer(
|
||||
new DateTimeToArrayTransformer(null, null, $parts)
|
||||
new DateTimeToArrayTransformer($options['model_timezone'], $options['model_timezone'], $parts)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -380,93 +380,43 @@ class DateTypeTest extends TestCase
|
||||
));
|
||||
}
|
||||
|
||||
public function testSetDataWithDifferentNegativeUTCTimezoneDateTime()
|
||||
public function testSetDataWithNegativeTimezoneOffsetStringInput()
|
||||
{
|
||||
$form = $this->factory->create('date', null, array(
|
||||
'format' => \IntlDateFormatter::MEDIUM,
|
||||
'model_timezone' => 'America/New_York',
|
||||
'view_timezone' => 'Pacific/Tahiti',
|
||||
'model_timezone' => 'UTC',
|
||||
'view_timezone' => 'America/New_York',
|
||||
'input' => 'string',
|
||||
'widget' => 'single_text',
|
||||
));
|
||||
|
||||
$form->setData('2010-06-02');
|
||||
|
||||
// 2010-06-02 00:00:00 UTC
|
||||
// 2010-06-01 20:00:00 UTC-4
|
||||
$this->assertEquals('01.06.2010', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSetDataWithDifferentTimezonesDateTime()
|
||||
public function testSetDataWithNegativeTimezoneOffsetDateTimeInput()
|
||||
{
|
||||
$form = $this->factory->create('date', null, array(
|
||||
'format' => \IntlDateFormatter::MEDIUM,
|
||||
'model_timezone' => 'America/New_York',
|
||||
'view_timezone' => 'Pacific/Tahiti',
|
||||
'model_timezone' => 'UTC',
|
||||
'view_timezone' => 'America/New_York',
|
||||
'input' => 'datetime',
|
||||
'widget' => 'single_text',
|
||||
));
|
||||
|
||||
$dateTime = new \DateTime('2010-06-02 America/New_York');
|
||||
$dateTime = new \DateTime('2010-06-02 UTC');
|
||||
|
||||
$form->setData($dateTime);
|
||||
|
||||
// 2010-06-02 00:00:00 UTC
|
||||
// 2010-06-01 20:00:00 UTC-4
|
||||
$this->assertDateTimeEquals($dateTime, $form->getData());
|
||||
$this->assertEquals('01.06.2010', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSetDataWithDifferentPositiveUTCTimezoneDateTime()
|
||||
{
|
||||
date_default_timezone_set('Pacific/Tahiti');
|
||||
|
||||
$form = $this->factory->create('date', null, array(
|
||||
'format' => \IntlDateFormatter::MEDIUM,
|
||||
'input' => 'datetime',
|
||||
'widget' => 'single_text',
|
||||
));
|
||||
|
||||
$dateTime = new \DateTime('2010-06-02 Australia/Melbourne');
|
||||
|
||||
$form->setData($dateTime);
|
||||
|
||||
$this->assertDateTimeEquals($dateTime, $form->getData());
|
||||
$this->assertEquals('02.06.2010', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSetDataWithSamePositiveUTCTimezoneDateTime()
|
||||
{
|
||||
date_default_timezone_set('Australia/Melbourne');
|
||||
|
||||
$form = $this->factory->create('date', null, array(
|
||||
'format' => \IntlDateFormatter::MEDIUM,
|
||||
'input' => 'datetime',
|
||||
'widget' => 'single_text',
|
||||
));
|
||||
|
||||
$dateTime = new \DateTime('2010-06-02 Australia/Melbourne');
|
||||
|
||||
$form->setData($dateTime);
|
||||
|
||||
$this->assertDateTimeEquals($dateTime, $form->getData());
|
||||
$this->assertEquals('02.06.2010', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testSetDataWithSameNegativeUTCTimezoneDateTime()
|
||||
{
|
||||
date_default_timezone_set('America/New_York');
|
||||
|
||||
$form = $this->factory->create('date', null, array(
|
||||
'format' => \IntlDateFormatter::MEDIUM,
|
||||
'input' => 'datetime',
|
||||
'widget' => 'single_text',
|
||||
));
|
||||
|
||||
$dateTime = new \DateTime('2010-06-02 America/New_York');
|
||||
|
||||
$form->setData($dateTime);
|
||||
|
||||
$this->assertDateTimeEquals($dateTime, $form->getData());
|
||||
$this->assertEquals('02.06.2010', $form->getViewData());
|
||||
}
|
||||
|
||||
public function testYearsOption()
|
||||
{
|
||||
$form = $this->factory->create('date', null, array(
|
||||
|
Reference in New Issue
Block a user