This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests/Symfony/Tests/Component/Form/PercentFieldTest.php
2010-08-20 23:09:55 +02:00

46 lines
1.1 KiB
PHP

<?php
namespace Symfony\Tests\Component\Form;
require_once __DIR__ . '/LocalizedTestCase.php';
use Symfony\Component\Form\PercentField;
class PercentFieldTest extends LocalizedTestCase
{
public function testRender()
{
$field = new PercentField('name');
$field->setLocale('de_DE');
$field->setData(0.12);
$html = '<input id="name" name="name" value="12" type="text" /> %';
$this->assertEquals($html, $field->render());
}
public function testRenderWithPrecision()
{
$field = new PercentField('name', array('precision' => 2));
$field->setLocale('de_DE');
$field->setData(0.1234);
$html = '<input id="name" name="name" value="12,34" type="text" /> %';
$this->assertEquals($html, $field->render());
}
public function testRenderWithInteger()
{
$field = new PercentField('name', array('type' => 'integer'));
$field->setLocale('de_DE');
$field->setData(123);
$html = '<input id="name" name="name" value="123" type="text" /> %';
$this->assertEquals($html, $field->render());
}
}