|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Setono\EditorJSBundle\Tests\Twig; |
| 6 | + |
| 7 | +use Prophecy\PhpUnit\ProphecyTrait; |
| 8 | +use Setono\EditorJS\Parser\ParserInterface; |
| 9 | +use Setono\EditorJS\Renderer\RendererInterface; |
| 10 | +use Setono\EditorJSBundle\Twig\Extension; |
| 11 | +use Setono\EditorJSBundle\Twig\Runtime; |
| 12 | +use Twig\RuntimeLoader\RuntimeLoaderInterface; |
| 13 | +use Twig\Test\IntegrationTestCase; |
| 14 | +use Webmozart\Assert\Assert; |
| 15 | + |
| 16 | +final class ExtensionTest extends IntegrationTestCase |
| 17 | +{ |
| 18 | + use ProphecyTrait; |
| 19 | + |
| 20 | + public function getRuntimeLoaders(): array |
| 21 | + { |
| 22 | + $parser = $this->prophesize(ParserInterface::class); |
| 23 | + $renderer = $this->prophesize(RendererInterface::class); |
| 24 | + |
| 25 | + $runtimeLoader = new class($parser->reveal(), $renderer->reveal()) implements RuntimeLoaderInterface { |
| 26 | + public function __construct( |
| 27 | + private readonly ParserInterface $parser, |
| 28 | + private readonly RendererInterface $renderer, |
| 29 | + ) { |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * @param string $class |
| 34 | + */ |
| 35 | + public function load($class): Runtime |
| 36 | + { |
| 37 | + Assert::same($class, Runtime::class); |
| 38 | + |
| 39 | + return new Runtime($this->parser, $this->renderer); |
| 40 | + } |
| 41 | + }; |
| 42 | + |
| 43 | + return [$runtimeLoader]; |
| 44 | + } |
| 45 | + |
| 46 | + public function getExtensions(): array |
| 47 | + { |
| 48 | + return [ |
| 49 | + new Extension(), |
| 50 | + ]; |
| 51 | + } |
| 52 | + |
| 53 | + protected function getFixturesDir(): string |
| 54 | + { |
| 55 | + return __DIR__ . '/Fixtures/'; |
| 56 | + } |
| 57 | +} |
0 commit comments