DatePatternPluginTest.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\Form\Renderer\Plugin;
  11. use Symfony\Component\Form\Renderer\Plugin\DatePatternPlugin;
  12. class DatePatternPluginTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testen_US()
  15. {
  16. $intl = new \IntlDateFormatter("en_US" ,\IntlDateFormatter::SHORT, \IntlDateFormatter::NONE);
  17. $field = $this->getMock('Symfony\Tests\Component\Form\FormInterface');
  18. $renderer = $this->getMock('Symfony\Component\Form\Renderer\FormRendererInterface');
  19. $renderer->expects($this->once())
  20. ->method('setVar')
  21. ->with($this->equalTo('date_pattern'), $this->equalTo('{{ month }}/{{ day }}/{{ year }}'));
  22. $plugin = new DatePatternPlugin($intl);
  23. $plugin->setUp($field, $renderer);
  24. }
  25. public function testen_GB()
  26. {
  27. $intl = new \IntlDateFormatter("en_GB" ,\IntlDateFormatter::SHORT, \IntlDateFormatter::NONE);
  28. $field = $this->getMock('Symfony\Tests\Component\Form\FormInterface');
  29. $renderer = $this->getMock('Symfony\Component\Form\Renderer\FormRendererInterface');
  30. $renderer->expects($this->once())
  31. ->method('setVar')
  32. ->with($this->equalTo('date_pattern'), $this->equalTo('{{ day }}/{{ month }}/{{ year }}'));
  33. $plugin = new DatePatternPlugin($intl);
  34. $plugin->setUp($field, $renderer);
  35. }
  36. public function testde_DE()
  37. {
  38. $intl = new \IntlDateFormatter("de_DE" ,\IntlDateFormatter::SHORT, \IntlDateFormatter::NONE);
  39. $field = $this->getMock('Symfony\Tests\Component\Form\FormInterface');
  40. $renderer = $this->getMock('Symfony\Component\Form\Renderer\FormRendererInterface');
  41. $renderer->expects($this->once())
  42. ->method('setVar')
  43. ->with($this->equalTo('date_pattern'), $this->equalTo('{{ day }}.{{ month }}.{{ year }}'));
  44. $plugin = new DatePatternPlugin($intl);
  45. $plugin->setUp($field, $renderer);
  46. }
  47. public function testDefault()
  48. {
  49. $intl = new \IntlDateFormatter("de_DE" ,\IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT);
  50. $field = $this->getMock('Symfony\Tests\Component\Form\FormInterface');
  51. $renderer = $this->getMock('Symfony\Component\Form\Renderer\FormRendererInterface');
  52. $renderer->expects($this->once())
  53. ->method('setVar')
  54. ->with($this->equalTo('date_pattern'), $this->equalTo('{{ year }}-{{ month }}-{{ day }}'));
  55. $plugin = new DatePatternPlugin($intl);
  56. $plugin->setUp($field, $renderer);
  57. }
  58. }