mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Under undetermined circumstances, `exec('php -v')` called the current script triggering an infinite loop crashing the server
problem reported by @molkobain
see: https://stackoverflow.com/questions/43728378/running-php-files-through-shell-exec
52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* Created by Bruno DA SILVA, working for Combodo
|
|
* Date: 31/12/2019
|
|
* Time: 12:31
|
|
*/
|
|
|
|
namespace Combodo\iTop\Config\Test\Validator;
|
|
|
|
use Combodo\iTop\Config\Validator\iTopConfigAstValidator;
|
|
use Combodo\iTop\Config\Validator\iTopConfigSyntaxValidator;
|
|
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
|
use PhpParser\Node;
|
|
use PhpParser\PrettyPrinter\Standard;
|
|
|
|
class iTopConfigAstValidatorTest extends ItopTestCase
|
|
{
|
|
|
|
public function setUp()
|
|
{
|
|
parent::setUp();
|
|
|
|
require_once __DIR__.'/../../../env-production/itop-config/src/Validator/ConfigNodesVisitor.php';
|
|
require_once __DIR__.'/../../../env-production/itop-config/src/Validator/iTopConfigSyntaxValidator.php';
|
|
}
|
|
|
|
|
|
/**
|
|
* @throws \Exception
|
|
* @doesNotPerformAssertions
|
|
*/
|
|
public function testValidCode()
|
|
{
|
|
$oiTopConfigValidator = new iTopConfigSyntaxValidator();
|
|
$oiTopConfigValidator->Validate("<?php \n echo 'foo'; ");
|
|
}
|
|
|
|
public function testThrowOnInvalidCode()
|
|
{
|
|
$oiTopConfigValidator = new iTopConfigSyntaxValidator();
|
|
|
|
$this->expectException(\Exception::class);
|
|
try{
|
|
$oiTopConfigValidator->Validate("<?php \n zef;zefzef \n zdadz = azdazd \n zerfgzaezerfgzef>");
|
|
}catch (\Exception $e)
|
|
{
|
|
$this->assertStringStartsWith('Error in configuration: syntax error, unexpected \'zdadz\' (T_STRING)', $e->getMessage());
|
|
throw $e;
|
|
}
|
|
}
|
|
}
|