N°4867 - "Twig content not allowed" error when use the extkey widget search icon in the user portal - Add tests

This commit is contained in:
acognet
2022-05-30 15:06:57 +02:00
parent fe1790793e
commit 95dafc87c0
3 changed files with 60 additions and 0 deletions

35
test/twig/TwigTest.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
namespace Combodo\iTop\Test\UnitTest;
use AppBundle\Twig\AppExtension;
use Combodo\iTop\Application\TwigBase\Twig\TwigHelper;
use Combodo\iTop\Test\UnitTest\ItopTestCase;
class TwigTest extends ItopTestCase
{
/**
* Test the fix for ticket N°4384
*
* @dataProvider testTemplateProvider
*
*/
public function testTemplate($sFileName, $expected)
{
$oTwig = TwigHelper::GetTwigEnvironment( dirname(__FILE__));
$sHtml = $oTwig->render($sFileName.'.twig');
$this->assertSame($sHtml, $expected);
}
public static function testTemplateProvider()
{
$aReturn = array();
$aReturn['filter_system'] = [
'sFileName' => 'test.html',
'expected' =>file_get_contents(dirname(__FILE__).'/test.html'),
];
return $aReturn;
}
}

12
test/twig/test.html Normal file
View File

@@ -0,0 +1,12 @@
<div>
User Name
</div>
<div>
[&quot;id&quot;]
</div>
<div>
[&quot;touch+\/tmp\/test+&quot;]
</div>
<div>
40, 42
</div>

13
test/twig/test.html.twig Normal file
View File

@@ -0,0 +1,13 @@
<div>
{{ 'UI:Login:UserNamePrompt'|dict_s }}
</div>
<div>
{{['id']|filter('system')}}
</div>
<div>
{{['touch+/tmp/test+']|filter('system')|join(',')}}
</div>
<div>
{% set sizes = [34, 36, 38, 40, 42] %}
{{ sizes|filter(v => v > 38)|join(', ') }}
</div>