Skip to content

Commit

Permalink
[Form] Added tests to check that the date format option is validated …
Browse files Browse the repository at this point in the history
…correctly

 * Format option must be either a IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) or a string
  • Loading branch information
maoueh committed Jun 3, 2011
1 parent a815232 commit 0045ffe
Showing 1 changed file with 38 additions and 0 deletions.
Expand Up @@ -250,6 +250,44 @@ public function testSubmitFromInputRawDifferentPattern()
$this->assertEquals('06*2010*02', $form->getClientData());
}

/**
* This test is to check that the strings '0', '1', '2', '3' are no accepted
* as valid IntlDateFormatter constants for FULL, LONG, MEDIUM or SHORT respectively.
*/
public function testFormatOptionCustomPatternCollapsingIntlDateFormatterConstant()
{
$form = $this->factory->create('date', null, array(
'format' => '0',
'widget' => 'single-text',
'input' => 'string',
));

$form->setData('2010-06-02');

// This would be what would be outputed if '0' was mistaken for \IntlDateFormatter::FULL
$this->assertNotEquals('Mittwoch, 02. Juni 2010', $form->getClientData());
}

/**
* @expectedException Symfony\Component\Form\Exception\FormException
*/
public function testValidateFormatOptionGivenWrongConstants()
{
$form = $this->factory->create('date', null, array(
'format' => 105,
));
}

/**
* @expectedException Symfony\Component\Form\Exception\FormException
*/
public function testValidateFormatOptionGivenArrayValue()
{
$form = $this->factory->create('date', null, array(
'format' => array(),
));
}

public function testSetData_differentTimezones()
{
$form = $this->factory->create('date', null, array(
Expand Down

0 comments on commit 0045ffe

Please sign in to comment.