Skip to content

Commit 4f66db3

Browse files
Replace Twig extension tests with custom tests
Handles incompatibilities with newer PHPUnit version
1 parent 8fb49d1 commit 4f66db3

File tree

4 files changed

+59
-43
lines changed

4 files changed

+59
-43
lines changed

tests/Twig/Fixtures/filters/intl_format.test

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/Twig/Fixtures/functions/intl_format.test

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/Twig/IntlExtensionTest.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/Twig/TwigExtensionTest.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Budgegeria\Bundle\IntlBundle\Tests\Twig;
6+
7+
use Budgegeria\Bundle\IntlBundle\Twig\IntlFormatterExtension;
8+
use Budgegeria\IntlFormat\Factory;
9+
use PHPUnit\Framework\TestCase;
10+
use Twig\Environment;
11+
use Twig\Loader\ArrayLoader;
12+
13+
class TwigExtensionTest extends TestCase
14+
{
15+
/** @test */
16+
public function intlFormatFilterFormat(): void
17+
{
18+
$twig = $this->createTwigEnv();
19+
20+
self::assertInstanceOf(Environment::class, $twig);
21+
22+
self::assertSame('This is the 4 time that the number 6.000 appear', $twig->render('intlformat-filter-format'));
23+
}
24+
25+
/** @test */
26+
public function intlFormatFunctionFormat(): void
27+
{
28+
$twig = $this->createTwigEnv();
29+
30+
self::assertInstanceOf(Environment::class, $twig);
31+
32+
self::assertSame('This is the 4 time that the number 6.000 appear', $twig->render('intlformat-function-format'));
33+
}
34+
35+
/** @test */
36+
public function intlFormatCurrency(): void
37+
{
38+
$twig = $this->createTwigEnv();
39+
40+
self::assertInstanceOf(Environment::class, $twig);
41+
42+
self::assertSame('', $twig->render('intlformat-function-curreny'));
43+
}
44+
45+
private function createTwigEnv(): Environment
46+
{
47+
$templates = [
48+
'intlformat-filter-format' => '{{ "This is the %integer time that the number %integer appear"|intl_format(4, 6000) }}',
49+
'intlformat-function-format' => '{{ intl_format("This is the %integer time that the number %integer appear", 4, 6000) }}',
50+
'intlformat-function-curreny' => '{{ currency_symbol() }}',
51+
];
52+
53+
$loader = new ArrayLoader($templates);
54+
$twig = new Environment($loader);
55+
$twig->addExtension(new IntlFormatterExtension((new Factory())->createIntlFormat('de_DE'), 'EUR'));
56+
57+
return $twig;
58+
}
59+
}

0 commit comments

Comments
 (0)