mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
Merge branch 'support/3.2' into develop
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -51,27 +52,27 @@ class CKEditorHelperTest extends ItopTestCase
|
||||
$oSanitizer->SetStylesWhiteList($aSanitizerConfiguration['stylesWhiteList']);
|
||||
$oSanitizer->SetTagsBlackList($aSanitizerConfiguration['tagsBlackList']);
|
||||
$oSanitizer->SetAttrsBlackList($aSanitizerConfiguration['attrsBlackList']);
|
||||
|
||||
|
||||
$aCKEditorConfiguration = CKEditorHelper::GetDOMSanitizerForCKEditor($oSanitizer);
|
||||
$this->assertEquals($aExpectedCKEditorConfiguration, $aCKEditorConfiguration);
|
||||
}
|
||||
|
||||
|
||||
public function DOMSanitizerForCKEditorProvider(): array
|
||||
{
|
||||
return [
|
||||
'Allow list small dataset' => [
|
||||
[
|
||||
'tagsWhiteList' => [
|
||||
'html' => array(),
|
||||
'p' => array('style', 'class'),
|
||||
'a' => array('href', 'name'),
|
||||
'tagsWhiteList' => [
|
||||
'html' => [],
|
||||
'p' => ['style', 'class'],
|
||||
'a' => ['href', 'name'],
|
||||
],
|
||||
'attrsWhiteList' => [
|
||||
'href' => '/^(https:)/i'
|
||||
'href' => '/^(https:)/i',
|
||||
],
|
||||
'stylesWhiteList' => [
|
||||
'color',
|
||||
'font-size'
|
||||
'font-size',
|
||||
],
|
||||
'tagsBlackList' => [],
|
||||
'attrsBlackList' => [],
|
||||
@@ -82,7 +83,7 @@ class CKEditorHelperTest extends ItopTestCase
|
||||
'name' => 'html',
|
||||
'attributes' => false,
|
||||
'classes' => false,
|
||||
'styles' => false
|
||||
'styles' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'p',
|
||||
@@ -90,35 +91,35 @@ class CKEditorHelperTest extends ItopTestCase
|
||||
'classes' => true,
|
||||
'styles' => [
|
||||
'color' => true,
|
||||
'font-size' => true
|
||||
]
|
||||
'font-size' => true,
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'a',
|
||||
'attributes' => [
|
||||
'href' => [
|
||||
'pattern' => '/^(https:)/i'
|
||||
'pattern' => '/^(https:)/i',
|
||||
],
|
||||
'name' => true
|
||||
'name' => true,
|
||||
],
|
||||
'classes' => false,
|
||||
'styles' => false
|
||||
]
|
||||
'styles' => false,
|
||||
],
|
||||
],
|
||||
'disallow' => []
|
||||
]
|
||||
'disallow' => [],
|
||||
],
|
||||
],
|
||||
'Allow list medium dataset' => [
|
||||
[
|
||||
'tagsWhiteList' => [
|
||||
'h1' => array('style', 'class'),
|
||||
'h2' => array('style', 'class'),
|
||||
'h3' => array('style', 'class'),
|
||||
'h4' => array('style', 'class'),
|
||||
'table' => array('style', 'class', 'width', 'summary', 'align', 'border', 'cellpadding', 'cellspacing', 'style'),
|
||||
'tr' => array('style', 'class', 'align', 'valign', 'bgcolor', 'style'),
|
||||
'ul' => array(),
|
||||
'ol' => array(),
|
||||
'h1' => ['style', 'class'],
|
||||
'h2' => ['style', 'class'],
|
||||
'h3' => ['style', 'class'],
|
||||
'h4' => ['style', 'class'],
|
||||
'table' => ['style', 'class', 'width', 'summary', 'align', 'border', 'cellpadding', 'cellspacing', 'style'],
|
||||
'tr' => ['style', 'class', 'align', 'valign', 'bgcolor', 'style'],
|
||||
'ul' => [],
|
||||
'ol' => [],
|
||||
],
|
||||
'attrsWhiteList' => [
|
||||
'href' => '/^(https:)/i',
|
||||
@@ -166,8 +167,8 @@ class CKEditorHelperTest extends ItopTestCase
|
||||
'vertical-align' => true,
|
||||
'width' => true,
|
||||
'white-space' => true,
|
||||
'float' => true
|
||||
]
|
||||
'float' => true,
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'h2',
|
||||
@@ -186,8 +187,8 @@ class CKEditorHelperTest extends ItopTestCase
|
||||
'vertical-align' => true,
|
||||
'width' => true,
|
||||
'white-space' => true,
|
||||
'float' => true
|
||||
]
|
||||
'float' => true,
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'h3',
|
||||
@@ -206,8 +207,8 @@ class CKEditorHelperTest extends ItopTestCase
|
||||
'vertical-align' => true,
|
||||
'width' => true,
|
||||
'white-space' => true,
|
||||
'float' => true
|
||||
]
|
||||
'float' => true,
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'h4',
|
||||
@@ -226,18 +227,18 @@ class CKEditorHelperTest extends ItopTestCase
|
||||
'vertical-align' => true,
|
||||
'width' => true,
|
||||
'white-space' => true,
|
||||
'float' => true
|
||||
]
|
||||
'float' => true,
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'table',
|
||||
'attributes' => [
|
||||
'width' => [
|
||||
'pattern' => '/^([0-9]+(px|em|%)?)$/i'
|
||||
'pattern' => '/^([0-9]+(px|em|%)?)$/i',
|
||||
],
|
||||
'summary' => true,
|
||||
'align' => [
|
||||
'pattern' => '/^(left|right|center|justify)$/i'
|
||||
'pattern' => '/^(left|right|center|justify)$/i',
|
||||
],
|
||||
'border' => true,
|
||||
'cellpadding' => true,
|
||||
@@ -257,21 +258,21 @@ class CKEditorHelperTest extends ItopTestCase
|
||||
'vertical-align' => true,
|
||||
'width' => true,
|
||||
'white-space' => true,
|
||||
'float' => true
|
||||
]
|
||||
'float' => true,
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'tr',
|
||||
'attributes' => [
|
||||
'align' => [
|
||||
'pattern' => '/^(left|right|center|justify)$/i'
|
||||
'pattern' => '/^(left|right|center|justify)$/i',
|
||||
],
|
||||
'valign' => [
|
||||
'pattern' => '/^(top|middle|bottom)$/i'
|
||||
'pattern' => '/^(top|middle|bottom)$/i',
|
||||
],
|
||||
'bgcolor' => [
|
||||
'pattern' => '/^#[0-9a-f]{6}$/i'
|
||||
]
|
||||
'pattern' => '/^#[0-9a-f]{6}$/i',
|
||||
],
|
||||
],
|
||||
'classes' => true,
|
||||
'styles' => [
|
||||
@@ -287,24 +288,24 @@ class CKEditorHelperTest extends ItopTestCase
|
||||
'vertical-align' => true,
|
||||
'width' => true,
|
||||
'white-space' => true,
|
||||
'float' => true
|
||||
]
|
||||
'float' => true,
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'ul',
|
||||
'attributes' => false,
|
||||
'classes' => false,
|
||||
'styles' => false
|
||||
'styles' => false,
|
||||
],
|
||||
[
|
||||
'name' => 'ol',
|
||||
'attributes' => false,
|
||||
'classes' => false,
|
||||
'styles' => false
|
||||
]
|
||||
'styles' => false,
|
||||
],
|
||||
],
|
||||
'disallow' => []
|
||||
]
|
||||
'disallow' => [],
|
||||
],
|
||||
],
|
||||
'Disallow list small dataset' => [
|
||||
[
|
||||
@@ -326,24 +327,24 @@ class CKEditorHelperTest extends ItopTestCase
|
||||
[
|
||||
'name' => 'html',
|
||||
'attributes' => [
|
||||
'href' => true
|
||||
'href' => true,
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'p',
|
||||
'attributes' => [
|
||||
'href' => true
|
||||
'href' => true,
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'a',
|
||||
'attributes' => [
|
||||
'href' => true
|
||||
'href' => true,
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Application\Helper;
|
||||
|
||||
|
||||
use DOMSanitizer;
|
||||
|
||||
class TestDOMSanitizer extends DOMSanitizer
|
||||
@@ -38,27 +37,27 @@ class TestDOMSanitizer extends DOMSanitizer
|
||||
{
|
||||
return static::$aStylesWhiteList;
|
||||
}
|
||||
|
||||
|
||||
public function SetTagsWhiteList(array $aTagsWhiteList)
|
||||
{
|
||||
static::$aTagsWhiteList = $aTagsWhiteList;
|
||||
}
|
||||
|
||||
|
||||
public function SetAttrsWhiteList(array $aAttrsWhiteList)
|
||||
{
|
||||
static::$aAttrsWhiteList = $aAttrsWhiteList;
|
||||
}
|
||||
|
||||
|
||||
public function SetStylesWhiteList(array $aStylesWhiteList)
|
||||
{
|
||||
static::$aStylesWhiteList = $aStylesWhiteList;
|
||||
}
|
||||
|
||||
|
||||
public function SetTagsBlackList(array $aTagsBlackList)
|
||||
{
|
||||
static::$aTagsBlackList = $aTagsBlackList;
|
||||
}
|
||||
|
||||
|
||||
public function SetAttrsBlackList(array $aAttrsBlackList)
|
||||
{
|
||||
static::$aAttrsBlackList = $aAttrsBlackList;
|
||||
@@ -73,4 +72,4 @@ class TestDOMSanitizer extends DOMSanitizer
|
||||
{
|
||||
// TODO: Implement PrintDoc() method.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -10,7 +11,6 @@ use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
use RuntimeDashboard;
|
||||
use SecurityException;
|
||||
|
||||
|
||||
/**
|
||||
* We need the metamodel started as this is a dependency of {@link RuntimeDashboard}
|
||||
*
|
||||
@@ -18,19 +18,20 @@ use SecurityException;
|
||||
*/
|
||||
class RuntimeDashboardTest extends ItopDataTestCase
|
||||
{
|
||||
const DEFAULT_WELCOME_DASHBOARD_PATH = 'env-production/itop-welcome-itil/welcomemenupage_dashboard.xml';
|
||||
const SYSTEM_FILE_PATH = '../../system-file';
|
||||
public const DEFAULT_WELCOME_DASHBOARD_PATH = 'env-production/itop-welcome-itil/welcomemenupage_dashboard.xml';
|
||||
public const SYSTEM_FILE_PATH = '../../system-file';
|
||||
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
public function testGetDashboard()
|
||||
{
|
||||
$sDashboardFileOk = APPROOT.self::DEFAULT_WELCOME_DASHBOARD_PATH;
|
||||
$sDashboardId = uniqid(mt_rand(), TRUE);
|
||||
$sDashboardId = uniqid(mt_rand(), true);
|
||||
$oDashboard = RuntimeDashboard::GetDashboard($sDashboardFileOk, $sDashboardId);
|
||||
$this->assertNotNull($oDashboard);
|
||||
|
||||
$this->expectException(SecurityException::class);
|
||||
$sDashboardFileSuspect = APPROOT.self::SYSTEM_FILE_PATH;;
|
||||
$sDashboardFileSuspect = APPROOT.self::SYSTEM_FILE_PATH;
|
||||
;
|
||||
RuntimeDashboard::GetDashboard($sDashboardFileSuspect, $sDashboardId);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2010-2024 Combodo SAS
|
||||
*
|
||||
@@ -47,8 +48,8 @@ use Dict;
|
||||
*/
|
||||
class CriterionConversionTest extends ItopDataTestCase
|
||||
{
|
||||
const CREATE_TEST_ORG = false;
|
||||
const USE_TRANSACTION = false;
|
||||
public const CREATE_TEST_ORG = false;
|
||||
public const USE_TRANSACTION = false;
|
||||
|
||||
/**
|
||||
* @dataProvider ToOqlProvider
|
||||
@@ -63,7 +64,8 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
{
|
||||
$oSearch = new DBObjectSearch($sClass);
|
||||
$sOql = CriterionToOQL::Convert(
|
||||
$oSearch, json_decode($sJSONCriterion, true)
|
||||
$oSearch,
|
||||
json_decode($sJSONCriterion, true)
|
||||
);
|
||||
|
||||
$this->debug($sOql);
|
||||
@@ -72,8 +74,8 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
|
||||
public function ToOqlProvider()
|
||||
{
|
||||
return array(
|
||||
'>' => array(
|
||||
return [
|
||||
'>' => [
|
||||
'UserRequest',
|
||||
'{
|
||||
"ref": "UserRequest.start_date",
|
||||
@@ -86,9 +88,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"operator": ">",
|
||||
"oql": ""
|
||||
}',
|
||||
"(`UserRequest`.`start_date` > '2017-01-01')"
|
||||
),
|
||||
'contains nothing' => array(
|
||||
"(`UserRequest`.`start_date` > '2017-01-01')",
|
||||
],
|
||||
'contains nothing' => [
|
||||
'Contact',
|
||||
'{
|
||||
"ref": "Contact.name",
|
||||
@@ -101,9 +103,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"operator": "contains",
|
||||
"oql": ""
|
||||
}',
|
||||
"1"
|
||||
),
|
||||
'contains a regular string' => array(
|
||||
"1",
|
||||
],
|
||||
'contains a regular string' => [
|
||||
'Contact',
|
||||
'{
|
||||
"ref": "Contact.name",
|
||||
@@ -116,10 +118,10 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"operator": "contains",
|
||||
"oql": ""
|
||||
}',
|
||||
"(`Contact`.`name` LIKE '%toto%')"
|
||||
),
|
||||
"(`Contact`.`name` LIKE '%toto%')",
|
||||
],
|
||||
// See PR #170
|
||||
'contains 0 as a string' => array(
|
||||
'contains 0 as a string' => [
|
||||
'Contact',
|
||||
'{
|
||||
"ref": "Contact.name",
|
||||
@@ -132,9 +134,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"operator": "contains",
|
||||
"oql": ""
|
||||
}',
|
||||
"(`Contact`.`name` LIKE '%0%')"
|
||||
),
|
||||
'starts_with nothing' => array(
|
||||
"(`Contact`.`name` LIKE '%0%')",
|
||||
],
|
||||
'starts_with nothing' => [
|
||||
'Contact',
|
||||
'{
|
||||
"ref": "Contact.name",
|
||||
@@ -147,9 +149,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"operator": "starts_with",
|
||||
"oql": ""
|
||||
}',
|
||||
"1"
|
||||
),
|
||||
'starts_with a regular string' => array(
|
||||
"1",
|
||||
],
|
||||
'starts_with a regular string' => [
|
||||
'Contact',
|
||||
'{
|
||||
"ref": "Contact.name",
|
||||
@@ -162,9 +164,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"operator": "starts_with",
|
||||
"oql": ""
|
||||
}',
|
||||
"(`Contact`.`name` LIKE 'toto%')"
|
||||
),
|
||||
'starts_with a 0 as a string' => array(
|
||||
"(`Contact`.`name` LIKE 'toto%')",
|
||||
],
|
||||
'starts_with a 0 as a string' => [
|
||||
'Contact',
|
||||
'{
|
||||
"ref": "Contact.name",
|
||||
@@ -177,9 +179,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"operator": "starts_with",
|
||||
"oql": ""
|
||||
}',
|
||||
"(`Contact`.`name` LIKE '0%')"
|
||||
),
|
||||
'ends_with nothing' => array(
|
||||
"(`Contact`.`name` LIKE '0%')",
|
||||
],
|
||||
'ends_with nothing' => [
|
||||
'Contact',
|
||||
'{
|
||||
"ref": "Contact.name",
|
||||
@@ -192,9 +194,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"operator": "ends_with",
|
||||
"oql": ""
|
||||
}',
|
||||
"1"
|
||||
),
|
||||
'ends_with a regular string' => array(
|
||||
"1",
|
||||
],
|
||||
'ends_with a regular string' => [
|
||||
'Contact',
|
||||
'{
|
||||
"ref": "Contact.name",
|
||||
@@ -207,9 +209,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"operator": "ends_with",
|
||||
"oql": ""
|
||||
}',
|
||||
"(`Contact`.`name` LIKE '%toto')"
|
||||
),
|
||||
'ends_with 0 as a string' => array(
|
||||
"(`Contact`.`name` LIKE '%toto')",
|
||||
],
|
||||
'ends_with 0 as a string' => [
|
||||
'Contact',
|
||||
'{
|
||||
"ref": "Contact.name",
|
||||
@@ -222,9 +224,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"operator": "ends_with",
|
||||
"oql": ""
|
||||
}',
|
||||
"(`Contact`.`name` LIKE '%0')"
|
||||
),
|
||||
'empty' => array(
|
||||
"(`Contact`.`name` LIKE '%0')",
|
||||
],
|
||||
'empty' => [
|
||||
'Contact',
|
||||
'{
|
||||
"ref": "Contact.name",
|
||||
@@ -237,9 +239,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"operator": "empty",
|
||||
"oql": ""
|
||||
}',
|
||||
"(`Contact`.`name` = '')"
|
||||
),
|
||||
'not_empty' => array(
|
||||
"(`Contact`.`name` = '')",
|
||||
],
|
||||
'not_empty' => [
|
||||
'Contact',
|
||||
'{
|
||||
"ref": "Contact.name",
|
||||
@@ -252,9 +254,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"operator": "not_empty",
|
||||
"oql": ""
|
||||
}',
|
||||
"(`Contact`.`name` != '')"
|
||||
),
|
||||
);
|
||||
"(`Contact`.`name` != '')",
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -266,7 +268,7 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
* @throws \CoreException
|
||||
* @throws \OQLException
|
||||
*/
|
||||
function testToSearchForm($aCriterion, $sExpectedOperator)
|
||||
public function testToSearchForm($aCriterion, $sExpectedOperator)
|
||||
{
|
||||
$oSearchForm = new SearchForm();
|
||||
/** @var \DBObjectSearch $oSearch */
|
||||
@@ -277,10 +279,10 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
$this->assertEquals($sExpectedOperator, $aRes[0]['operator']);
|
||||
}
|
||||
|
||||
function ToSearchFormProvider()
|
||||
public function ToSearchFormProvider()
|
||||
{
|
||||
return array(
|
||||
'=' => array(
|
||||
return [
|
||||
'=' => [
|
||||
json_decode('[
|
||||
{
|
||||
"ref": "Contact.name",
|
||||
@@ -295,9 +297,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"oql": "(`Contact`.`name` = \'toto\')"
|
||||
}
|
||||
]', true),
|
||||
'='
|
||||
),
|
||||
'starts_with' => array(
|
||||
'=',
|
||||
],
|
||||
'starts_with' => [
|
||||
json_decode('[
|
||||
{
|
||||
"ref": "Contact.name",
|
||||
@@ -312,9 +314,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"oql": "(`Contact`.`name` LIKE \'toto%\')"
|
||||
}
|
||||
]', true),
|
||||
'starts_with'
|
||||
),
|
||||
'ends_with' => array(
|
||||
'starts_with',
|
||||
],
|
||||
'ends_with' => [
|
||||
json_decode('[
|
||||
{
|
||||
"ref": "Contact.name",
|
||||
@@ -329,9 +331,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"oql": "(`Contact`.`name` LIKE \'%toto\')"
|
||||
}
|
||||
]', true),
|
||||
'ends_with'
|
||||
),
|
||||
'contains' => array(
|
||||
'ends_with',
|
||||
],
|
||||
'contains' => [
|
||||
json_decode('[
|
||||
{
|
||||
"widget": "string",
|
||||
@@ -346,9 +348,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"oql": "(`Contact`.`name` LIKE \'%toto%\')"
|
||||
}
|
||||
]', true),
|
||||
'contains'
|
||||
),
|
||||
'empty1' => array(
|
||||
'contains',
|
||||
],
|
||||
'empty1' => [
|
||||
json_decode('[
|
||||
{
|
||||
"widget": "string",
|
||||
@@ -363,9 +365,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"oql": "(`Contact`.`name` LIKE \'\')"
|
||||
}
|
||||
]', true),
|
||||
'empty'
|
||||
),
|
||||
'empty2' => array(
|
||||
'empty',
|
||||
],
|
||||
'empty2' => [
|
||||
json_decode('[
|
||||
{
|
||||
"widget": "string",
|
||||
@@ -380,9 +382,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"oql": "(`Contact`.`name` = \'\')"
|
||||
}
|
||||
]', true),
|
||||
'empty'
|
||||
),
|
||||
'not_empty' => array(
|
||||
'empty',
|
||||
],
|
||||
'not_empty' => [
|
||||
json_decode('[
|
||||
{
|
||||
"widget": "string",
|
||||
@@ -397,9 +399,9 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
"oql": "(`Contact`.`name` != \'\')"
|
||||
}
|
||||
]', true),
|
||||
'not_empty'
|
||||
),
|
||||
);
|
||||
'not_empty',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -414,7 +416,7 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
* @throws \OQLException
|
||||
* @throws \CoreException
|
||||
*/
|
||||
function testOqlToSearchToOql($sOQL, $sExpectedOQL, $aExpectedCriterion)
|
||||
public function testOqlToSearchToOql($sOQL, $sExpectedOQL, $aExpectedCriterion)
|
||||
{
|
||||
// For tests on tags
|
||||
$this->CreateTagData(TAG_CLASS, TAG_ATTCODE, 'tag1', 'First');
|
||||
@@ -423,161 +425,161 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
$this->OqlToSearchToOqlAltLanguage($sOQL, $sExpectedOQL, $aExpectedCriterion);
|
||||
}
|
||||
|
||||
function OqlProvider()
|
||||
public function OqlProvider()
|
||||
{
|
||||
return array(
|
||||
'no criteria' => array(
|
||||
return [
|
||||
'no criteria' => [
|
||||
'OQL' => 'SELECT WebApplication',
|
||||
'ExpectedOQL' => "SELECT `WebApplication` FROM WebApplication AS `WebApplication` WHERE 1",
|
||||
'ExpectedCriterion' => array(),
|
||||
),
|
||||
'string starts' => array(
|
||||
'ExpectedCriterion' => [],
|
||||
],
|
||||
'string starts' => [
|
||||
'OQL' => "SELECT Contact WHERE name LIKE 'toto%'",
|
||||
'ExpectedOQL' => "SELECT `Contact` FROM Contact AS `Contact` WHERE (`Contact`.`name` LIKE 'toto%')",
|
||||
'ExpectedCriterion' => array(array('widget' => 'string', 'operator' => 'starts_with', 'values' => array(array('value' => 'toto')))),
|
||||
),
|
||||
'string ends' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'string', 'operator' => 'starts_with', 'values' => [['value' => 'toto']]]],
|
||||
],
|
||||
'string ends' => [
|
||||
'OQL' => "SELECT Contact WHERE name LIKE '%toto'",
|
||||
'ExpectedOQL' => "SELECT `Contact` FROM Contact AS `Contact` WHERE (`Contact`.`name` LIKE '%toto')",
|
||||
'ExpectedCriterion' => array(array('widget' => 'string', 'operator' => 'ends_with', 'values' => array(array('value' => 'toto')))),
|
||||
),
|
||||
'string contains 1' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'string', 'operator' => 'ends_with', 'values' => [['value' => 'toto']]]],
|
||||
],
|
||||
'string contains 1' => [
|
||||
'OQL' => "SELECT Contact WHERE name LIKE '%toto%'",
|
||||
'ExpectedOQL' => "SELECT `Contact` FROM Contact AS `Contact` WHERE (`Contact`.`name` LIKE '%toto%')",
|
||||
'ExpectedCriterion' => array(array('widget' => 'string', 'operator' => 'contains', 'values' => array(array('value' => 'toto')))),
|
||||
),
|
||||
'string contains 2' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'string', 'operator' => 'contains', 'values' => [['value' => 'toto']]]],
|
||||
],
|
||||
'string contains 2' => [
|
||||
'OQL' => "SELECT Person AS B WHERE B.name LIKE '%A%'",
|
||||
'ExpectedOQL' => "SELECT `B` FROM Person AS `B` WHERE (`B`.`name` LIKE '%A%')",
|
||||
'ExpectedCriterion' => array(array('widget' => 'string', 'operator' => 'contains', 'values' => array(array('value' => 'A')))),
|
||||
),
|
||||
'string NOT contains' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'string', 'operator' => 'contains', 'values' => [['value' => 'A']]]],
|
||||
],
|
||||
'string NOT contains' => [
|
||||
'OQL' => "SELECT Person AS B WHERE B.name NOT LIKE '%A%'",
|
||||
'ExpectedOQL' => "SELECT `B` FROM Person AS `B` WHERE (`B`.`name` NOT LIKE '%A%')",
|
||||
'ExpectedCriterion' => array(array('widget' => 'string', 'operator' => 'NOT LIKE', 'values' => array(array('value' => '%A%')))),
|
||||
),
|
||||
'string regexp' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'string', 'operator' => 'NOT LIKE', 'values' => [['value' => '%A%']]]],
|
||||
],
|
||||
'string regexp' => [
|
||||
'OQL' => "SELECT Server WHERE name REGEXP '^dbserver[0-9]+\\\\\\\\..+\\\\\\\\.[a-z]{2,3}$'",
|
||||
'ExpectedOQL' => "SELECT `Server` FROM Server AS `Server` WHERE (`Server`.`name` REGEXP '^dbserver[0-9]+\\\\\\\\..+\\\\\\\\.[a-z]{2,3}$')",
|
||||
'ExpectedCriterion' => array(array('widget' => 'string', 'operator' => 'REGEXP')),
|
||||
),
|
||||
'enum + key =' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'string', 'operator' => 'REGEXP']],
|
||||
],
|
||||
'enum + key =' => [
|
||||
'OQL' => "SELECT Contact WHERE status = 'active' AND org_id = 3",
|
||||
'ExpectedOQL' => "SELECT `Contact` FROM Contact AS `Contact` JOIN Organization AS `Organization` ON `Contact`.org_id = `Organization`.id JOIN Organization AS `Organization1` ON `Organization`.parent_id BELOW `Organization1`.id WHERE ((`Organization1`.`id` = '3') AND (`Contact`.`status` = 'active'))",
|
||||
'ExpectedCriterion' => array(array('widget' => 'hierarchical_key', 'operator' => 'IN'), array('widget' => 'enum', 'operator' => 'IN')),
|
||||
),
|
||||
'enum =' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'hierarchical_key', 'operator' => 'IN'], ['widget' => 'enum', 'operator' => 'IN']],
|
||||
],
|
||||
'enum =' => [
|
||||
'OQL' => "SELECT Contact WHERE status = 'active'",
|
||||
'ExpectedOQL' => "SELECT `Contact` FROM Contact AS `Contact` WHERE (`Contact`.`status` = 'active')",
|
||||
'ExpectedCriterion' => array(array('widget' => 'enum', 'operator' => 'IN', 'values' => array(array('value' => 'active')))),
|
||||
),
|
||||
'enum IN' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'enum', 'operator' => 'IN', 'values' => [['value' => 'active']]]],
|
||||
],
|
||||
'enum IN' => [
|
||||
'OQL' => "SELECT Contact WHERE status IN ('active', 'inactive')",
|
||||
'ExpectedOQL' => "SELECT `Contact` FROM Contact AS `Contact` WHERE 1",
|
||||
'ExpectedCriterion' => array(array('widget' => 'enum', 'operator' => 'IN', 'values' => array(array('value' => 'active'), array('value' => 'inactive')))),
|
||||
),
|
||||
'enum NOT IN 1' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'enum', 'operator' => 'IN', 'values' => [['value' => 'active'], ['value' => 'inactive']]]],
|
||||
],
|
||||
'enum NOT IN 1' => [
|
||||
'OQL' => "SELECT Contact WHERE status NOT IN ('active')",
|
||||
'ExpectedOQL' => "SELECT `Contact` FROM Contact AS `Contact` WHERE (`Contact`.`status` = 'inactive')",
|
||||
'ExpectedCriterion' => array(array('widget' => 'enum', 'operator' => 'IN', 'values' => array(array('value' => 'inactive')))),
|
||||
),
|
||||
'enum NOT IN 2' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'enum', 'operator' => 'IN', 'values' => [['value' => 'inactive']]]],
|
||||
],
|
||||
'enum NOT IN 2' => [
|
||||
'OQL' => "SELECT Person AS p JOIN UserRequest AS u ON u.agent_id = p.id WHERE u.status != 'closed'",
|
||||
'ExpectedOQL' => "SELECT `p` FROM Person AS `p` JOIN UserRequest AS `u` ON `u`.agent_id = `p`.id WHERE (`u`.`status` != 'closed')",
|
||||
'ExpectedCriterion' => array(array('widget' => 'raw')),
|
||||
),
|
||||
'enum undefined 1' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'raw']],
|
||||
],
|
||||
'enum undefined 1' => [
|
||||
'OQL' => "SELECT FunctionalCI WHERE ((business_criticity = 'high') OR ISNULL(business_criticity)) AND 1",
|
||||
'ExpectedOQL' => "SELECT `FunctionalCI` FROM FunctionalCI AS `FunctionalCI` WHERE (((`FunctionalCI`.`business_criticity` = 'high') OR ISNULL(`FunctionalCI`.`business_criticity`)) AND 1)",
|
||||
'ExpectedCriterion' => array(array('widget' => 'enum', 'has_undefined' => true, 'operator' => 'IN', 'values' => array(array('value' => 'high'), array('value' => 'null')))),
|
||||
),
|
||||
'enum undefined 2' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'enum', 'has_undefined' => true, 'operator' => 'IN', 'values' => [['value' => 'high'], ['value' => 'null']]]],
|
||||
],
|
||||
'enum undefined 2' => [
|
||||
'OQL' => "SELECT FunctionalCI WHERE ((business_criticity IN ('high', 'medium')) OR ISNULL(business_criticity)) AND 1",
|
||||
'ExpectedOQL' => "SELECT `FunctionalCI` FROM FunctionalCI AS `FunctionalCI` WHERE (((`FunctionalCI`.`business_criticity` IN ('high', 'medium')) OR ISNULL(`FunctionalCI`.`business_criticity`)) AND 1)",
|
||||
'ExpectedCriterion' => array(array('widget' => 'enum', 'has_undefined' => true, 'operator' => 'IN', 'values' => array(array('value' => 'high'), array('value' => 'medium'), array('value' => 'null')))),
|
||||
),
|
||||
'enum undefined 3' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'enum', 'has_undefined' => true, 'operator' => 'IN', 'values' => [['value' => 'high'], ['value' => 'medium'], ['value' => 'null']]]],
|
||||
],
|
||||
'enum undefined 3' => [
|
||||
'OQL' => "SELECT FunctionalCI WHERE ISNULL(business_criticity)",
|
||||
'ExpectedOQL' => "SELECT `FunctionalCI` FROM FunctionalCI AS `FunctionalCI` WHERE ISNULL(`FunctionalCI`.`business_criticity`)",
|
||||
'ExpectedCriterion' => array(array('widget' => 'enum', 'has_undefined' => true, 'operator' => 'IN', 'values' => array(array('value' => 'null')))),
|
||||
),
|
||||
'key NOT IN' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'enum', 'has_undefined' => true, 'operator' => 'IN', 'values' => [['value' => 'null']]]],
|
||||
],
|
||||
'key NOT IN' => [
|
||||
'OQL' => "SELECT Contact WHERE org_id NOT IN ('1')",
|
||||
'ExpectedOQL' => "SELECT `Contact` FROM Contact AS `Contact` WHERE (`Contact`.`org_id` NOT IN ('1'))",
|
||||
'ExpectedCriterion' => array(array('widget' => 'raw', 'operator' => 'NOT IN')),
|
||||
),
|
||||
'key IN' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'raw', 'operator' => 'NOT IN']],
|
||||
],
|
||||
'key IN' => [
|
||||
'OQL' => "SELECT Contact WHERE org_id IN ('1')",
|
||||
'ExpectedOQL' => "SELECT `Contact` FROM Contact AS `Contact` JOIN Organization AS `Organization` ON `Contact`.org_id = `Organization`.id JOIN Organization AS `Organization1` ON `Organization`.parent_id BELOW `Organization1`.id WHERE (`Organization1`.`id` = '1')",
|
||||
'ExpectedCriterion' => array(array('widget' => 'hierarchical_key', 'operator' => 'IN')),
|
||||
),
|
||||
'key IN 2' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'hierarchical_key', 'operator' => 'IN']],
|
||||
],
|
||||
'key IN 2' => [
|
||||
'OQL' => "SELECT Contact WHERE org_id IN ('1', '999999')",
|
||||
'ExpectedOQL' => "SELECT `Contact` FROM Contact AS `Contact` JOIN Organization AS `Organization` ON `Contact`.org_id = `Organization`.id JOIN Organization AS `Organization1` ON `Organization`.parent_id BELOW `Organization1`.id WHERE (`Organization1`.`id` = '1')",
|
||||
'ExpectedCriterion' => array(array('widget' => 'hierarchical_key', 'operator' => 'IN')),
|
||||
),
|
||||
'key empty' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'hierarchical_key', 'operator' => 'IN']],
|
||||
],
|
||||
'key empty' => [
|
||||
'OQL' => "SELECT Person WHERE location_id = '0'",
|
||||
'ExpectedOQL' => "SELECT `Person` FROM Person AS `Person` WHERE (`Person`.`location_id` = '0')",
|
||||
'ExpectedCriterion' => array(array('widget' => 'external_key', 'operator' => 'IN', 'values' => array(array('value' => '0')))),
|
||||
),
|
||||
'Double field' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'external_key', 'operator' => 'IN', 'values' => [['value' => '0']]]],
|
||||
],
|
||||
'Double field' => [
|
||||
'OQL' => "SELECT UserRequest AS u WHERE u.close_date > u.start_date",
|
||||
'ExpectedOQL' => "SELECT `u` FROM UserRequest AS `u` WHERE (`u`.`close_date` > `u`.`start_date`)",
|
||||
'ExpectedCriterion' => array(array('widget' => 'raw')),
|
||||
),
|
||||
'Num between 1' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'raw']],
|
||||
],
|
||||
'Num between 1' => [
|
||||
'OQL' => "SELECT Server WHERE nb_u >= 0 AND 1 >= nb_u",
|
||||
'ExpectedOQL' => "SELECT `Server` FROM Server AS `Server` WHERE ((`Server`.`nb_u` >= '0') AND (`Server`.`nb_u` <= '1'))",
|
||||
'ExpectedCriterion' => array(array('widget' => 'numeric', 'operator' => 'between')),
|
||||
),
|
||||
'Num ISNULL' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'numeric', 'operator' => 'between']],
|
||||
],
|
||||
'Num ISNULL' => [
|
||||
'OQL' => "SELECT Server WHERE ISNULL(nb_u)",
|
||||
'ExpectedOQL' => "SELECT `Server` FROM Server AS `Server` WHERE ISNULL(`Server`.`nb_u`)",
|
||||
'ExpectedCriterion' => array(array('widget' => 'numeric', 'operator' => 'empty')),
|
||||
),
|
||||
'Hierarchical below 1' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'numeric', 'operator' => 'empty']],
|
||||
],
|
||||
'Hierarchical below 1' => [
|
||||
'OQL' => "SELECT Person AS P JOIN Organization AS Node ON P.org_id = Node.id JOIN Organization AS Root ON Node.parent_id BELOW Root.id WHERE Root.id=1",
|
||||
'ExpectedOQL' => "SELECT `P` FROM Person AS `P` JOIN Organization AS `Node` ON `P`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id WHERE (`Root`.`id` = '1')",
|
||||
'ExpectedCriterion' => array(array('widget' => 'hierarchical_key')),
|
||||
),
|
||||
'Hierarchical below 2' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'hierarchical_key']],
|
||||
],
|
||||
'Hierarchical below 2' => [
|
||||
'OQL' => "SELECT `Organization` FROM Organization AS `Organization` JOIN Organization AS `Organization1` ON `Organization`.parent_id = `Organization1`.id JOIN Organization AS `Organization11` ON `Organization1`.parent_id BELOW `Organization11`.id WHERE (((`Organization11`.`id` IN ('1', '2')) OR (`Organization`.`parent_id` = '0')) AND 1)",
|
||||
'ExpectedOQL' => "SELECT `Organization` FROM Organization AS `Organization` JOIN Organization AS `Organization1` ON `Organization`.parent_id = `Organization1`.id JOIN Organization AS `Organization11` ON `Organization1`.parent_id BELOW `Organization11`.id WHERE (((`Organization11`.`id` IN ('1', '2')) OR (`Organization`.`parent_id` = '0')) AND 1)",
|
||||
'ExpectedCriterion' => array(array('widget' => 'hierarchical_key')),
|
||||
),
|
||||
'IP range' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'hierarchical_key']],
|
||||
],
|
||||
'IP range' => [
|
||||
'OQL' => "SELECT DatacenterDevice AS dev WHERE INET_ATON(dev.managementip) > INET_ATON('10.22.32.224') AND INET_ATON(dev.managementip) < INET_ATON('10.22.32.255')",
|
||||
'ExpectedOQL' => "SELECT `dev` FROM DatacenterDevice AS `dev` WHERE ((INET_ATON(`dev`.`managementip`) < INET_ATON('10.22.32.255')) AND (INET_ATON(`dev`.`managementip`) > INET_ATON('10.22.32.224')))",
|
||||
'ExpectedCriterion' => array(array('widget' => 'raw')),
|
||||
),
|
||||
'TagSet Matches' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'raw']],
|
||||
],
|
||||
'TagSet Matches' => [
|
||||
'OQL' => "SELECT ".TAG_CLASS." WHERE ".TAG_ATTCODE." MATCHES 'tag1'",
|
||||
'ExpectedOQL' => "SELECT `".TAG_CLASS."` FROM ".TAG_CLASS." AS `".TAG_CLASS."` WHERE `".TAG_CLASS."`.`".TAG_ATTCODE.'` MATCHES \'tag1 _\'',
|
||||
'ExpectedCriterion' => array(array('widget' => 'tag_set')),
|
||||
),
|
||||
'TagSet Matches2' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'tag_set']],
|
||||
],
|
||||
'TagSet Matches2' => [
|
||||
'OQL' => "SELECT ".TAG_CLASS." WHERE ".TAG_ATTCODE." MATCHES 'tag1 tag2'",
|
||||
'ExpectedOQL' => "SELECT `".TAG_CLASS."` FROM ".TAG_CLASS." AS `".TAG_CLASS."` WHERE `".TAG_CLASS."`.`".TAG_ATTCODE.'` MATCHES \'tag1 tag2 _\'',
|
||||
'ExpectedCriterion' => array(array('widget' => 'tag_set')),
|
||||
),
|
||||
'TagSet Undefined' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'tag_set']],
|
||||
],
|
||||
'TagSet Undefined' => [
|
||||
'OQL' => "SELECT ".TAG_CLASS." WHERE ".TAG_ATTCODE." = ''",
|
||||
'ExpectedOQL' => "SELECT `".TAG_CLASS."` FROM ".TAG_CLASS." AS `".TAG_CLASS."` WHERE (`".TAG_CLASS."`.`".TAG_ATTCODE."` = '')",
|
||||
'ExpectedCriterion' => array(array('widget' => 'tag_set')),
|
||||
),
|
||||
'TagSet Undefined and tag' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'tag_set']],
|
||||
],
|
||||
'TagSet Undefined and tag' => [
|
||||
'OQL' => "SELECT ".TAG_CLASS." WHERE (((".TAG_ATTCODE." MATCHES 'tag1 tag2') OR (".TAG_ATTCODE." = '')) AND 1)",
|
||||
'ExpectedOQL' => "SELECT `".TAG_CLASS."` FROM ".TAG_CLASS." AS `".TAG_CLASS."` WHERE ((`".TAG_CLASS."`.`".TAG_ATTCODE.'` MATCHES \'tag1 tag2 _\' OR (`'.TAG_CLASS."`.`".TAG_ATTCODE."` = '')) AND 1)",
|
||||
'ExpectedCriterion' => array(array('widget' => 'tag_set')),
|
||||
),
|
||||
'TagSet equals' => array(
|
||||
'ExpectedCriterion' => [['widget' => 'tag_set']],
|
||||
],
|
||||
'TagSet equals' => [
|
||||
'OQL' => "SELECT ".TAG_CLASS." WHERE ".TAG_ATTCODE." = 'tag1 tag2'",
|
||||
'ExpectedOQL' => "SELECT `".TAG_CLASS."` FROM ".TAG_CLASS." AS `".TAG_CLASS."` WHERE (`".TAG_CLASS."`.`".TAG_ATTCODE.'` MATCHES \'tag1 _\' AND `'.TAG_CLASS."`.`".TAG_ATTCODE.'` MATCHES \'tag2 _\')',
|
||||
'ExpectedCriterion' => array(array('widget' => 'tag_set')),
|
||||
),
|
||||
'ExpectedCriterion' => [['widget' => 'tag_set']],
|
||||
],
|
||||
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -592,87 +594,87 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
* @throws \OQLException
|
||||
* @throws \CoreException
|
||||
*/
|
||||
function testOqlToForSearchToOqlAltLanguage($sOQL, $sExpectedOQL, $aExpectedCriterion)
|
||||
{
|
||||
\MetaModel::GetConfig()->Set('date_and_time_format', array('default' => array('date' => 'Y-m-d', 'time' => 'H:i:s', 'date_time' => '$date $time')));
|
||||
$this->OqlToSearchToOqlAltLanguage($sOQL, $sExpectedOQL, $aExpectedCriterion);
|
||||
}
|
||||
function OqlProviderDates()
|
||||
{
|
||||
return array(
|
||||
public function testOqlToForSearchToOqlAltLanguage($sOQL, $sExpectedOQL, $aExpectedCriterion)
|
||||
{
|
||||
\MetaModel::GetConfig()->Set('date_and_time_format', ['default' => ['date' => 'Y-m-d', 'time' => 'H:i:s', 'date_time' => '$date $time']]);
|
||||
$this->OqlToSearchToOqlAltLanguage($sOQL, $sExpectedOQL, $aExpectedCriterion);
|
||||
}
|
||||
public function OqlProviderDates()
|
||||
{
|
||||
return [
|
||||
|
||||
'Date relative 1' => array(
|
||||
'OQL' => "SELECT UserRequest WHERE DATE_SUB(NOW(), INTERVAL 14 DAY) < start_date",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE (DATE_SUB(NOW(), INTERVAL 14 DAY) < `UserRequest`.`start_date`)",
|
||||
'ExpectedCriterion' => array(array('widget' => 'raw')),
|
||||
),
|
||||
'Date relative 2' => array(
|
||||
'OQL' => "SELECT Contract AS c WHERE c.end_date > NOW() AND c.end_date < DATE_ADD(NOW(), INTERVAL 30 DAY)",
|
||||
'ExpectedOQL' => "SELECT `c` FROM Contract AS `c` WHERE ((`c`.`end_date` < DATE_ADD(NOW(), INTERVAL 30 DAY)) AND (`c`.`end_date` > NOW()))",
|
||||
'ExpectedCriterion' => array(array('widget' => 'raw'), array('widget' => 'raw')),
|
||||
),
|
||||
'Date relative 3' => array(
|
||||
'OQL' => "SELECT UserRequest AS u WHERE u.close_date > DATE_ADD(u.start_date, INTERVAL 8 HOUR)",
|
||||
'ExpectedOQL' => "SELECT `u` FROM UserRequest AS `u` WHERE (`u`.`close_date` > DATE_ADD(`u`.`start_date`, INTERVAL 8 HOUR))",
|
||||
'ExpectedCriterion' => array(),
|
||||
),
|
||||
'Date relative 4' => array(
|
||||
'OQL' => "SELECT UserRequest AS u WHERE u.start_date < DATE_SUB(NOW(), INTERVAL 60 MINUTE) AND u.status = 'new'",
|
||||
'ExpectedOQL' => "SELECT `u` FROM UserRequest AS `u` WHERE ((`u`.`start_date` < DATE_SUB(NOW(), INTERVAL 60 MINUTE)) AND (`u`.`status` = 'new'))",
|
||||
'ExpectedCriterion' => array(array('widget' => 'raw')),
|
||||
),
|
||||
'Date between 1' => array(
|
||||
'OQL' => "SELECT UserRequest WHERE start_date > '2017-01-01 00:00:00' AND '2018-01-01 00:00:00' >= start_date",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE ((`UserRequest`.`start_date` >= '2017-01-01 00:00:01') AND (`UserRequest`.`start_date` <= '2018-01-01 00:00:00'))",
|
||||
'ExpectedCriterion' => array(array('widget' => 'date_time', 'operator' => 'between_dates')),
|
||||
),
|
||||
'Date between 2' => array(
|
||||
'OQL' => "SELECT UserRequest WHERE start_date > '2017-01-01 00:00:00' AND status = 'active' AND org_id = 3 AND '2018-01-01 00:00:00' >= start_date",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` JOIN Organization AS `Organization` ON `UserRequest`.org_id = `Organization`.id JOIN Organization AS `Organization1` ON `Organization`.parent_id BELOW `Organization1`.id WHERE ((((`Organization1`.`id` = '3') AND (`UserRequest`.`start_date` >= '2017-01-01 00:00:01')) AND (`UserRequest`.`start_date` <= '2018-01-01 00:00:00')) AND (`UserRequest`.`status` = 'active'))",
|
||||
'ExpectedCriterion' => array(array('widget' => 'hierarchical_key', 'operator' => 'IN'), array('widget' => 'date_time', 'operator' => 'between_dates'), array('widget' => 'enum', 'operator' => 'IN')),
|
||||
),
|
||||
'Date between 3' => array(
|
||||
'OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-01 00:00:00' >= start_date",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE ((`UserRequest`.`start_date` >= '2017-01-01 00:00:00') AND (`UserRequest`.`start_date` <= '2017-01-01 00:00:00'))",
|
||||
'ExpectedCriterion' => array(array('widget' => 'date_time', 'operator' => 'between_dates')),
|
||||
),
|
||||
'Date between 4' => array(
|
||||
'OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-01 01:00:00' > start_date",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE ((`UserRequest`.`start_date` >= '2017-01-01 00:00:00') AND (`UserRequest`.`start_date` <= '2017-01-01 00:59:59'))",
|
||||
'ExpectedCriterion' => array(array('widget' => 'date_time', 'operator' => 'between_dates')),
|
||||
),
|
||||
'Date between 5' => array(
|
||||
'OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-02 00:00:00' > start_date",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE ((`UserRequest`.`start_date` >= '2017-01-01 00:00:00') AND (`UserRequest`.`start_date` <= '2017-01-01 23:59:59'))",
|
||||
'ExpectedCriterion' => array(array('widget' => 'date_time', 'operator' => 'between_dates')),
|
||||
),
|
||||
'Date between 6' => array(
|
||||
'OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01' AND '2017-01-02' >= start_date",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE ((`UserRequest`.`start_date` >= '2017-01-01 00:00:00') AND (`UserRequest`.`start_date` <= '2017-01-02 00:00:00'))",
|
||||
'ExpectedCriterion' => array(array('widget' => 'date_time', 'operator' => 'between_dates')),
|
||||
),
|
||||
'Date between 7' => array(
|
||||
'OQL' => "SELECT CustomerContract WHERE ((start_date >= '2018-03-01') AND (start_date < '2018-04-01'))",
|
||||
'ExpectedOQL' => "SELECT `CustomerContract` FROM CustomerContract AS `CustomerContract` WHERE ((`CustomerContract`.`start_date` >= '2018-03-01') AND (`CustomerContract`.`start_date` <= '2018-03-31'))",
|
||||
'ExpectedCriterion' => array(array('widget' => 'date', 'operator' => 'between_dates')),
|
||||
),
|
||||
'Date =' => array(
|
||||
'OQL' => "SELECT CustomerContract WHERE (start_date = '2018-03-01')",
|
||||
'ExpectedOQL' => "SELECT `CustomerContract` FROM CustomerContract AS `CustomerContract` WHERE ((`CustomerContract`.`start_date` >= '2018-03-01') AND (`CustomerContract`.`start_date` <= '2018-03-01'))",
|
||||
'ExpectedCriterion' => array(array('widget' => 'date', 'operator' => 'between_dates')),
|
||||
),
|
||||
'Date =2' => array(
|
||||
'OQL' => "SELECT UserRequest WHERE (DATE_FORMAT(start_date, '%Y-%m-%d') = '2018-03-21')",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE ((`UserRequest`.`start_date` >= '2018-03-21 00:00:00') AND (`UserRequest`.`start_date` <= '2018-03-21 23:59:59'))",
|
||||
'ExpectedCriterion' => array(array('widget' => 'date_time', 'operator' => 'between_dates')),
|
||||
),
|
||||
'Date =3' => array(
|
||||
'OQL' => "SELECT UserRequest WHERE (DATE_FORMAT(`UserRequest`.`start_date`, '%w') = '4')",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE (DATE_FORMAT(`UserRequest`.`start_date`, '%w') = '4')",
|
||||
'ExpectedCriterion' => array(array('widget' => 'raw')),
|
||||
),
|
||||
);
|
||||
}
|
||||
'Date relative 1' => [
|
||||
'OQL' => "SELECT UserRequest WHERE DATE_SUB(NOW(), INTERVAL 14 DAY) < start_date",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE (DATE_SUB(NOW(), INTERVAL 14 DAY) < `UserRequest`.`start_date`)",
|
||||
'ExpectedCriterion' => [['widget' => 'raw']],
|
||||
],
|
||||
'Date relative 2' => [
|
||||
'OQL' => "SELECT Contract AS c WHERE c.end_date > NOW() AND c.end_date < DATE_ADD(NOW(), INTERVAL 30 DAY)",
|
||||
'ExpectedOQL' => "SELECT `c` FROM Contract AS `c` WHERE ((`c`.`end_date` < DATE_ADD(NOW(), INTERVAL 30 DAY)) AND (`c`.`end_date` > NOW()))",
|
||||
'ExpectedCriterion' => [['widget' => 'raw'], ['widget' => 'raw']],
|
||||
],
|
||||
'Date relative 3' => [
|
||||
'OQL' => "SELECT UserRequest AS u WHERE u.close_date > DATE_ADD(u.start_date, INTERVAL 8 HOUR)",
|
||||
'ExpectedOQL' => "SELECT `u` FROM UserRequest AS `u` WHERE (`u`.`close_date` > DATE_ADD(`u`.`start_date`, INTERVAL 8 HOUR))",
|
||||
'ExpectedCriterion' => [],
|
||||
],
|
||||
'Date relative 4' => [
|
||||
'OQL' => "SELECT UserRequest AS u WHERE u.start_date < DATE_SUB(NOW(), INTERVAL 60 MINUTE) AND u.status = 'new'",
|
||||
'ExpectedOQL' => "SELECT `u` FROM UserRequest AS `u` WHERE ((`u`.`start_date` < DATE_SUB(NOW(), INTERVAL 60 MINUTE)) AND (`u`.`status` = 'new'))",
|
||||
'ExpectedCriterion' => [['widget' => 'raw']],
|
||||
],
|
||||
'Date between 1' => [
|
||||
'OQL' => "SELECT UserRequest WHERE start_date > '2017-01-01 00:00:00' AND '2018-01-01 00:00:00' >= start_date",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE ((`UserRequest`.`start_date` >= '2017-01-01 00:00:01') AND (`UserRequest`.`start_date` <= '2018-01-01 00:00:00'))",
|
||||
'ExpectedCriterion' => [['widget' => 'date_time', 'operator' => 'between_dates']],
|
||||
],
|
||||
'Date between 2' => [
|
||||
'OQL' => "SELECT UserRequest WHERE start_date > '2017-01-01 00:00:00' AND status = 'active' AND org_id = 3 AND '2018-01-01 00:00:00' >= start_date",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` JOIN Organization AS `Organization` ON `UserRequest`.org_id = `Organization`.id JOIN Organization AS `Organization1` ON `Organization`.parent_id BELOW `Organization1`.id WHERE ((((`Organization1`.`id` = '3') AND (`UserRequest`.`start_date` >= '2017-01-01 00:00:01')) AND (`UserRequest`.`start_date` <= '2018-01-01 00:00:00')) AND (`UserRequest`.`status` = 'active'))",
|
||||
'ExpectedCriterion' => [['widget' => 'hierarchical_key', 'operator' => 'IN'], ['widget' => 'date_time', 'operator' => 'between_dates'], ['widget' => 'enum', 'operator' => 'IN']],
|
||||
],
|
||||
'Date between 3' => [
|
||||
'OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-01 00:00:00' >= start_date",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE ((`UserRequest`.`start_date` >= '2017-01-01 00:00:00') AND (`UserRequest`.`start_date` <= '2017-01-01 00:00:00'))",
|
||||
'ExpectedCriterion' => [['widget' => 'date_time', 'operator' => 'between_dates']],
|
||||
],
|
||||
'Date between 4' => [
|
||||
'OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-01 01:00:00' > start_date",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE ((`UserRequest`.`start_date` >= '2017-01-01 00:00:00') AND (`UserRequest`.`start_date` <= '2017-01-01 00:59:59'))",
|
||||
'ExpectedCriterion' => [['widget' => 'date_time', 'operator' => 'between_dates']],
|
||||
],
|
||||
'Date between 5' => [
|
||||
'OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-02 00:00:00' > start_date",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE ((`UserRequest`.`start_date` >= '2017-01-01 00:00:00') AND (`UserRequest`.`start_date` <= '2017-01-01 23:59:59'))",
|
||||
'ExpectedCriterion' => [['widget' => 'date_time', 'operator' => 'between_dates']],
|
||||
],
|
||||
'Date between 6' => [
|
||||
'OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01' AND '2017-01-02' >= start_date",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE ((`UserRequest`.`start_date` >= '2017-01-01 00:00:00') AND (`UserRequest`.`start_date` <= '2017-01-02 00:00:00'))",
|
||||
'ExpectedCriterion' => [['widget' => 'date_time', 'operator' => 'between_dates']],
|
||||
],
|
||||
'Date between 7' => [
|
||||
'OQL' => "SELECT CustomerContract WHERE ((start_date >= '2018-03-01') AND (start_date < '2018-04-01'))",
|
||||
'ExpectedOQL' => "SELECT `CustomerContract` FROM CustomerContract AS `CustomerContract` WHERE ((`CustomerContract`.`start_date` >= '2018-03-01') AND (`CustomerContract`.`start_date` <= '2018-03-31'))",
|
||||
'ExpectedCriterion' => [['widget' => 'date', 'operator' => 'between_dates']],
|
||||
],
|
||||
'Date =' => [
|
||||
'OQL' => "SELECT CustomerContract WHERE (start_date = '2018-03-01')",
|
||||
'ExpectedOQL' => "SELECT `CustomerContract` FROM CustomerContract AS `CustomerContract` WHERE ((`CustomerContract`.`start_date` >= '2018-03-01') AND (`CustomerContract`.`start_date` <= '2018-03-01'))",
|
||||
'ExpectedCriterion' => [['widget' => 'date', 'operator' => 'between_dates']],
|
||||
],
|
||||
'Date =2' => [
|
||||
'OQL' => "SELECT UserRequest WHERE (DATE_FORMAT(start_date, '%Y-%m-%d') = '2018-03-21')",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE ((`UserRequest`.`start_date` >= '2018-03-21 00:00:00') AND (`UserRequest`.`start_date` <= '2018-03-21 23:59:59'))",
|
||||
'ExpectedCriterion' => [['widget' => 'date_time', 'operator' => 'between_dates']],
|
||||
],
|
||||
'Date =3' => [
|
||||
'OQL' => "SELECT UserRequest WHERE (DATE_FORMAT(`UserRequest`.`start_date`, '%w') = '4')",
|
||||
'ExpectedOQL' => "SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE (DATE_FORMAT(`UserRequest`.`start_date`, '%w') = '4')",
|
||||
'ExpectedCriterion' => [['widget' => 'raw']],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -685,98 +687,80 @@ class CriterionConversionTest extends ItopDataTestCase
|
||||
* @throws \MissingQueryArgument
|
||||
* @throws \OQLException
|
||||
*/
|
||||
function OqlToSearchToOqlAltLanguage($sOQL, $sExpectedOQL, $aExpectedCriterion)
|
||||
{
|
||||
$this->debug($sOQL);
|
||||
|
||||
$oSearchForm = new SearchForm();
|
||||
$oSearch = DBSearch::FromOQL($sOQL);
|
||||
$aFields = $oSearchForm->GetFields(new DBObjectSet($oSearch));
|
||||
/** @var \DBObjectSearch $oSearch */
|
||||
$aCriterion = $oSearchForm->GetCriterion($oSearch, $aFields);
|
||||
|
||||
$aAndCriterion = $aCriterion['or'][0]['and'];
|
||||
|
||||
$aNewCriterion = array();
|
||||
foreach($aAndCriterion as $aCriteria)
|
||||
{
|
||||
if ($aCriteria['widget'] != AttributeDefinition::SEARCH_WIDGET_TYPE_RAW)
|
||||
{
|
||||
unset($aCriteria['oql']);
|
||||
foreach($aFields as $aCatFields)
|
||||
{
|
||||
if (isset($aCatFields[$aCriteria['ref']]))
|
||||
{
|
||||
$aField = $aCatFields[$aCriteria['ref']];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isset($aField))
|
||||
{
|
||||
$aCriteria['code'] = $aField['code'];
|
||||
$aCriteria['class'] = $aField['class'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($aCriteria['widget'] == AttributeDefinition::SEARCH_WIDGET_TYPE_DATE_TIME || $aCriteria['widget'] == AttributeDefinition::SEARCH_WIDGET_TYPE_DATE)
|
||||
{
|
||||
$sAttributeClass = ($aCriteria['widget'] == AttributeDefinition::SEARCH_WIDGET_TYPE_DATE_TIME) ? AttributeDateTime::class : AttributeDate::class;
|
||||
|
||||
/** @var \AttributeDateTime $sAttributeClass */
|
||||
/** @var \DateTimeFormat $oFormat */
|
||||
$oFormat = $sAttributeClass::GetFormat();
|
||||
|
||||
foreach($aCriteria['values'] as $i => $aValue)
|
||||
{
|
||||
if (!empty($aValue['value'])) {
|
||||
$aCriteria['values'][$i]['value'] = $oFormat->Format($aValue['value']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$aNewCriterion[] = $aCriteria;
|
||||
}
|
||||
$this->debug($aNewCriterion);
|
||||
|
||||
$this->assertFalse($this->array_diff_assoc_recursive($aExpectedCriterion, $aNewCriterion), 'Criterion array contains critical parts');
|
||||
|
||||
$aCriterion['or'][0]['and'] = $aNewCriterion;
|
||||
|
||||
$oSearch->ResetCondition();
|
||||
$oFilter = CriterionParser::Parse($oSearch->ToOQL(), $aCriterion);
|
||||
|
||||
$sResultOQL = $oFilter->ToOQL();
|
||||
$this->debug($sResultOQL);
|
||||
|
||||
$this->assertEquals($sExpectedOQL, $sResultOQL);
|
||||
}
|
||||
|
||||
|
||||
function array_diff_assoc_recursive($array1, $array2)
|
||||
public function OqlToSearchToOqlAltLanguage($sOQL, $sExpectedOQL, $aExpectedCriterion)
|
||||
{
|
||||
foreach($array1 as $key => $value)
|
||||
{
|
||||
if (is_array($value))
|
||||
{
|
||||
if (!isset($array2[$key]))
|
||||
{
|
||||
$difference[$key] = $value;
|
||||
$this->debug($sOQL);
|
||||
|
||||
$oSearchForm = new SearchForm();
|
||||
$oSearch = DBSearch::FromOQL($sOQL);
|
||||
$aFields = $oSearchForm->GetFields(new DBObjectSet($oSearch));
|
||||
/** @var \DBObjectSearch $oSearch */
|
||||
$aCriterion = $oSearchForm->GetCriterion($oSearch, $aFields);
|
||||
|
||||
$aAndCriterion = $aCriterion['or'][0]['and'];
|
||||
|
||||
$aNewCriterion = [];
|
||||
foreach ($aAndCriterion as $aCriteria) {
|
||||
if ($aCriteria['widget'] != AttributeDefinition::SEARCH_WIDGET_TYPE_RAW) {
|
||||
unset($aCriteria['oql']);
|
||||
foreach ($aFields as $aCatFields) {
|
||||
if (isset($aCatFields[$aCriteria['ref']])) {
|
||||
$aField = $aCatFields[$aCriteria['ref']];
|
||||
break;
|
||||
}
|
||||
}
|
||||
elseif (!is_array($array2[$key]))
|
||||
{
|
||||
$difference[$key] = $value;
|
||||
if (isset($aField)) {
|
||||
$aCriteria['code'] = $aField['code'];
|
||||
$aCriteria['class'] = $aField['class'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_diff = $this->array_diff_assoc_recursive($value, $array2[$key]);
|
||||
if ($new_diff !== false)
|
||||
{
|
||||
$difference[$key] = $new_diff;
|
||||
}
|
||||
|
||||
if ($aCriteria['widget'] == AttributeDefinition::SEARCH_WIDGET_TYPE_DATE_TIME || $aCriteria['widget'] == AttributeDefinition::SEARCH_WIDGET_TYPE_DATE) {
|
||||
$sAttributeClass = ($aCriteria['widget'] == AttributeDefinition::SEARCH_WIDGET_TYPE_DATE_TIME) ? AttributeDateTime::class : AttributeDate::class;
|
||||
|
||||
/** @var \AttributeDateTime $sAttributeClass */
|
||||
/** @var \DateTimeFormat $oFormat */
|
||||
$oFormat = $sAttributeClass::GetFormat();
|
||||
|
||||
foreach ($aCriteria['values'] as $i => $aValue) {
|
||||
if (!empty($aValue['value'])) {
|
||||
$aCriteria['values'][$i]['value'] = $oFormat->Format($aValue['value']);
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (!array_key_exists($key, $array2) || $array2[$key] != $value)
|
||||
{
|
||||
|
||||
$aNewCriterion[] = $aCriteria;
|
||||
}
|
||||
$this->debug($aNewCriterion);
|
||||
|
||||
$this->assertFalse($this->array_diff_assoc_recursive($aExpectedCriterion, $aNewCriterion), 'Criterion array contains critical parts');
|
||||
|
||||
$aCriterion['or'][0]['and'] = $aNewCriterion;
|
||||
|
||||
$oSearch->ResetCondition();
|
||||
$oFilter = CriterionParser::Parse($oSearch->ToOQL(), $aCriterion);
|
||||
|
||||
$sResultOQL = $oFilter->ToOQL();
|
||||
$this->debug($sResultOQL);
|
||||
|
||||
$this->assertEquals($sExpectedOQL, $sResultOQL);
|
||||
}
|
||||
|
||||
public function array_diff_assoc_recursive($array1, $array2)
|
||||
{
|
||||
foreach ($array1 as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
if (!isset($array2[$key])) {
|
||||
$difference[$key] = $value;
|
||||
} elseif (!is_array($array2[$key])) {
|
||||
$difference[$key] = $value;
|
||||
} else {
|
||||
$new_diff = $this->array_diff_assoc_recursive($value, $array2[$key]);
|
||||
if ($new_diff !== false) {
|
||||
$difference[$key] = $new_diff;
|
||||
}
|
||||
}
|
||||
} elseif (!array_key_exists($key, $array2) || $array2[$key] != $value) {
|
||||
$difference[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2010-2024 Combodo SAS
|
||||
*
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2010-2024 Combodo SAS
|
||||
*
|
||||
@@ -19,7 +20,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Application\Search;
|
||||
|
||||
use Combodo\iTop\Application\Search\SearchForm;
|
||||
@@ -32,7 +32,7 @@ use Exception;
|
||||
*/
|
||||
class SearchFormTest extends ItopDataTestCase
|
||||
{
|
||||
const CREATE_TEST_ORG = false;
|
||||
public const CREATE_TEST_ORG = false;
|
||||
|
||||
/**
|
||||
* @dataProvider GetFieldsProvider
|
||||
@@ -52,17 +52,16 @@ class SearchFormTest extends ItopDataTestCase
|
||||
|
||||
public function GetFieldsProvider()
|
||||
{
|
||||
return array(
|
||||
array("SELECT Contact"),
|
||||
array("SELECT Contact AS C WHERE C.status = 'active'"),
|
||||
array("SELECT Person"),
|
||||
array(
|
||||
return [
|
||||
["SELECT Contact"],
|
||||
["SELECT Contact AS C WHERE C.status = 'active'"],
|
||||
["SELECT Person"],
|
||||
[
|
||||
"SELECT Person AS p JOIN UserRequest AS u ON u.agent_id = p.id WHERE u.status != 'closed'",
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dataProvider GetCriterionProvider
|
||||
*
|
||||
@@ -75,19 +74,17 @@ class SearchFormTest extends ItopDataTestCase
|
||||
public function testGetCriterion($sOQL, $iOrCount)
|
||||
{
|
||||
$oSearchForm = new SearchForm();
|
||||
try
|
||||
{
|
||||
try {
|
||||
$oSearch = \DBSearch::FromOQL($sOQL);
|
||||
$aFields = $oSearchForm->GetFields(new \DBObjectSet($oSearch));
|
||||
/** @var DBObjectSearch $oSearch */
|
||||
$aCriterion = $oSearchForm->GetCriterion($oSearch, $aFields);
|
||||
} catch (\OQLException $e)
|
||||
{
|
||||
} catch (\OQLException $e) {
|
||||
$this->assertTrue(false);
|
||||
|
||||
return;
|
||||
}
|
||||
$aRes = array('base_oql' => $sOQL, 'criterion' => $aCriterion);
|
||||
$aRes = ['base_oql' => $sOQL, 'criterion' => $aCriterion];
|
||||
$this->debug(json_encode($aRes));
|
||||
$this->debug($sOQL);
|
||||
$this->debug(json_encode($aCriterion, JSON_PRETTY_PRINT));
|
||||
@@ -96,27 +93,27 @@ class SearchFormTest extends ItopDataTestCase
|
||||
|
||||
public function GetCriterionProvider()
|
||||
{
|
||||
return array(
|
||||
array('OQL' => "SELECT Contact", 1),
|
||||
array('OQL' => "SELECT Contact WHERE status = 'active'", 1),
|
||||
array('OQL' => "SELECT Contact AS C WHERE C.status = 'active'", 1),
|
||||
array('OQL' => "SELECT Contact WHERE status = 'active' AND name LIKE 'toto%'", 1),
|
||||
array('OQL' => "SELECT Contact WHERE status = 'active' AND org_id = 3", 1),
|
||||
array('OQL' => "SELECT Contact WHERE status IN ('active', 'inactive')", 1),
|
||||
array('OQL' => "SELECT Contact WHERE status NOT IN ('active')", 1),
|
||||
array('OQL' => "SELECT Contact WHERE status NOT IN ('active', 'inactive')", 1),
|
||||
array('OQL' => "SELECT Contact WHERE status = 'active' OR name LIKE 'toto%'", 2),
|
||||
array('OQL' => "SELECT UserRequest WHERE DATE_SUB(NOW(), INTERVAL 14 DAY) < start_date", 1),
|
||||
array('OQL' => "SELECT UserRequest WHERE start_date > '2017-01-01 00:00:00' AND '2018-01-01 00:00:00' >= start_date", 1),
|
||||
array('OQL' => "SELECT UserRequest WHERE start_date > '2017-01-01 00:00:00' AND status = 'active' AND org_id = 3 AND '2018-01-01 00:00:00' >= start_date", 1),
|
||||
array('OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-01 00:00:00' >= start_date", 1),
|
||||
array('OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-01 01:00:00' > start_date", 1),
|
||||
array('OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-02 00:00:00' > start_date", 1),
|
||||
array(
|
||||
return [
|
||||
['OQL' => "SELECT Contact", 1],
|
||||
['OQL' => "SELECT Contact WHERE status = 'active'", 1],
|
||||
['OQL' => "SELECT Contact AS C WHERE C.status = 'active'", 1],
|
||||
['OQL' => "SELECT Contact WHERE status = 'active' AND name LIKE 'toto%'", 1],
|
||||
['OQL' => "SELECT Contact WHERE status = 'active' AND org_id = 3", 1],
|
||||
['OQL' => "SELECT Contact WHERE status IN ('active', 'inactive')", 1],
|
||||
['OQL' => "SELECT Contact WHERE status NOT IN ('active')", 1],
|
||||
['OQL' => "SELECT Contact WHERE status NOT IN ('active', 'inactive')", 1],
|
||||
['OQL' => "SELECT Contact WHERE status = 'active' OR name LIKE 'toto%'", 2],
|
||||
['OQL' => "SELECT UserRequest WHERE DATE_SUB(NOW(), INTERVAL 14 DAY) < start_date", 1],
|
||||
['OQL' => "SELECT UserRequest WHERE start_date > '2017-01-01 00:00:00' AND '2018-01-01 00:00:00' >= start_date", 1],
|
||||
['OQL' => "SELECT UserRequest WHERE start_date > '2017-01-01 00:00:00' AND status = 'active' AND org_id = 3 AND '2018-01-01 00:00:00' >= start_date", 1],
|
||||
['OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-01 00:00:00' >= start_date", 1],
|
||||
['OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-01 01:00:00' > start_date", 1],
|
||||
['OQL' => "SELECT UserRequest WHERE start_date >= '2017-01-01 00:00:00' AND '2017-01-02 00:00:00' > start_date", 1],
|
||||
[
|
||||
'OQL' => "SELECT FunctionalCI WHERE ((business_criticity IN ('high', 'medium')) OR ISNULL(business_criticity)) AND 1",
|
||||
1
|
||||
),
|
||||
1,
|
||||
],
|
||||
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Status;
|
||||
|
||||
|
||||
|
||||
use Combodo\iTop\Application\Status\Status;
|
||||
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
use Config;
|
||||
use Exception;
|
||||
use MySQLException;
|
||||
|
||||
use function Combodo\iTop\Application\Status\StatusCheckConfigFile;
|
||||
use function Combodo\iTop\Application\Status\StatusGetAppRoot;
|
||||
use function Combodo\iTop\Application\Status\StatusStartup;
|
||||
|
||||
if (!defined('DEBUG_UNIT_TEST')) {
|
||||
define('DEBUG_UNIT_TEST', true);
|
||||
define('DEBUG_UNIT_TEST', true);
|
||||
}
|
||||
|
||||
class StatusIncTest extends ItopTestCase {
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $sAppRoot = '';
|
||||
class StatusIncTest extends ItopTestCase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $sAppRoot = '';
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
@@ -29,59 +29,64 @@ class StatusIncTest extends ItopTestCase {
|
||||
$this->RequireOnceItopFile('sources/Application/Status/Status.php');
|
||||
}
|
||||
|
||||
public function testStatusGetAppRootWrongPath() {
|
||||
public function testStatusGetAppRootWrongPath()
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$sAppRootFilenamewrong = 'approot.inc.php_wrong';
|
||||
|
||||
$oStatus = new Status();
|
||||
$this->InvokeNonPublicMethod(Status::class, "StatusGetAppRoot", $oStatus, [$sAppRootFilenamewrong]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function testStatusGetAppRootGood() {
|
||||
$oStatus = new Status();
|
||||
$this->InvokeNonPublicMethod(Status::class, "StatusGetAppRoot", $oStatus, []);
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function testStatusGetAppRootGood()
|
||||
{
|
||||
$oStatus = new Status();
|
||||
$this->InvokeNonPublicMethod(Status::class, "StatusGetAppRoot", $oStatus, []);
|
||||
|
||||
$this->assertNotEmpty(APPROOT);
|
||||
}
|
||||
$this->assertNotEmpty(APPROOT);
|
||||
}
|
||||
|
||||
public function testStatusCheckConfigFileWrongPath() {
|
||||
public function testStatusCheckConfigFileWrongPath()
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$sConfigFilenamewrong = 'config-itop.php_wrong';
|
||||
|
||||
$oStatus = new Status();
|
||||
$this->InvokeNonPublicMethod(Status::class, "StatusCheckConfigFile", $oStatus, [$sConfigFilenamewrong]);
|
||||
}
|
||||
$oStatus = new Status();
|
||||
$this->InvokeNonPublicMethod(Status::class, "StatusCheckConfigFile", $oStatus, [$sConfigFilenamewrong]);
|
||||
}
|
||||
|
||||
public function testStatusCheckConfigFileGood() {
|
||||
$oStatus = new Status();
|
||||
$this->InvokeNonPublicMethod(Status::class, "StatusCheckConfigFile", $oStatus, []);
|
||||
public function testStatusCheckConfigFileGood()
|
||||
{
|
||||
$oStatus = new Status();
|
||||
$this->InvokeNonPublicMethod(Status::class, "StatusCheckConfigFile", $oStatus, []);
|
||||
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess Required because Status constructor invokes MetaModel::Startup... which does nothing when already loaded
|
||||
*/
|
||||
/**
|
||||
* @runInSeparateProcess Required because Status constructor invokes MetaModel::Startup... which does nothing when already loaded
|
||||
*/
|
||||
public function testStatusStartupWrongDbPwd()
|
||||
{
|
||||
$this->RequireOnceItopFile('core/cmdbobject.class.inc.php');
|
||||
$this->RequireOnceItopFile('application/utils.inc.php');
|
||||
$this->RequireOnceItopFile('core/contexttag.class.inc.php');
|
||||
{
|
||||
$this->RequireOnceItopFile('core/cmdbobject.class.inc.php');
|
||||
$this->RequireOnceItopFile('application/utils.inc.php');
|
||||
$this->RequireOnceItopFile('core/contexttag.class.inc.php');
|
||||
|
||||
$oConfigWrong = new Config(ITOP_DEFAULT_CONFIG_FILE);
|
||||
$oConfigWrong->Set('db_pwd', $oConfigWrong->Get('db_pwd').'_unittest');
|
||||
$this->expectException(MySQLException::class);
|
||||
new Status($oConfigWrong);
|
||||
}
|
||||
$oConfigWrong = new Config(ITOP_DEFAULT_CONFIG_FILE);
|
||||
$oConfigWrong->Set('db_pwd', $oConfigWrong->Get('db_pwd').'_unittest');
|
||||
$this->expectException(MySQLException::class);
|
||||
new Status($oConfigWrong);
|
||||
}
|
||||
|
||||
public function testStatusStartupGood() {
|
||||
$oStatus = new Status();
|
||||
$this->InvokeNonPublicMethod(Status::class, "StatusStartup", $oStatus, []);
|
||||
public function testStatusStartupGood()
|
||||
{
|
||||
$oStatus = new Status();
|
||||
$this->InvokeNonPublicMethod(Status::class, "StatusStartup", $oStatus, []);
|
||||
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class StatusTest extends ItopTestCase
|
||||
$sPath = APPROOT.'/webservices/status.php';
|
||||
|
||||
$sPHP = $this->GetPHPCommand();
|
||||
echo "About to execute: $sPHP $sPath\n";
|
||||
echo "About to execute: $sPHP $sPath\n";
|
||||
exec("$sPHP $sPath", $aOutput, $iRet);
|
||||
$this->assertEquals(0, $iRet, "Problem executing status page: $sPath, $iRet, aOutput:\n".var_export($aOutput, true));
|
||||
|
||||
|
||||
@@ -5,21 +5,18 @@
|
||||
require_once __DIR__.'/../../../../../../sources/application/status/Status.php';
|
||||
|
||||
// Do check Status
|
||||
try
|
||||
{
|
||||
\Combodo\iTop\Application\Status\StatusStartup();
|
||||
$aResult = array('status' => STATUS_RUNNING, 'code' => \RestResult::OK, 'message' => '');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$iCode = (defined('\RestResult::INTERNAL_ERROR')) ? \RestResult::INTERNAL_ERROR : 100;
|
||||
$aResult = array('status' => STATUS_ERROR, 'code' => $iCode, 'message' => $e->getMessage());
|
||||
http_response_code(500);
|
||||
try {
|
||||
\Combodo\iTop\Application\Status\StatusStartup();
|
||||
$aResult = ['status' => STATUS_RUNNING, 'code' => \RestResult::OK, 'message' => ''];
|
||||
} catch (\Exception $e) {
|
||||
$iCode = (defined('\RestResult::INTERNAL_ERROR')) ? \RestResult::INTERNAL_ERROR : 100;
|
||||
$aResult = ['status' => STATUS_ERROR, 'code' => $iCode, 'message' => $e->getMessage()];
|
||||
http_response_code(500);
|
||||
}
|
||||
|
||||
//Set headers, based on webservices/rest.php
|
||||
$sContentType = 'application/json';
|
||||
header('Content-type: ' . $sContentType);
|
||||
header('Content-type: '.$sContentType);
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
//Output result
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -10,7 +11,6 @@ use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
|
||||
class TestAutoload extends ItopDataTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testAutoloader()
|
||||
|
||||
@@ -29,13 +29,11 @@ class TwigTest extends ItopDataTestCase
|
||||
// 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)
|
||||
{
|
||||
foreach ($aFilters as $oFilter) {
|
||||
$oTwig->addFilter($oFilter);
|
||||
}
|
||||
$aFunctions = $oAppExtension->getFunctions();
|
||||
foreach ($aFunctions as $oFunction)
|
||||
{
|
||||
foreach ($aFunctions as $oFunction) {
|
||||
$oTwig->addFunction($oFunction);
|
||||
}
|
||||
|
||||
@@ -46,7 +44,7 @@ class TwigTest extends ItopDataTestCase
|
||||
|
||||
public static function TemplateProvider()
|
||||
{
|
||||
$aReturn = array();
|
||||
$aReturn = [];
|
||||
$aReturn['filter_system'] = [
|
||||
'sFileName' => 'test.html',
|
||||
'expected' => file_get_contents(__DIR__.'/test.html'),
|
||||
@@ -54,4 +52,4 @@ class TwigTest extends ItopDataTestCase
|
||||
|
||||
return $aReturn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Application\WebPage;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\WebPage\WebPage;
|
||||
|
||||
class WebPageMock extends WebPage
|
||||
@@ -17,4 +15,4 @@ class WebPageMock extends WebPage
|
||||
{
|
||||
// Don't call parent construct as we don't want the ob_start() method to be called (it would mess with PHPUnit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -229,4 +230,4 @@ class WebPageTest extends ItopDataTestCase
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
*/
|
||||
class iTopComposerTest extends ItopTestCase
|
||||
{
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -90,8 +89,10 @@ class iTopComposerTest extends ItopTestCase
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEmpty($aDeniedDirWrongFormat,
|
||||
'There are elements in \Combodo\iTop\Dependencies\Composer\iTopComposer::ListDeniedFoldersRelPaths that are not test dirs :'.var_export($aDeniedDirWrongFormat, true));
|
||||
$this->assertEmpty(
|
||||
$aDeniedDirWrongFormat,
|
||||
'There are elements in \Combodo\iTop\Dependencies\Composer\iTopComposer::ListDeniedFoldersRelPaths that are not test dirs :'.var_export($aDeniedDirWrongFormat, true)
|
||||
);
|
||||
}
|
||||
|
||||
public function testListAllowedFoldersAbsPaths()
|
||||
@@ -117,7 +118,6 @@ class iTopComposerTest extends ItopTestCase
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This is NOT a unit test, this test the iTop instance running the test ...
|
||||
*/
|
||||
|
||||
@@ -26,7 +26,6 @@ use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
*/
|
||||
class iTopNPMTest extends ItopTestCase
|
||||
{
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -15,7 +16,7 @@ use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
|
||||
class FieldTest extends ItopTestCase
|
||||
{
|
||||
public function testIsValidationDisabled(): void
|
||||
public function testIsValidationDisabled(): void
|
||||
{
|
||||
$oField = new StringField('test');
|
||||
$oField->SetCurrentValue('toto@johny.invalid');
|
||||
@@ -101,7 +102,8 @@ class FieldTest extends ItopTestCase
|
||||
$this->assertCount(0, $oSubFormField->GetErrorMessages());
|
||||
}
|
||||
|
||||
public function testRemoveValidatorsOfClass(): void {
|
||||
public function testRemoveValidatorsOfClass(): void
|
||||
{
|
||||
$oField = new StringField('test');
|
||||
|
||||
$this->assertCount(0, $oField->GetValidators());
|
||||
@@ -124,4 +126,4 @@ class FieldTest extends ItopTestCase
|
||||
$oField->RemoveValidatorsOfClass(CustomRegexpValidator::class);
|
||||
$this->assertCount(1, $oField->GetValidators());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -11,8 +12,10 @@ use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
use ormLinkSet;
|
||||
use Person;
|
||||
|
||||
class LinkedSetFieldTest extends ItopDataTestCase {
|
||||
public function testValidate(): void {
|
||||
class LinkedSetFieldTest extends ItopDataTestCase
|
||||
{
|
||||
public function testValidate(): void
|
||||
{
|
||||
$sLinkedClass = Ticket::class;
|
||||
$oLinkedSetField = new LinkedSetField('test');
|
||||
$oLinkedSetField->SetIndirect(false);
|
||||
@@ -37,4 +40,4 @@ class LinkedSetFieldTest extends ItopDataTestCase {
|
||||
$oUserRequest1->Set('title', '');
|
||||
$this->assertFalse($oLinkedSetField->Validate(), 'A set with existing objects and an invalid modification must be KO');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -104,4 +105,4 @@ class MultipleChoicesFieldTest extends ItopTestCase
|
||||
$this->assertCount(1, $oMultipleChoicesField->GetErrorMessages());
|
||||
$this->assertStringContainsString($sNonExistingValue, $oMultipleChoicesField->GetErrorMessages()[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -12,8 +13,10 @@ use ContextTag;
|
||||
use DBObjectSearch;
|
||||
use Organization;
|
||||
|
||||
class SelectObjectFieldTest extends ItopDataTestCase {
|
||||
public function testValidate(): void {
|
||||
class SelectObjectFieldTest extends ItopDataTestCase
|
||||
{
|
||||
public function testValidate(): void
|
||||
{
|
||||
$oSelectObjectField = new SelectObjectField('test');
|
||||
$oSelectObjectField->SetSearch(DBObjectSearch::FromOQL('SELECT '.Organization::class));
|
||||
|
||||
@@ -26,7 +29,8 @@ class SelectObjectFieldTest extends ItopDataTestCase {
|
||||
$this->ValidateSelectObjectField($oSelectObjectField);
|
||||
}
|
||||
|
||||
private function ValidateSelectObjectField(SelectObjectField $oSelectObjectField): void {
|
||||
private function ValidateSelectObjectField(SelectObjectField $oSelectObjectField): void
|
||||
{
|
||||
$oSelectObjectField->SetCurrentValue(null);
|
||||
$this->assertTrue($oSelectObjectField->Validate(), 'No value must be valid');
|
||||
|
||||
@@ -40,4 +44,4 @@ class SelectObjectFieldTest extends ItopDataTestCase {
|
||||
$this->assertCount(1, $oSelectObjectField->GetErrorMessages());
|
||||
$this->assertStringContainsString($sNonExistingOrganizationId, $oSelectObjectField->GetErrorMessages()[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -28,4 +29,4 @@ class ValidatorTest extends ItopTestCase
|
||||
$this->assertCount(1, $oField->GetErrorMessages());
|
||||
$this->assertStringContainsString(MandatoryValidator::DEFAULT_ERROR_MESSAGE, $oField->GetErrorMessages()[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,15 +30,15 @@ class DataModelDependantCacheTest extends ItopTestCase
|
||||
}
|
||||
|
||||
public function testShouldStoreAndFetchVariousDataTypes(): void
|
||||
{
|
||||
$this->oCacheService->Store('pool-A', 'key-array', ['value1', 'value2']);
|
||||
$this->oCacheService->Store('pool-A', 'key-string', 'foo');
|
||||
$this->oCacheService->Store('pool-A', 'key-int', 1971);
|
||||
{
|
||||
$this->oCacheService->Store('pool-A', 'key-array', ['value1', 'value2']);
|
||||
$this->oCacheService->Store('pool-A', 'key-string', 'foo');
|
||||
$this->oCacheService->Store('pool-A', 'key-int', 1971);
|
||||
|
||||
$this->assertEquals(['value1', 'value2'], $this->oCacheService->Fetch('pool-A', 'key-array'));
|
||||
$this->assertEquals('foo', $this->oCacheService->Fetch('pool-A', 'key-string'));
|
||||
$this->assertEquals(1971, $this->oCacheService->Fetch('pool-A', 'key-int'));
|
||||
}
|
||||
$this->assertEquals('foo', $this->oCacheService->Fetch('pool-A', 'key-string'));
|
||||
$this->assertEquals(1971, $this->oCacheService->Fetch('pool-A', 'key-int'));
|
||||
}
|
||||
|
||||
public function testShouldNotAllowToStoreNull(): void
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -23,9 +24,9 @@ use TypeError;
|
||||
*/
|
||||
class EventTest extends ItopDataTestCase
|
||||
{
|
||||
const USE_TRANSACTION = false;
|
||||
const CREATE_TEST_ORG = false;
|
||||
const DEBUG_UNIT_TEST = true;
|
||||
public const USE_TRANSACTION = false;
|
||||
public const CREATE_TEST_ORG = false;
|
||||
public const DEBUG_UNIT_TEST = true;
|
||||
|
||||
private static int $iEventCalls;
|
||||
|
||||
@@ -99,18 +100,18 @@ class EventTest extends ItopDataTestCase
|
||||
{
|
||||
$oReceiver = new TestEventReceiver();
|
||||
|
||||
return array(
|
||||
'method' => array(array($oReceiver, 'OnEvent1')),
|
||||
'static' => array('Combodo\iTop\Test\UnitTest\Service\Events\TestEventReceiver::OnStaticEvent1'),
|
||||
'static2' => array(array('Combodo\iTop\Test\UnitTest\Service\Events\TestEventReceiver', 'OnStaticEvent1')),
|
||||
);
|
||||
return [
|
||||
'method' => [[$oReceiver, 'OnEvent1']],
|
||||
'static' => ['Combodo\iTop\Test\UnitTest\Service\Events\TestEventReceiver::OnStaticEvent1'],
|
||||
'static2' => [['Combodo\iTop\Test\UnitTest\Service\Events\TestEventReceiver', 'OnStaticEvent1']],
|
||||
];
|
||||
}
|
||||
|
||||
public function testBrokenCallback()
|
||||
{
|
||||
EventService::RegisterEvent(new EventDescription('event_a', [], 'test', '', [], ''));
|
||||
$oReceiver = new TestEventReceiver();
|
||||
$this->EventService_RegisterListener('event_a', array($oReceiver, 'BrokenCallback'));
|
||||
$this->EventService_RegisterListener('event_a', [$oReceiver, 'BrokenCallback']);
|
||||
|
||||
$this->expectException(TypeError::class);
|
||||
EventService::FireEvent(new EventData('event_a'));
|
||||
@@ -120,7 +121,7 @@ class EventTest extends ItopDataTestCase
|
||||
{
|
||||
EventService::RegisterEvent(new EventDescription('event_a', [], 'test', '', [], ''));
|
||||
$oReceiver = new TestEventReceiver();
|
||||
$this->EventService_RegisterListener('event_a', array($oReceiver, 'OnEvent1'));
|
||||
$this->EventService_RegisterListener('event_a', [$oReceiver, 'OnEvent1']);
|
||||
|
||||
self::$iEventCalls = 0;
|
||||
EventService::FireEvent(new EventData('event_a'));
|
||||
@@ -140,14 +141,14 @@ class EventTest extends ItopDataTestCase
|
||||
EventService::RegisterEvent(new EventDescription('event_a', [], 'test', '', [], ''));
|
||||
EventService::RegisterEvent(new EventDescription('event_b', [], 'test', '', [], ''));
|
||||
$oReceiver = new TestEventReceiver();
|
||||
$this->EventService_RegisterListener('event_a', array($oReceiver, 'OnEvent1'));
|
||||
$this->EventService_RegisterListener('event_a', array($oReceiver, 'OnEvent2'));
|
||||
$this->EventService_RegisterListener('event_a', array('Combodo\iTop\Test\UnitTest\Service\Events\TestEventReceiver', 'OnStaticEvent1'));
|
||||
$this->EventService_RegisterListener('event_a', [$oReceiver, 'OnEvent1']);
|
||||
$this->EventService_RegisterListener('event_a', [$oReceiver, 'OnEvent2']);
|
||||
$this->EventService_RegisterListener('event_a', ['Combodo\iTop\Test\UnitTest\Service\Events\TestEventReceiver', 'OnStaticEvent1']);
|
||||
$this->EventService_RegisterListener('event_a', 'Combodo\iTop\Test\UnitTest\Service\Events\TestEventReceiver::OnStaticEvent2');
|
||||
|
||||
$this->EventService_RegisterListener('event_b', array($oReceiver, 'OnEvent1'));
|
||||
$this->EventService_RegisterListener('event_b', array($oReceiver, 'OnEvent2'));
|
||||
$this->EventService_RegisterListener('event_b', array('Combodo\iTop\Test\UnitTest\Service\Events\TestEventReceiver', 'OnStaticEvent1'));
|
||||
$this->EventService_RegisterListener('event_b', [$oReceiver, 'OnEvent1']);
|
||||
$this->EventService_RegisterListener('event_b', [$oReceiver, 'OnEvent2']);
|
||||
$this->EventService_RegisterListener('event_b', ['Combodo\iTop\Test\UnitTest\Service\Events\TestEventReceiver', 'OnStaticEvent1']);
|
||||
$this->EventService_RegisterListener('event_b', 'Combodo\iTop\Test\UnitTest\Service\Events\TestEventReceiver::OnStaticEvent2');
|
||||
|
||||
self::$iEventCalls = 0;
|
||||
@@ -163,13 +164,13 @@ class EventTest extends ItopDataTestCase
|
||||
{
|
||||
EventService::RegisterEvent(new EventDescription('event1', [], 'test', '', [], ''));
|
||||
$oReceiver = new TestEventReceiver();
|
||||
$sId = $this->EventService_RegisterListener('event1', array($oReceiver, 'OnEvent1'));
|
||||
$sId = $this->EventService_RegisterListener('event1', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sId");
|
||||
$sId = $this->EventService_RegisterListener('event1', array($oReceiver, 'OnEvent1'));
|
||||
$sId = $this->EventService_RegisterListener('event1', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sId");
|
||||
$sId = $this->EventService_RegisterListener('event1', array($oReceiver, 'OnEvent1'));
|
||||
$sId = $this->EventService_RegisterListener('event1', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sId");
|
||||
$sId = $this->EventService_RegisterListener('event1', array($oReceiver, 'OnEvent1'));
|
||||
$sId = $this->EventService_RegisterListener('event1', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sId");
|
||||
|
||||
self::$iEventCalls = 0;
|
||||
@@ -268,19 +269,18 @@ class EventTest extends ItopDataTestCase
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testUnRegisterEventListener()
|
||||
{
|
||||
EventService::RegisterEvent(new EventDescription('event1', [], 'test', '', [], ''));
|
||||
EventService::RegisterEvent(new EventDescription('event2', [], 'test', '', [], ''));
|
||||
$oReceiver = new TestEventReceiver();
|
||||
$sId = $this->EventService_RegisterListener('event1', array($oReceiver, 'OnEvent1'));
|
||||
$sId = $this->EventService_RegisterListener('event1', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sId");
|
||||
$sId = $this->EventService_RegisterListener('event1', array($oReceiver, 'OnEvent1'));
|
||||
$sId = $this->EventService_RegisterListener('event1', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sId");
|
||||
$sId = $this->EventService_RegisterListener('event1', array($oReceiver, 'OnEvent1'));
|
||||
$sId = $this->EventService_RegisterListener('event1', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sId");
|
||||
$sId = $this->EventService_RegisterListener('event2', array($oReceiver, 'OnEvent1'));
|
||||
$sId = $this->EventService_RegisterListener('event2', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sId");
|
||||
|
||||
self::$iEventCalls = 0;
|
||||
@@ -307,13 +307,13 @@ class EventTest extends ItopDataTestCase
|
||||
EventService::RegisterEvent(new EventDescription('event1', [], 'test', '', [], ''));
|
||||
EventService::RegisterEvent(new EventDescription('event2', [], 'test', '', [], ''));
|
||||
$oReceiver = new TestEventReceiver();
|
||||
$sId = $this->EventService_RegisterListener('event1', array($oReceiver, 'OnEvent1'));
|
||||
$sId = $this->EventService_RegisterListener('event1', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sId");
|
||||
$sId = $this->EventService_RegisterListener('event1', array($oReceiver, 'OnEvent1'));
|
||||
$sId = $this->EventService_RegisterListener('event1', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sId");
|
||||
$sId = $this->EventService_RegisterListener('event1', array($oReceiver, 'OnEvent1'));
|
||||
$sId = $this->EventService_RegisterListener('event1', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sId");
|
||||
$sId = $this->EventService_RegisterListener('event2', array($oReceiver, 'OnEvent1'));
|
||||
$sId = $this->EventService_RegisterListener('event2', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sId");
|
||||
|
||||
self::$iEventCalls = 0;
|
||||
@@ -335,13 +335,13 @@ class EventTest extends ItopDataTestCase
|
||||
EventService::RegisterEvent(new EventDescription('event1', [], 'test', '', [], ''));
|
||||
EventService::RegisterEvent(new EventDescription('event2', [], 'test', '', [], ''));
|
||||
$oReceiver = new TestEventReceiver();
|
||||
$sIdToRemove = $this->EventService_RegisterListener('event1', array($oReceiver, 'OnEvent1'));
|
||||
$sIdToRemove = $this->EventService_RegisterListener('event1', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sIdToRemove");
|
||||
$sId = $this->EventService_RegisterListener('event1', array($oReceiver, 'OnEvent1'));
|
||||
$sId = $this->EventService_RegisterListener('event1', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sId");
|
||||
$sId = $this->EventService_RegisterListener('event1', array($oReceiver, 'OnEvent1'));
|
||||
$sId = $this->EventService_RegisterListener('event1', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sId");
|
||||
$sId = $this->EventService_RegisterListener('event2', array($oReceiver, 'OnEvent1'));
|
||||
$sId = $this->EventService_RegisterListener('event2', [$oReceiver, 'OnEvent1']);
|
||||
$this->debug("Registered $sId");
|
||||
|
||||
self::$iEventCalls = 0;
|
||||
@@ -408,7 +408,6 @@ class TestClassesWithDebug
|
||||
|
||||
class TestEventReceiver extends TestClassesWithDebug
|
||||
{
|
||||
|
||||
// Event callbacks
|
||||
public function OnEvent1(EventData $oData)
|
||||
{
|
||||
@@ -458,4 +457,3 @@ class TestEventReceiver extends TestClassesWithDebug
|
||||
EventTest::IncrementCallCount();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,9 +36,9 @@ class InterfaceDiscoveryTest extends ItopDataTestCase
|
||||
public function testShouldSelectTheRequestedItopClasses()
|
||||
{
|
||||
$this->GivenClassMap([
|
||||
'Combodo\iTop\Application\UI\Base\Component\Alert\Alert' => APPROOT . '/sources/Application/UI/Base/Component/Alert/Alert.php',
|
||||
'Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory' => APPROOT . '/sources/Application/UI/Base/Component/Alert/AlertUIBlockFactory.php',
|
||||
'Combodo\iTop\Application\UI\Base\Component\ButtonGroup\ButtonGroupUIBlockFactory' => APPROOT . '/sources/Application/UI/Base/Component/ButtonGroup/ButtonGroupUIBlockFactory.php',
|
||||
'Combodo\iTop\Application\UI\Base\Component\Alert\Alert' => APPROOT.'/sources/Application/UI/Base/Component/Alert/Alert.php',
|
||||
'Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory' => APPROOT.'/sources/Application/UI/Base/Component/Alert/AlertUIBlockFactory.php',
|
||||
'Combodo\iTop\Application\UI\Base\Component\ButtonGroup\ButtonGroupUIBlockFactory' => APPROOT.'/sources/Application/UI/Base/Component/ButtonGroup/ButtonGroupUIBlockFactory.php',
|
||||
]);
|
||||
|
||||
$this->AssertArraysHaveSameItems(
|
||||
@@ -57,8 +57,8 @@ class InterfaceDiscoveryTest extends ItopDataTestCase
|
||||
{
|
||||
$this->SetNonPublicProperty($this->oInterfaceDiscovery, 'bCheckInterfaceImplementation', false);
|
||||
$this->GivenClassMap([
|
||||
'Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory2' => APPROOT . '/sources/Application/UI/Base/Component/Alert/AlertUIBlockFactory.php',
|
||||
'Combodo\iTop\Application\UI\Base\Component\ButtonGroup\ButtonGroupUIBlockFactory2' => APPROOT . '/sources/Application/UI/Base/Component/ButtonGroup/ButtonGroupUIBlockFactory.php',
|
||||
'Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory2' => APPROOT.'/sources/Application/UI/Base/Component/Alert/AlertUIBlockFactory.php',
|
||||
'Combodo\iTop\Application\UI\Base\Component\ButtonGroup\ButtonGroupUIBlockFactory2' => APPROOT.'/sources/Application/UI/Base/Component/ButtonGroup/ButtonGroupUIBlockFactory.php',
|
||||
]);
|
||||
|
||||
$this->AssertArraysHaveSameItems([], $this->oInterfaceDiscovery->FindItopClasses(iUIBlockFactory::class));
|
||||
@@ -87,8 +87,8 @@ class InterfaceDiscoveryTest extends ItopDataTestCase
|
||||
public function testShouldExcludeAliases()
|
||||
{
|
||||
$this->GivenClassMap([
|
||||
'Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory' => APPROOT . '/sources/Application/UI/Base/Component/Alert/AlertUIBlockFactory.php',
|
||||
'AlbertIsBlockingTheFactory' => APPROOT . '/sources/Application/UI/Base/Component/Alert/AlertUIBlockFactory.php',
|
||||
'Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory' => APPROOT.'/sources/Application/UI/Base/Component/Alert/AlertUIBlockFactory.php',
|
||||
'AlbertIsBlockingTheFactory' => APPROOT.'/sources/Application/UI/Base/Component/Alert/AlertUIBlockFactory.php',
|
||||
]);
|
||||
|
||||
class_alias('Combodo\iTop\Application\UI\Base\Component\Alert\AlertUIBlockFactory', 'AlbertIsBlockingTheFactory');
|
||||
@@ -120,11 +120,13 @@ class InterfaceDiscoveryTest extends ItopDataTestCase
|
||||
MetaModel::GetConfig()->Set('developer_mode.interface_cache.enabled', true);
|
||||
|
||||
$this->assertGreaterThan(0, count($this->oInterfaceDiscovery->FindItopClasses(iUIBlockFactory::class)));
|
||||
$this->AssertDirectoryListingEquals([
|
||||
$this->AssertDirectoryListingEquals(
|
||||
[
|
||||
'autoload_classmaps.php',
|
||||
'1ab1e62be3e9984a8176deeb20f049b1_iUIBlockFactory.php',
|
||||
],
|
||||
$this->sCacheRootDir.'/InterfaceDiscovery');
|
||||
$this->sCacheRootDir.'/InterfaceDiscovery'
|
||||
);
|
||||
}
|
||||
|
||||
public function testShouldProduceStaticCacheForProduction()
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Service\Notification;
|
||||
|
||||
|
||||
use Combodo\iTop\Core\Trigger\Enum\SubscriptionPolicy;
|
||||
use Combodo\iTop\Service\Notification\NotificationsRepository;
|
||||
use Combodo\iTop\Service\Notification\NotificationsService;
|
||||
@@ -21,7 +19,8 @@ use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
* @package Combodo\iTop\Test\UnitTest\Service\Notification
|
||||
* @covers \Combodo\iTop\Service\Notification\NotificationsService
|
||||
*/
|
||||
class NotificationsServiceTest extends ItopDataTestCase {
|
||||
class NotificationsServiceTest extends ItopDataTestCase
|
||||
{
|
||||
public const CREATE_TEST_ORG = true;
|
||||
|
||||
/**
|
||||
@@ -59,14 +58,12 @@ class NotificationsServiceTest extends ItopDataTestCase {
|
||||
]);
|
||||
$iActionNotificationID = $oActionNotification->GetKey();
|
||||
|
||||
|
||||
$oService = NotificationsService::GetInstance();
|
||||
|
||||
// Case 1: Person hasn't received action so far, so it is implicitly subscribed by default
|
||||
// - Assert
|
||||
$this->assertTrue($oService->IsSubscribed($oTrigger, $oActionNotification, $oPerson));
|
||||
|
||||
|
||||
// Case 2: Activate an action, the person should have an explicit subscription
|
||||
// - Prepare
|
||||
$oActionNotification->DoExecute($oTrigger, [
|
||||
@@ -79,7 +76,6 @@ class NotificationsServiceTest extends ItopDataTestCase {
|
||||
$this->assertEquals(1, $iSubscribedCount, "There should be 1 explicit subscription");
|
||||
$this->assertTrue($oService->IsSubscribed($oTrigger, $oActionNotification, $oPerson));
|
||||
|
||||
|
||||
// Case 3: Unsubscribe, person should have an explicit unsubscribe
|
||||
// - Prepare
|
||||
$oSubscription = NotificationsRepository::GetInstance()->SearchSubscribedSubscriptionsByTriggerContactAndAction($iTriggerID, $iActionNotificationID, $iPersonID)->Fetch();
|
||||
@@ -93,4 +89,4 @@ class NotificationsServiceTest extends ItopDataTestCase {
|
||||
$this->assertEquals(1, $iUnsubscribedCount, "There should be 1 explicit unsubscription");
|
||||
$this->assertFalse($oService->IsSubscribed($oTrigger, $oActionNotification, $oPerson));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -90,7 +91,7 @@ class RouterTest extends ItopDataTestCase
|
||||
'object.modify',
|
||||
[
|
||||
'class' => 'Person',
|
||||
'id' => 123
|
||||
'id' => 123,
|
||||
],
|
||||
true,
|
||||
],
|
||||
@@ -247,7 +248,9 @@ class RouterTest extends ItopDataTestCase
|
||||
|
||||
// Generate corrupted cache manually
|
||||
$sFaultyStatement = 'return 1;';
|
||||
file_put_contents($sRoutesCacheFilePath, <<<PHP
|
||||
file_put_contents(
|
||||
$sRoutesCacheFilePath,
|
||||
<<<PHP
|
||||
<?php
|
||||
|
||||
{$sFaultyStatement}
|
||||
@@ -427,4 +430,4 @@ PHP
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -14,8 +15,8 @@ use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
|
||||
class TemporaryObjectManagerTest extends ItopDataTestCase
|
||||
{
|
||||
const USE_TRANSACTION = true;
|
||||
const CREATE_TEST_ORG = false;
|
||||
public const USE_TRANSACTION = true;
|
||||
public const CREATE_TEST_ORG = false;
|
||||
|
||||
private TemporaryObjectConfig $oConfig;
|
||||
private $oManager;
|
||||
@@ -36,12 +37,12 @@ class TemporaryObjectManagerTest extends ItopDataTestCase
|
||||
|
||||
$oDescriptor = $this->oManager->CreateTemporaryObject($sTempId, 'FakedClass', -1, TemporaryObjectHelper::OPERATION_CREATE);
|
||||
|
||||
$this->assertNull( $oDescriptor);
|
||||
$this->assertNull($oDescriptor);
|
||||
|
||||
$oOrg = $this->CreateTestOrganization();
|
||||
$oDescriptor = $this->CreateTemporaryObject($sTempId, $oOrg, 3000, TemporaryObjectHelper::OPERATION_CREATE);
|
||||
|
||||
$this->assertNotNull( $oDescriptor);
|
||||
$this->assertNotNull($oDescriptor);
|
||||
}
|
||||
|
||||
public function testCancelAllTemporaryObjects()
|
||||
@@ -156,7 +157,6 @@ class TemporaryObjectManagerTest extends ItopDataTestCase
|
||||
$this->assertNull($oDeletedObject);
|
||||
}
|
||||
|
||||
|
||||
private function CreateTemporaryObject($sTempId, $oDBObject, int $iLifetime, string $sOperation)
|
||||
{
|
||||
$this->oConfig->SetConfigTemporaryLifetime($iLifetime);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -15,8 +16,8 @@ use DBObject;
|
||||
|
||||
class TemporaryObjectRepositoryTest extends ItopDataTestCase
|
||||
{
|
||||
const USE_TRANSACTION = true;
|
||||
const CREATE_TEST_ORG = false;
|
||||
public const USE_TRANSACTION = true;
|
||||
public const CREATE_TEST_ORG = false;
|
||||
|
||||
private TemporaryObjectConfig $oTemporaryObjectConfig;
|
||||
|
||||
|
||||
@@ -325,4 +325,4 @@ class SessionHandlerTest extends ItopDataTestCase
|
||||
$sContent = $this->GenerateSessionContent($oSessionHandler, json_encode(null));
|
||||
$this->assertNotNull($sContent, "Call to CompleteSessionData should NOT fail due to Argument #1 (\$aJson) must be of type array, null given");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ namespace Combodo\iTop\Test\UnitTest\SessionTracker;
|
||||
|
||||
use Combodo\iTop\SessionTracker\iSessionHandlerExtension;
|
||||
|
||||
class BasicSessionHandlerExtension implements iSessionHandlerExtension {
|
||||
public function __construct(){
|
||||
class BasicSessionHandlerExtension implements iSessionHandlerExtension
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function CompleteSessionData(array $aJson, array &$aData): void
|
||||
{
|
||||
$aData['shadok']='gabuzomeu';
|
||||
$aData['shadok'] = 'gabuzomeu';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,4 +135,4 @@ HTML;
|
||||
|
||||
$this->assertSame($sExpectedBody, $sActualBody);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user