MoneyFieldTest.php 1.3 KB

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