29 lines
761 B
PHP
29 lines
761 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use App\Template\Twig;
|
|
use Twig\TwigFilter;
|
|
|
|
final class TwigTest extends \PHPUnit\Framework\TestCase
|
|
{
|
|
public function testInstance(): void
|
|
{
|
|
$obj = new Twig(['template' => 'start {{ var }} end']);
|
|
$template = $obj->load('template');
|
|
$output = $template->render(['var' => 'middle']);
|
|
$this->assertEquals('start middle end', $output);
|
|
}
|
|
|
|
public function testExtensionsLoaded(): void
|
|
{
|
|
$obj = new Twig(['template' => 'start {{ var | formatBytes}} end']);
|
|
$template = $obj->load('template');
|
|
$output = $template->render(['var' => 1]);
|
|
$this->assertEquals('start 1.00B end', $output);
|
|
}
|
|
}
|