From 06a8481511f22a70110972419c157fd782872a81 Mon Sep 17 00:00:00 2001
From: Benjamin Dalsass <95754414+bdalsass@users.noreply.github.com>
Date: Thu, 25 Apr 2024 09:16:30 +0200
Subject: [PATCH 1/4] =?UTF-8?q?N=C2=B07279=20-=20AttributeClass=20defined?=
=?UTF-8?q?=20in=20XML=20datamodel=20compilation=20issue?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
core/attributedef.class.inc.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php
index e80d8de86..7134467b7 100644
--- a/core/attributedef.class.inc.php
+++ b/core/attributedef.class.inc.php
@@ -11508,6 +11508,11 @@ class AttributeClassAttCodeSet extends AttributeSet
}
return ''.$value.'';
}
+
+ public function IsNull($proposedValue)
+ {
+ return (empty($proposedValue));
+ }
}
class AttributeQueryAttCodeSet extends AttributeSet
From 32140b360f4803f3b918780f6ac6ce71c6a91d80 Mon Sep 17 00:00:00 2001
From: Molkobain
Date: Mon, 29 Apr 2024 11:45:09 +0200
Subject: [PATCH 2/4] :white_check_mark: Cherry pick fixes from 59a955f4
---
tests/php-unit-tests/composer.json | 3 +
.../Service/UnitTestRunTimeEnvironment.php | 63 +++++++++++++++++--
...plication-extension-usages-in-snippets.xml | 2 +-
3 files changed, 61 insertions(+), 7 deletions(-)
diff --git a/tests/php-unit-tests/composer.json b/tests/php-unit-tests/composer.json
index fef0397e9..36e0c7e44 100644
--- a/tests/php-unit-tests/composer.json
+++ b/tests/php-unit-tests/composer.json
@@ -4,6 +4,9 @@
"sempro/phpunit-pretty-print": "^1.4"
},
"autoload": {
+ "classmap": [
+ "unitary-tests/"
+ ],
"psr-4": {
"Combodo\\iTop\\Test\\UnitTest\\": "src/BaseTestCase/",
"Combodo\\iTop\\Test\\UnitTest\\Hook\\": "src/Hook/",
diff --git a/tests/php-unit-tests/src/Service/UnitTestRunTimeEnvironment.php b/tests/php-unit-tests/src/Service/UnitTestRunTimeEnvironment.php
index 63ded52c7..0c76e727f 100644
--- a/tests/php-unit-tests/src/Service/UnitTestRunTimeEnvironment.php
+++ b/tests/php-unit-tests/src/Service/UnitTestRunTimeEnvironment.php
@@ -9,9 +9,11 @@ namespace Combodo\iTop\Test\UnitTest\Service;
use Combodo\iTop\Test\UnitTest\ItopCustomDatamodelTestCase;
use IssueLog;
+use LogChannels;
use MFCoreModule;
use ReflectionClass;
use RunTimeEnvironment;
+use utils;
/**
@@ -33,12 +35,15 @@ class UnitTestRunTimeEnvironment extends RunTimeEnvironment
/** @var string[] $aDeltaFiles Referential of loaded deltas. Mostly to avoid duplicates. */
$aDeltaFiles = [];
- foreach (get_declared_classes() as $sClass) {
- // Filter on classes derived from this \Combodo\iTop\Test\UnitTest\ItopCustomDatamodelTestCaseItopCustomDatamodelTestCase
- if (false === is_a($sClass, ItopCustomDatamodelTestCase::class, true)) {
- continue;
- }
-
+ $aRelatedClasses = $this->GetClassesExtending(
+ ItopCustomDatamodelTestCase::class,
+ array(
+ '[\\\\/]tests[\\\\/]php-unit-tests[\\\\/]vendor[\\\\/]',
+ '[\\\\/]tests[\\\\/]php-unit-tests[\\\\/]unitary-tests[\\\\/]datamodels[\\\\/]2.x[\\\\/]authent-local',
+ ));
+ //Combodo\iTop\Test\UnitTest\Application\ApplicationExtensionTest
+ //Combodo\iTop\Test\UnitTest\Application\ApplicationExtensionTest
+ foreach ($aRelatedClasses as $sClass) {
$oReflectionClass = new ReflectionClass($sClass);
$oReflectionMethod = $oReflectionClass->getMethod('GetDatamodelDeltaAbsPath');
@@ -83,4 +88,50 @@ class UnitTestRunTimeEnvironment extends RunTimeEnvironment
return $aRet;
}
+ protected function GetClassesExtending (string $sExtendedClass, array $aExcludedPath = []) : array {
+ $aMatchingClasses = [];
+
+ $aAutoloadClassMaps =[__DIR__."/../../vendor/composer/autoload_classmap.php"];
+
+ $aClassMap = [];
+ $aAutoloaderErrors = [];
+ foreach ($aAutoloadClassMaps as $sAutoloadFile) {
+ $aTmpClassMap = include $sAutoloadFile;
+ /** @noinspection SlowArrayOperationsInLoopInspection we are getting an associative array so the documented workarounds cannot be used */
+ $aClassMap = array_merge($aClassMap, $aTmpClassMap);
+ }
+ foreach ($aClassMap as $sPHPClass => $sPHPFile) {
+ $bSkipped = false;
+ if (utils::IsNotNullOrEmptyString($sPHPFile)) {
+ $sPHPFile = utils::LocalPath($sPHPFile);
+ if ($sPHPFile !== false) {
+ $sPHPFile = '/'.$sPHPFile; // for regex
+ foreach ($aExcludedPath as $sExcludedPath) {
+ // Note: We use '#' as delimiters as usual '/' is often used in paths.
+ if ($sExcludedPath !== '' && preg_match('#'.$sExcludedPath.'#', $sPHPFile) === 1) {
+ $bSkipped = true;
+ break;
+ }
+ }
+ } else {
+ $bSkipped = true; // file not found
+ }
+ }
+
+ if (!$bSkipped) {
+ try {
+ $oRefClass = new ReflectionClass($sPHPClass);
+ if ($oRefClass->isSubclassOf($sExtendedClass) &&
+ !$oRefClass->isInterface() && !$oRefClass->isAbstract() && !$oRefClass->isTrait()) {
+ $aMatchingClasses[] = $sPHPClass;
+ }
+ }
+ catch (Exception $e) {
+ }
+ }
+ }
+ return $aMatchingClasses;
+ }
+
+
}
\ No newline at end of file
diff --git a/tests/php-unit-tests/unitary-tests/application/applicationextension/Delta/application-extension-usages-in-snippets.xml b/tests/php-unit-tests/unitary-tests/application/applicationextension/Delta/application-extension-usages-in-snippets.xml
index e404ac49d..d5af912f8 100644
--- a/tests/php-unit-tests/unitary-tests/application/applicationextension/Delta/application-extension-usages-in-snippets.xml
+++ b/tests/php-unit-tests/unitary-tests/application/applicationextension/Delta/application-extension-usages-in-snippets.xml
@@ -140,7 +140,7 @@ class ExampleFor_iQueryModifier implements \iQueryModifier
public function GetFieldExpression(QueryBuilderContext &$oBuild, $sClass, $sAttCode, $sColId, Expression $oFieldSQLExp, SQLQuery &$oSelect)
{
- // Do nothing, we just need the class to exists for the unit test
+ return $oFieldSQLExp;
}
}
]]>
From 93bba66323e087aede741856b30793bb13879ed1 Mon Sep 17 00:00:00 2001
From: jf-cbd
Date: Tue, 30 Apr 2024 08:03:14 +0200
Subject: [PATCH 3/4] =?UTF-8?q?N=C2=B07445=20-=20Invalid=20Unicode=20escap?=
=?UTF-8?q?e=20sequence=20on=20dashlet=20Header=20with=20statistics?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/ajax.render.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/pages/ajax.render.php b/pages/ajax.render.php
index d9cddaaa1..5e9a3a285 100644
--- a/pages/ajax.render.php
+++ b/pages/ajax.render.php
@@ -1155,7 +1155,6 @@ EOF
if ($oDashlet->IsFormRedrawNeeded()) {
$oForm = $oDashlet->GetForm(); // Rebuild the form since the values/content changed
$oForm->SetSubmitParams(utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php', array('operation' => 'update_dashlet_property', 'extra_params' => $aExtraParams));
- $sHtml = addslashes($oForm->RenderAsPropertySheet($oPage, true, '.itop-dashboard'));
$sHtml= json_encode($sHtml);
$oPage->add_script("$('#dashlet_$sDashletId').html({$sHtml});");
}
From dbcbb187b2bd724ad1e578fbeea76715472b992b Mon Sep 17 00:00:00 2001
From: jf-cbd
Date: Tue, 30 Apr 2024 08:13:37 +0200
Subject: [PATCH 4/4] =?UTF-8?q?N=C2=B07445=20-=20Invalid=20Unicode=20escap?=
=?UTF-8?q?e=20sequence=20on=20dashlet=20Header=20with=20statistics?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/ajax.render.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/pages/ajax.render.php b/pages/ajax.render.php
index 5e9a3a285..9e8501758 100644
--- a/pages/ajax.render.php
+++ b/pages/ajax.render.php
@@ -1155,6 +1155,7 @@ EOF
if ($oDashlet->IsFormRedrawNeeded()) {
$oForm = $oDashlet->GetForm(); // Rebuild the form since the values/content changed
$oForm->SetSubmitParams(utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php', array('operation' => 'update_dashlet_property', 'extra_params' => $aExtraParams));
+ $sHtml = $oForm->RenderAsPropertySheet($oPage, true, '.itop-dashboard');
$sHtml= json_encode($sHtml);
$oPage->add_script("$('#dashlet_$sDashletId').html({$sHtml});");
}