2010-06-24 09:40:05 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Symfony\Tests\Components\Form;
|
|
|
|
|
|
|
|
require_once __DIR__ . '/../../../../bootstrap.php';
|
2010-06-24 10:39:05 +01:00
|
|
|
require_once __DIR__ . '/LocalizedTestCase.php';
|
2010-06-24 09:40:05 +01:00
|
|
|
|
|
|
|
use Symfony\Components\Form\MoneyField;
|
|
|
|
|
2010-06-24 10:39:05 +01:00
|
|
|
class MoneyFieldTest extends LocalizedTestCase
|
2010-06-24 09:40:05 +01:00
|
|
|
{
|
2010-06-24 10:24:08 +01:00
|
|
|
public function testRenderWithoutCurrency()
|
|
|
|
{
|
|
|
|
$field = new MoneyField('name');
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
$field->setLocale('de_AT');
|
|
|
|
$field->setData(1234);
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
$html = '<input id="name" name="name" value="1234,00" type="text" 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
|
|
|
public function testRenderWithCurrency_afterWidget()
|
|
|
|
{
|
|
|
|
$field = new MoneyField('name', array('currency' => 'EUR'));
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
$field->setLocale('de_DE');
|
|
|
|
$field->setData(1234);
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
$html = '<input id="name" name="name" value="1234,00" type="text" /> €';
|
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 testRenderWithCurrency_beforeWidget()
|
|
|
|
{
|
|
|
|
$field = new MoneyField('name', array('currency' => 'EUR'));
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
$field->setLocale('en_US');
|
|
|
|
$field->setData(1234);
|
2010-06-24 09:40:05 +01:00
|
|
|
|
2010-06-24 10:24:08 +01:00
|
|
|
$html = '€ <input id="name" name="name" value="1234.00" type="text" />';
|
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
|
|
|
}
|