Skip to content

Commit

Permalink
Load FormExtension for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Mar 5, 2023
1 parent 5395257 commit 25681ca
Show file tree
Hide file tree
Showing 3 changed files with 486 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/Pug/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Pug\Tests;

use Psr\Container\ContainerInterface;
use Pug\PugSymfonyEngine;
use Pug\Twig\Environment;
use Symfony\Bridge\Twig\Extension\CsrfExtension;
use Symfony\Bridge\Twig\Extension\CsrfRuntime;
use Symfony\Bridge\Twig\Extension\FormExtension;
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Filesystem\Filesystem;
Expand All @@ -15,7 +15,6 @@
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\RequestContext;
use Twig\Loader\FilesystemLoader;
use Twig\RuntimeLoader\ContainerRuntimeLoader;
use Twig\RuntimeLoader\FactoryRuntimeLoader;

abstract class AbstractTestCase extends KernelTestCase
Expand All @@ -35,6 +34,7 @@ protected function getTwigEnvironment(): Environment
__DIR__.'/../project-s5/templates/',
));
$this->twig->addExtension(new CsrfExtension());
$this->twig->addExtension(new FormExtension());
$this->twig->addRuntimeLoader(new FactoryRuntimeLoader([
CsrfRuntime::class => static fn () => new CsrfRuntime(new TestCsrfTokenManager()),
]));
Expand Down
6 changes: 0 additions & 6 deletions tests/project-s5/src/Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,12 @@
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormRenderer;
use Symfony\Component\Security\Csrf\CsrfTokenManager;
use Twig\Environment;
use Twig\RuntimeLoader\FactoryRuntimeLoader;

class DefaultController extends AbstractController
{
protected $twig;

// public function __construct(Environment $twig)
// {
// $this->twig = $twig;
// }

public function index()
{
$defaultFormTheme = 'form_div_layout.html.twig';
Expand Down
Loading

0 comments on commit 25681ca

Please sign in to comment.