FormExtensionTableLayoutTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.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\Bridge\Twig\Extension;
  11. require_once __DIR__.'/Fixtures/StubTranslator.php';
  12. use Symfony\Component\Form\FormInterface;
  13. use Symfony\Bridge\Twig\Extension\FormExtension;
  14. use Symfony\Bridge\Twig\Extension\TranslationExtension;
  15. use Symfony\Tests\Component\Form\AbstractTableLayoutTest;
  16. use Symfony\Tests\Bridge\Twig\Extension\Fixtures\StubTranslator;
  17. class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
  18. {
  19. protected function setUp()
  20. {
  21. parent::setUp();
  22. $loader = new \Twig_Loader_Filesystem(array(
  23. __DIR__.'/../../../../../../src/Symfony/Bundle/TwigBundle/Resources/views',
  24. ));
  25. $this->extension = new FormExtension(array('table_layout.html.twig'));
  26. $environment = new \Twig_Environment($loader);
  27. $environment->addExtension($this->extension);
  28. $environment->addExtension(new TranslationExtension(new StubTranslator()));
  29. $this->extension->initRuntime($environment);
  30. }
  31. protected function renderEnctype(FormInterface $form)
  32. {
  33. return (string)$this->extension->renderEnctype($form->getContext());
  34. }
  35. protected function renderLabel(FormInterface $form, $label = null)
  36. {
  37. return (string)$this->extension->renderLabel($form->getContext(), $label);
  38. }
  39. protected function renderErrors(FormInterface $form)
  40. {
  41. return (string)$this->extension->renderErrors($form->getContext());
  42. }
  43. protected function renderWidget(FormInterface $form, array $vars = array())
  44. {
  45. return (string)$this->extension->renderWidget($form->getContext(), $vars);
  46. }
  47. protected function renderRow(FormInterface $form, array $vars = array())
  48. {
  49. return (string)$this->extension->renderRow($form->getContext(), $vars);
  50. }
  51. protected function renderRest(FormInterface $form, array $vars = array())
  52. {
  53. return (string)$this->extension->renderRest($form->getContext(), $vars);
  54. }
  55. }