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/Components/Form/PercentFieldTest.php

46 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace Symfony\Tests\Components\Form;
require_once __DIR__ . '/LocalizedTestCase.php';
use Symfony\Components\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());
}
}