-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathShortcodeExtensionTest.php
More file actions
36 lines (28 loc) · 1004 Bytes
/
ShortcodeExtensionTest.php
File metadata and controls
36 lines (28 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace Webfactory\ShortcodeBundle\Tests\Functional;
use PHPUnit\Framework\Attributes\Test;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* Test that integration with Twig works as expected.
*/
class ShortcodeExtensionTest extends KernelTestCase
{
#[Test]
public function resolve_placeholder_shortcode_in_twig(): void
{
self::assertSame('News from year 1970.', $this->renderTemplate('{% apply shortcodes %}[placeholder year=1970]News from year %year%.[/placeholder]{% endapply %}'));
}
#[Test]
public function filter_returns_safe_html(): void
{
self::assertSame('<p>HTML</p>', $this->renderTemplate('{{ "<p>HTML</p>" | shortcodes }}'));
}
private function renderTemplate(string $template): string
{
self::bootKernel();
$container = static::getContainer();
$twig = $container->get('twig');
$template = $twig->createTemplate($template);
return $twig->render($template);
}
}