mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
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:
35
test/twig/TwigTest.php
Normal file
35
test/twig/TwigTest.php
Normal 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
12
test/twig/test.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<div>
|
||||
User Name
|
||||
</div>
|
||||
<div>
|
||||
["id"]
|
||||
</div>
|
||||
<div>
|
||||
["touch+\/tmp\/test+"]
|
||||
</div>
|
||||
<div>
|
||||
40, 42
|
||||
</div>
|
||||
13
test/twig/test.html.twig
Normal file
13
test/twig/test.html.twig
Normal 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>
|
||||
Reference in New Issue
Block a user