mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-18 13:26:37 +00:00
Fix tests
This commit is contained in:
@@ -16,7 +16,7 @@ use Twig\Extra\Cache\TokenParser\CacheTokenParser;
|
|||||||
|
|
||||||
final class CacheExtension extends AbstractExtension
|
final class CacheExtension extends AbstractExtension
|
||||||
{
|
{
|
||||||
public function getTokenParsers()
|
public function getTokenParsers(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new CacheTokenParser(),
|
new CacheTokenParser(),
|
||||||
|
|||||||
@@ -78,11 +78,9 @@ class FunctionalTest extends TestCase
|
|||||||
$this->cache = $cache;
|
$this->cache = $cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load($class)
|
public function load(string $class): ?object
|
||||||
{
|
{
|
||||||
if (CacheRuntime::class === $class) {
|
return CacheRuntime::class === $class ? new CacheRuntime($this->cache) : null;
|
||||||
return new CacheRuntime($this->cache);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -30,11 +30,9 @@ class IntegrationTest extends IntegrationTestCase
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new class() implements RuntimeLoaderInterface {
|
new class() implements RuntimeLoaderInterface {
|
||||||
public function load($class)
|
public function load(string $class): ?object
|
||||||
{
|
{
|
||||||
if (CacheRuntime::class === $class) {
|
return CacheRuntime::class === $class ? new CacheRuntime(new ArrayAdapter()) : null;
|
||||||
return new CacheRuntime(new ArrayAdapter());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use Twig\TwigFilter;
|
|||||||
|
|
||||||
class CssInlinerExtension extends AbstractExtension
|
class CssInlinerExtension extends AbstractExtension
|
||||||
{
|
{
|
||||||
public function getFilters()
|
public function getFilters(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new TwigFilter('inline_css', [self::class, 'inlineCss'], ['is_safe' => ['all']]),
|
new TwigFilter('inline_css', [self::class, 'inlineCss'], ['is_safe' => ['all']]),
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use Twig\TwigFilter;
|
|||||||
|
|
||||||
class InkyExtension extends AbstractExtension
|
class InkyExtension extends AbstractExtension
|
||||||
{
|
{
|
||||||
public function getFilters()
|
public function getFilters(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new TwigFilter('inky_to_html', [self::class, 'inky'], ['is_safe' => ['html']]),
|
new TwigFilter('inky_to_html', [self::class, 'inky'], ['is_safe' => ['html']]),
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ final class IntlExtension extends AbstractExtension
|
|||||||
$this->numberFormatterPrototype = $numberFormatterPrototype;
|
$this->numberFormatterPrototype = $numberFormatterPrototype;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFilters()
|
public function getFilters(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// internationalized names
|
// internationalized names
|
||||||
@@ -177,7 +177,7 @@ final class IntlExtension extends AbstractExtension
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFunctions()
|
public function getFunctions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// internationalized names
|
// internationalized names
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use Twig\TwigFilter;
|
|||||||
|
|
||||||
final class MarkdownExtension extends AbstractExtension
|
final class MarkdownExtension extends AbstractExtension
|
||||||
{
|
{
|
||||||
public function getFilters()
|
public function getFilters(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new TwigFilter('markdown_to_html', ['Twig\\Extra\\Markdown\\MarkdownRuntime', 'convert'], ['is_safe' => ['all']]),
|
new TwigFilter('markdown_to_html', ['Twig\\Extra\\Markdown\\MarkdownRuntime', 'convert'], ['is_safe' => ['all']]),
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class FunctionalTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @dataProvider getMarkdownTests
|
* @dataProvider getMarkdownTests
|
||||||
*/
|
*/
|
||||||
public function testMarkdown(string $template, string $expected): void
|
public function testMarkdown(string $template, string $expected)
|
||||||
{
|
{
|
||||||
foreach ([LeagueMarkdown::class, ErusevMarkdown::class, /* MichelfMarkdown::class, */ DefaultMarkdown::class] as $class) {
|
foreach ([LeagueMarkdown::class, ErusevMarkdown::class, /* MichelfMarkdown::class, */ DefaultMarkdown::class] as $class) {
|
||||||
$twig = new Environment(new ArrayLoader([
|
$twig = new Environment(new ArrayLoader([
|
||||||
@@ -48,11 +48,9 @@ EOF
|
|||||||
$this->class = $class;
|
$this->class = $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load($c)
|
public function load(string $c): ?object
|
||||||
{
|
{
|
||||||
if (MarkdownRuntime::class === $c) {
|
return MarkdownRuntime::class === $c ? new $c(new $this->class()) : null;
|
||||||
return new $c(new $this->class());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$this->assertMatchesRegularExpression('{'.$expected.'}m', trim($twig->render('index')));
|
$this->assertMatchesRegularExpression('{'.$expected.'}m', trim($twig->render('index')));
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ final class StringExtension extends AbstractExtension
|
|||||||
$this->slugger = $slugger ?: new AsciiSlugger();
|
$this->slugger = $slugger ?: new AsciiSlugger();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFilters()
|
public function getFilters(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new TwigFilter('u', [$this, 'createUnicodeString']),
|
new TwigFilter('u', [$this, 'createUnicodeString']),
|
||||||
|
|||||||
Reference in New Issue
Block a user