[extra-bundle] add integration tests

This commit is contained in:
Kevin Bond
2022-01-03 16:46:28 -05:00
parent 09c7f7dd9c
commit 5c63486adf
5 changed files with 66 additions and 0 deletions
+1
View File
@@ -1,4 +1,5 @@
vendor/
var/
composer.lock
phpunit.xml
.phpunit.result.cache
@@ -0,0 +1,42 @@
<?php
namespace Twig\Extra\TwigExtraBundle\Tests\Fixture;
use League\CommonMark\Extension\Strikethrough\StrikethroughExtension;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Twig\Extra\TwigExtraBundle\TwigExtraBundle;
class Kernel extends BaseKernel
{
use MicroKernelTrait;
public function registerBundles(): iterable
{
yield new FrameworkBundle();
yield new TwigBundle();
yield new TwigExtraBundle();
}
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader): void
{
$c->loadFromExtension('framework', [
'secret' => 'S3CRET',
'test' => true,
]);
$c->loadFromExtension('twig', [
'default_path' => __DIR__.'/views',
]);
$c->register(StrikethroughExtension::class)->addTag('twig.markdown.league_extension');
}
protected function configureRoutes($routes): void
{
}
}
@@ -0,0 +1,3 @@
{% apply markdown_to_html %}
# Hello ~~World~~
{% endapply %}
@@ -0,0 +1,18 @@
<?php
namespace Twig\Extra\TwigExtraBundle\Tests;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class IntegrationTest extends KernelTestCase
{
public function testCommonMarkRendering()
{
self::bootKernel();
$container = method_exists(self::class, 'getContainer') ? self::getContainer() : self::$container;
$rendered = $container->get('twig')->render('markdown_to_html.html.twig');
$this->assertStringContainsString('<h1>Hello <del>World</del></h1>', $rendered);
}
}
+2
View File
@@ -10,6 +10,8 @@
>
<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_CLASS" value="Twig\Extra\TwigExtraBundle\Tests\Fixture\Kernel" />
<server name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=0"/>
</php>
<testsuites>