MoneyFieldTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Symfony\Tests\Component\Form;
  3. require_once __DIR__ . '/LocalizedTestCase.php';
  4. use Symfony\Component\Form\MoneyField;
  5. class MoneyFieldTest extends LocalizedTestCase
  6. {
  7. public function testRenderWithoutCurrency()
  8. {
  9. $field = new MoneyField('name');
  10. $field->setLocale('de_AT');
  11. $field->setData(1234);
  12. $html = '<input id="name" name="name" value="1234,00" type="text" class="foobar" />';
  13. $this->assertEquals($html, $field->render(array('class' => 'foobar')));
  14. }
  15. public function testRenderWithCurrency_afterWidget()
  16. {
  17. $field = new MoneyField('name', array('currency' => 'EUR'));
  18. $field->setLocale('de_DE');
  19. $field->setData(1234);
  20. $html = '<input id="name" name="name" value="1234,00" type="text" /> €';
  21. $this->assertEquals($html, $field->render());
  22. }
  23. public function testRenderWithCurrency_beforeWidget()
  24. {
  25. $field = new MoneyField('name', array('currency' => 'EUR'));
  26. $field->setLocale('en_US');
  27. $field->setData(1234);
  28. $html = '€ <input id="name" name="name" value="1234.00" type="text" />';
  29. $this->assertEquals($html, $field->render());
  30. }
  31. }