DatePatternPluginTest.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. protected function setUp()
  15. {
  16. $this->markTestSkipped('Move me to Type tests');
  17. }
  18. public function testen_US()
  19. {
  20. $intl = new \IntlDateFormatter("en_US" ,\IntlDateFormatter::SHORT, \IntlDateFormatter::NONE);
  21. $form = $this->getMock('Symfony\Tests\Component\Form\FormInterface');
  22. $renderer = $this->getMock('Symfony\Component\Form\Renderer\FormRendererInterface');
  23. $renderer->expects($this->once())
  24. ->method('setVar')
  25. ->with($this->equalTo('date_pattern'), $this->equalTo('{{ month }}/{{ day }}/{{ year }}'));
  26. $plugin = new DatePatternPlugin($intl);
  27. $plugin->setUp($form, $renderer);
  28. }
  29. public function testen_GB()
  30. {
  31. $intl = new \IntlDateFormatter("en_GB" ,\IntlDateFormatter::SHORT, \IntlDateFormatter::NONE);
  32. $form = $this->getMock('Symfony\Tests\Component\Form\FormInterface');
  33. $renderer = $this->getMock('Symfony\Component\Form\Renderer\FormRendererInterface');
  34. $renderer->expects($this->once())
  35. ->method('setVar')
  36. ->with($this->equalTo('date_pattern'), $this->equalTo('{{ day }}/{{ month }}/{{ year }}'));
  37. $plugin = new DatePatternPlugin($intl);
  38. $plugin->setUp($form, $renderer);
  39. }
  40. public function testde_DE()
  41. {
  42. $intl = new \IntlDateFormatter("de_DE" ,\IntlDateFormatter::SHORT, \IntlDateFormatter::NONE);
  43. $form = $this->getMock('Symfony\Tests\Component\Form\FormInterface');
  44. $renderer = $this->getMock('Symfony\Component\Form\Renderer\FormRendererInterface');
  45. $renderer->expects($this->once())
  46. ->method('setVar')
  47. ->with($this->equalTo('date_pattern'), $this->equalTo('{{ day }}.{{ month }}.{{ year }}'));
  48. $plugin = new DatePatternPlugin($intl);
  49. $plugin->setUp($form, $renderer);
  50. }
  51. public function testDefault()
  52. {
  53. $intl = new \IntlDateFormatter("de_DE" ,\IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT);
  54. $form = $this->getMock('Symfony\Tests\Component\Form\FormInterface');
  55. $renderer = $this->getMock('Symfony\Component\Form\Renderer\FormRendererInterface');
  56. $renderer->expects($this->once())
  57. ->method('setVar')
  58. ->with($this->equalTo('date_pattern'), $this->equalTo('{{ year }}-{{ month }}-{{ day }}'));
  59. $plugin = new DatePatternPlugin($intl);
  60. $plugin->setUp($form, $renderer);
  61. }
  62. }