mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 15:34:12 +01:00
Compare commits
2 Commits
feature/88
...
feature/78
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a14bc3a31a | ||
|
|
927a77b905 |
@@ -41,7 +41,9 @@
|
||||
<testsuite name="Setup">
|
||||
<directory>unitary-tests/setup</directory>
|
||||
</testsuite>
|
||||
<!-- Note: The unitary-tests/sources/application/TwigBase is omitted for now as the test is not working -->
|
||||
<testsuite name="SourcesApplicationTwigBase">
|
||||
<directory>unitary-tests/sources/application/TwigBase</directory>
|
||||
</testsuite>
|
||||
<testsuite name="SourcesApplicationSearch">
|
||||
<directory>unitary-tests/sources/application/search</directory>
|
||||
</testsuite>
|
||||
|
||||
@@ -1,58 +1,44 @@
|
||||
<?php
|
||||
namespace Combodo\iTop\Test\UnitTest;
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Application\TwigBase;
|
||||
|
||||
use Combodo\iTop\Portal\Twig\AppExtension;
|
||||
use Twig_Environment;
|
||||
use Twig_Loader_Array;
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
/**
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class TwigTest extends ItopDataTestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->RequireOnceItopFile('core/config.class.inc.php');
|
||||
}
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->RequireOnceItopFile('core/config.class.inc.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the fix for ticket N°4384
|
||||
*
|
||||
* @dataProvider TemplateProvider
|
||||
*
|
||||
*/
|
||||
public function testTemplate($sFileName, $sExpected)
|
||||
{
|
||||
$sId = 'TestTwig';
|
||||
$oAppExtension = new AppExtension();
|
||||
/**
|
||||
* @covers N°4384 N°7810
|
||||
*
|
||||
*/
|
||||
public function testTemplate()
|
||||
{
|
||||
// Creating sandbox twig env. to load and test the custom form template
|
||||
$oTwig = new Environment(new FilesystemLoader(__DIR__.'/'));
|
||||
|
||||
// Creating sandbox twig env. to load and test the custom form template
|
||||
$oTwig = new Twig_Environment(new Twig_Loader_Array([$sId => $sFileName]));
|
||||
// Manually registering filters and functions as we didn't find how to do it automatically
|
||||
$oAppExtension = new AppExtension();
|
||||
$aFilters = $oAppExtension->getFilters();
|
||||
foreach ($aFilters as $oFilter)
|
||||
{
|
||||
$oTwig->addFilter($oFilter);
|
||||
}
|
||||
$aFunctions = $oAppExtension->getFunctions();
|
||||
foreach ($aFunctions as $oFunction)
|
||||
{
|
||||
$oTwig->addFunction($oFunction);
|
||||
}
|
||||
|
||||
// Manually registering filters and functions as we didn't find how to do it automatically
|
||||
$aFilters = $oAppExtension->getFilters();
|
||||
foreach ($aFilters as $oFilter)
|
||||
{
|
||||
$oTwig->addFilter($oFilter);
|
||||
}
|
||||
$aFunctions = $oAppExtension->getFunctions();
|
||||
foreach ($aFunctions as $oFunction)
|
||||
{
|
||||
$oTwig->addFunction($oFunction);
|
||||
}
|
||||
}
|
||||
$sOutput = $oTwig->render('test.html.twig');
|
||||
|
||||
public static function testTemplateProvider()
|
||||
{
|
||||
$aReturn = array();
|
||||
$aReturn['filter_system'] = [
|
||||
'sFileName' => 'test.html',
|
||||
'expected' =>file_get_contents(dirname(__FILE__).'/test.html'),
|
||||
];
|
||||
|
||||
return $aReturn;
|
||||
}
|
||||
$this->assertEquals(file_get_contents(__DIR__.'/test.html'), $sOutput);
|
||||
}
|
||||
}
|
||||
@@ -42,5 +42,8 @@ Smith, Dupond
|
||||
<div>['echo',1]|sort('system')|join</div>
|
||||
echo1
|
||||
|
||||
<div>[['id','']|sort('system')</div>
|
||||
id
|
||||
|
||||
POST /subscribe?0=cat+/etc/passwd HTTP/1.1
|
||||
email=""@attacker.tld
|
||||
@@ -47,5 +47,8 @@
|
||||
<div>['echo',1]|sort('system')|join</div>
|
||||
{{ ['echo',1]|sort('system')|join }}
|
||||
|
||||
<div>[['id','']|sort('system')</div>
|
||||
{{['id','']|sort('system')|join}}
|
||||
|
||||
POST /subscribe?0=cat+/etc/passwd HTTP/1.1
|
||||
email="{{ app.request.query.filter(0,0,1024,{'options':'system'}) }}"@attacker.tld
|
||||
Reference in New Issue
Block a user