mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 15:34:12 +01:00
# Conflicts: # core/cmdbsource.class.inc.php # core/config.class.inc.php # core/displayablegraph.class.inc.php # core/log.class.inc.php # datamodels/2.x/itop-config-mgmt/dictionaries/tr.dict.itop-config-mgmt.php # datamodels/2.x/itop-knownerror-mgmt/dictionaries/tr.dict.itop-knownerror-mgmt.php # datamodels/2.x/itop-service-mgmt/dictionaries/tr.dict.itop-service-mgmt.php # datamodels/2.x/itop-tickets/tr.dict.itop-tickets.php # datamodels/2.x/itop-welcome-itil/tr.dict.itop-welcome-itil.php # dictionaries/tr.dictionary.itop.core.php # dictionaries/tr.dictionary.itop.ui.php # pages/UI.php # setup/itopdesignformat.class.inc.php # test/core/LogAPITest.php # test/integration/iTopModulesPhpVersionChecklistTest.php # test/postbuild_integration/SetupCssIntegrityChecklistTest.php # test/postbuild_integration/iTopModuleXmlInstallationChecklistTest.php # test/status/StatusTest.php
54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Combodo\iTop\Test\UnitTest\Core;
|
|
|
|
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
|
use Expression;
|
|
|
|
/**
|
|
* @runTestsInSeparateProcesses
|
|
* @preserveGlobalState disabled
|
|
* @backupGlobals disabled
|
|
*/
|
|
class ExpressionTest extends ItopDataTestCase
|
|
{
|
|
const USE_TRANSACTION = false;
|
|
|
|
/**
|
|
* @dataProvider ListParametersProvider
|
|
* @param $sOQL
|
|
* @param $aExpected
|
|
*
|
|
* @throws \OQLException
|
|
*/
|
|
public function testListParameters($sOQL, $aExpected)
|
|
{
|
|
$oExpression = Expression::FromOQL($sOQL);
|
|
$aParameters = $oExpression->ListParameters();
|
|
$aResult = array();
|
|
foreach ($aParameters as $oVarExpr)
|
|
{
|
|
/** var \VariableExpression $oVarExpr */
|
|
$aResult[] = $oVarExpr->RenderExpression();
|
|
}
|
|
$this->debug($aResult);
|
|
$this->assertSame(array_diff($aExpected, $aResult), array_diff($aResult, $aExpected));
|
|
}
|
|
|
|
public function ListParametersProvider()
|
|
{
|
|
return [
|
|
['1', []],
|
|
[':id = 2', [':id']],
|
|
['expiration_date < DATE_SUB(NOW(), INTERVAL :expiration_days DAY)', [':expiration_days']],
|
|
['id IN (SELECT Organization WHERE :id = 2)', [':id']],
|
|
['id IN (:id, 2)', [':id']],
|
|
["B.name LIKE :name", [':name']],
|
|
["name REGEXP :regexp", [':regexp']],
|
|
[" t.agent_id = :current_contact_id", [':current_contact_id']],
|
|
["INET_ATON(dev.managementip) > INET_ATON('10.22.32.224') AND INET_ATON(:ip) < INET_ATON('10.22.32.255')", [':ip']],
|
|
["((`UserRequest`.`status` IN ('closed','rejected','resolved')))", []]
|
|
];
|
|
}
|
|
}
|