Files
piratepoet/mailpoet/tests/integration/Twig/FunctionsTest.php
Jan Lysý 1e0878cf6c Update twig/twig package to v3
[MAILPOET-4227]
2022-04-27 08:57:54 +02:00

29 lines
817 B
PHP

<?php
namespace MailPoet\Test\Twig;
use Codeception\Util\Stub;
use MailPoet\Twig\Functions;
use MailPoet\WP\Functions as WPFunctions;
use MailPoetVendor\Twig\Environment;
class FunctionsTest extends \MailPoetTest {
public function testItExecutesIsRtlFunction() {
$template = ['template' => '{% if is_rtl() %}rtl{% endif %}'];
$twig = new Environment(new \MailPoetVendor\Twig\Loader\ArrayLoader($template));
WPFunctions::set(Stub::make(new WPFunctions, [
'isRtl' => Stub::consecutive(true, false),
]));
$twig->addExtension(new Functions());
$resultRtl = $twig->render('template');
expect($resultRtl)->equals('rtl');
$resultNoRtl = $twig->render('template');
expect($resultNoRtl)->isEmpty();
}
public function _after() {
WPFunctions::set(new WPFunctions);
}
}