2010-06-24 09:40:05 +01:00
|
|
|
<?php
|
|
|
|
|
2010-08-20 22:09:55 +01:00
|
|
|
namespace Symfony\Tests\Component\Form;
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-08-20 22:09:55 +01:00
|
|
|
use Symfony\Component\Form\PasswordField;
|
2010-06-24 09:40:05 +01:00
|
|
|
|
|
|
|
class PasswordFieldTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
2010-06-24 10:24:08 +01:00
|
|
|
public function testRender()
|
|
|
|
{
|
|
|
|
$field = new PasswordField('name');
|
|
|
|
$field->setData('asdf');
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
$html = '<input id="name" name="name" value="" type="password" class="foobar" />';
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
$this->assertEquals($html, $field->render(array('class' => 'foobar')));
|
|
|
|
}
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
// when the user made an error in the form, display the value in the field
|
|
|
|
public function testRenderAfterBinding()
|
|
|
|
{
|
|
|
|
$field = new PasswordField('name');
|
|
|
|
$field->bind('asdf');
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
$html = '<input id="name" name="name" value="asdf" type="password" />';
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
$this->assertEquals($html, $field->render());
|
|
|
|
}
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
public function testRenderNotAlwaysEmpty()
|
|
|
|
{
|
|
|
|
$field = new PasswordField('name', array('always_empty' => false));
|
|
|
|
$field->setData('asdf');
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
$html = '<input id="name" name="name" value="asdf" type="password" />';
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
$this->assertEquals($html, $field->render());
|
|
|
|
}
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
public function testRenderNotAlwaysEmptyAfterBinding()
|
|
|
|
{
|
|
|
|
$field = new PasswordField('name', array('always_empty' => false));
|
|
|
|
$field->bind('asdf');
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
$html = '<input id="name" name="name" value="asdf" type="password" />';
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
$this->assertEquals($html, $field->render());
|
|
|
|
}
|
2010-06-24 09:40:05 +01:00
|
|
|
}
|