Skip to content

Commit

Permalink
[Form] Added test for 'email' type and fixed a few bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
webmozart committed Apr 18, 2011
1 parent 23e9ad7 commit 5772255
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Expand Up @@ -2,6 +2,7 @@
<?php echo $view['form']->attributes() ?>
name="<?php echo $view->escape($name) ?>"
value="<?php echo $view->escape($value) ?>"
<?php if ($max_length): ?>maxlength="<?php echo $view->escape($max_length) ?>"<?php endif ?>
<?php if ($read_only): ?>disabled="disabled"<?php endif ?>
<?php if ($required): ?>required="required"<?php endif ?>
/>
Expand Up @@ -32,6 +32,7 @@ public function __construct(
new Type\CountryType(),
new Type\DateType(),
new Type\DateTimeType(),
new Type\EmailType(),
new Type\HiddenType(),
new Type\IntegerType(),
new Type\LanguageType(),
Expand Down
35 changes: 35 additions & 0 deletions tests/Symfony/Tests/Component/Form/AbstractLayoutTest.php
Expand Up @@ -603,6 +603,41 @@ public function testDateText()
);
}

public function testEmail()
{
$form = $this->factory->create('email', 'na&me', array(
'property_path' => 'name',
'data' => 'foo&bar',
));

$this->assertWidgetMatchesXpath($form->createView(), array(),
'/input
[@type="email"]
[@name="na&me"]
[@value="foo&bar"]
[not(@maxlength)]
'
);
}

public function testEmailWithMaxLength()
{
$form = $this->factory->create('email', 'na&me', array(
'property_path' => 'name',
'data' => 'foo&bar',
'max_length' => 123,
));

$this->assertWidgetMatchesXpath($form->createView(), array(),
'/input
[@type="email"]
[@name="na&me"]
[@value="foo&bar"]
[@maxlength="123"]
'
);
}

public function testFile()
{
$form = $this->factory->create('file', 'na&me', array('property_path' => 'name'));
Expand Down

0 comments on commit 5772255

Please sign in to comment.