Skip to content

Commit f026e4b

Browse files
committed
Add small twig test
1 parent f231bf0 commit f026e4b

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

tests/Twig/ExtensionTest.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
--TEST--
2+
"editorjs_render" should return empty string
3+
--TEMPLATE--
4+
{{ null|editorjs_render }}
5+
--DATA--
6+
return []
7+
--EXPECT--

0 commit comments

Comments
 (0)