Skip to content

Commit

Permalink
minor #12843 [Form] Add further timezone tests for date type (McSimp)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.6 branch.

Discussion
----------

[Form] Add further timezone tests for date type

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | no (failing tests added)
| Fixed tickets | Adds tests for bug in #12808
| License       | MIT
| Doc PR        | ~

#12404 removed the timezone options from DateType and TimeType, however the tests don't cover all cases and there was a bug introduced as per #12808.

This PR adds tests for the expected behaviour but will not fix the bug.

Unfortunately, it seems that the tests are being skipped in the form component on Travis (and have been for a year) - probably due to the ICU version being changed.

Commits
-------

f919793 [Form] Add further timezone tests for date type
  • Loading branch information
fabpot committed Dec 29, 2014
2 parents d0d4482 + f919793 commit 90378ab
Showing 1 changed file with 55 additions and 1 deletion.
Expand Up @@ -355,7 +355,7 @@ public function testThrowExceptionIfDaysIsInvalid()
));
}

public function testSetDataWithDifferentTimezoneDateTime()
public function testSetDataWithDifferentNegativeUTCTimezoneDateTime()
{
date_default_timezone_set('Pacific/Tahiti');

Expand All @@ -373,6 +373,60 @@ public function testSetDataWithDifferentTimezoneDateTime()
$this->assertEquals('02.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(
Expand Down

0 comments on commit 90378ab

Please sign in to comment.