FormExtensionTableLayoutTest.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. require_once __DIR__.'/Fixtures/StubFilesystemLoader.php';
  13. use Symfony\Component\Form\TemplateContext;
  14. use Symfony\Bridge\Twig\Extension\FormExtension;
  15. use Symfony\Bridge\Twig\Extension\TranslationExtension;
  16. use Symfony\Tests\Component\Form\AbstractTableLayoutTest;
  17. use Symfony\Tests\Bridge\Twig\Extension\Fixtures\StubTranslator;
  18. use Symfony\Tests\Bridge\Twig\Extension\Fixtures\StubFilesystemLoader;
  19. class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
  20. {
  21. protected function setUp()
  22. {
  23. parent::setUp();
  24. $loader = new StubFilesystemLoader(array(
  25. __DIR__.'/../../../../../../src/Symfony/Bundle/TwigBundle/Resources/views',
  26. ));
  27. $this->extension = new FormExtension(array('table_layout.html.twig'));
  28. $environment = new \Twig_Environment($loader);
  29. $environment->addExtension($this->extension);
  30. $environment->addExtension(new TranslationExtension(new StubTranslator()));
  31. $this->extension->initRuntime($environment);
  32. }
  33. protected function renderEnctype(TemplateContext $context)
  34. {
  35. return (string)$this->extension->renderEnctype($context);
  36. }
  37. protected function renderLabel(TemplateContext $context, $label = null)
  38. {
  39. return (string)$this->extension->renderLabel($context, $label);
  40. }
  41. protected function renderErrors(TemplateContext $context)
  42. {
  43. return (string)$this->extension->renderErrors($context);
  44. }
  45. protected function renderWidget(TemplateContext $context, array $vars = array())
  46. {
  47. return (string)$this->extension->renderWidget($context, $vars);
  48. }
  49. protected function renderRow(TemplateContext $context, array $vars = array())
  50. {
  51. return (string)$this->extension->renderRow($context, $vars);
  52. }
  53. protected function renderRest(TemplateContext $context, array $vars = array())
  54. {
  55. return (string)$this->extension->renderRest($context, $vars);
  56. }
  57. }