mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 00:28:47 +02:00
Compare commits
6 Commits
designer-p
...
support/3.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f7ce0837e | ||
|
|
7df09541ac | ||
|
|
7fb0ae48f9 | ||
|
|
e89a8edae0 | ||
|
|
f6366057c9 | ||
|
|
b5c79e1d75 |
@@ -71,7 +71,10 @@ class DesignDocument extends DOMDocument
|
||||
$this->preserveWhiteSpace = true; // otherwise the formatOutput option would have no effect
|
||||
}
|
||||
|
||||
public function loadXML(string $source, int $options = 0)
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function loadXML(string $source, int $options = 0) : bool
|
||||
{
|
||||
return parent::loadXML($source, $options | LIBXML_BIGLINES);
|
||||
}
|
||||
|
||||
@@ -70,14 +70,14 @@ class MFException extends Exception
|
||||
*
|
||||
* @inheritDoc
|
||||
*
|
||||
* @param $message
|
||||
* @param $code: error code
|
||||
* @param $oNode: dom node
|
||||
* @param $sXPath: XML xpath: if provided used in exception message. otherwise computed via $oNode
|
||||
* @param $sExtraInfo: additional information stored in exception
|
||||
* @param $oParentFallbackNode: fallback dom node (usually parent). in case $oNode XML line is wrong (set to 0), line number computed/displayed in error message comes from $oParentFallbackNode
|
||||
* @param string $message
|
||||
* @param int $code: error code
|
||||
* @param DesignElement $oNode: dom node
|
||||
* @param string|null $sXPath: XML xpath: if provided used in exception message. otherwise computed via $oNode
|
||||
* @param string $sExtraInfo: additional information stored in exception
|
||||
* @param DesignElement|null $oParentFallbackNode: fallback dom node (usually parent). in case $oNode XML line is wrong (set to 0), line number computed/displayed in error message comes from $oParentFallbackNode
|
||||
*/
|
||||
public function __construct($message, $code, $oNode, $sXPath = null, $sExtraInfo = '', $oParentFallbackNode=null)
|
||||
public function __construct(string $message, int $code, DesignElement $oNode, ?string $sXPath = null, string $sExtraInfo = '', ?DesignElement $oParentFallbackNode = null)
|
||||
{
|
||||
$iSourceLineNumber = ModelFactory::GetXMLLineNumber($oNode);
|
||||
if ($iSourceLineNumber==0 && ! is_null($oParentFallbackNode)){
|
||||
@@ -2249,13 +2249,13 @@ EOF;
|
||||
if (!$oExisting)
|
||||
{
|
||||
$sPath = MFDocument::GetItopNodePath($this)."/".$oNode->tagName.(empty($sSearchId) ? '' : "[$sSearchId]");
|
||||
throw new MFException('could not be modified (not found)', MFException::COULD_NOT_BE_MODIFIED_NOT_FOUND, $oNode, $sPath, $oParentFallbackNode);
|
||||
throw new MFException('could not be modified (not found)', MFException::COULD_NOT_BE_MODIFIED_NOT_FOUND, $oNode, $sPath, '', $oParentFallbackNode);
|
||||
}
|
||||
$sPrevFlag = $oExisting->GetAlteration();
|
||||
$sOldId = $oExisting->getAttribute('_old_id');
|
||||
if ($oExisting->IsRemoved()) {
|
||||
$sPath = MFDocument::GetItopNodePath($this)."/".$oNode->tagName.(empty($sSearchId) ? '' : "[$sSearchId]");
|
||||
throw new MFException('could not be modified (marked as deleted)', MFException::COULD_NOT_BE_MODIFIED_ALREADY_DELETED, $oNode, $sPath, $oParentFallbackNode);
|
||||
throw new MFException('could not be modified (marked as deleted)', MFException::COULD_NOT_BE_MODIFIED_ALREADY_DELETED, $oNode, $sPath, '', $oParentFallbackNode);
|
||||
}
|
||||
$oExisting->ReplaceWithSingleNode($oNode);
|
||||
if (!$this->IsInDefinition()) {
|
||||
|
||||
@@ -120,10 +120,6 @@ class ModuleDiscovery
|
||||
$aArgs['module_file'] = $sFilePath;
|
||||
|
||||
list($sModuleName, $sModuleVersion) = static::GetModuleName($sId);
|
||||
if ($sModuleVersion == '')
|
||||
{
|
||||
$sModuleVersion = '1.0.0';
|
||||
}
|
||||
|
||||
if (array_key_exists($sModuleName, self::$m_aModuleVersionByName))
|
||||
{
|
||||
@@ -233,7 +229,7 @@ class ModuleDiscovery
|
||||
}
|
||||
ksort($aDependencies);
|
||||
$aOrderedModules = [];
|
||||
$iLoopCount = 1;
|
||||
$iLoopCount = 0;
|
||||
while(($iLoopCount < count($aModules)) && (count($aDependencies) > 0) )
|
||||
{
|
||||
foreach($aDependencies as $sId => $aRemainingDeps)
|
||||
@@ -308,16 +304,8 @@ class ModuleDiscovery
|
||||
// Separate the module names from their version for an easier comparison later
|
||||
foreach($aOrderedModules as $sModuleId)
|
||||
{
|
||||
$aMatches = array();
|
||||
if (preg_match('|^([^/]+)/(.*)$|', $sModuleId, $aMatches))
|
||||
{
|
||||
$aModuleVersions[$aMatches[1]] = $aMatches[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
// No version number found, assume 1.0.0
|
||||
$aModuleVersions[$sModuleId] = '1.0.0';
|
||||
}
|
||||
list($sModuleName, $sVersion) = self::GetModuleName($sModuleId);
|
||||
$aModuleVersions[$sModuleName] = $sVersion;
|
||||
}
|
||||
if (preg_match_all('/([^\(\)&| ]+)/', $sDepString, $aMatches))
|
||||
{
|
||||
@@ -456,13 +444,17 @@ class ModuleDiscovery
|
||||
{
|
||||
$sName = $aMatches[1];
|
||||
$sVersion = $aMatches[2];
|
||||
if ($sVersion === ""){
|
||||
$sVersion = "1.0.0";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sName = $sModuleId;
|
||||
$sVersion = "";
|
||||
$sVersion = "1.0.0";
|
||||
}
|
||||
return array($sName, $sVersion);
|
||||
|
||||
return [$sName, $sVersion];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Setup;
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
|
||||
class ModuleDiscoveryTest extends ItopTestCase
|
||||
{
|
||||
public function GetModuleNameProvider()
|
||||
{
|
||||
return [
|
||||
'nominal' => [
|
||||
'sModuleId' => 'a/1.2.3',
|
||||
'name' => 'a',
|
||||
'version' => '1.2.3',
|
||||
],
|
||||
'develop' => [
|
||||
'sModuleId' => 'a/1.2.3-dev',
|
||||
'name' => 'a',
|
||||
'version' => '1.2.3-dev',
|
||||
],
|
||||
'missing version => 1.0.0' => [
|
||||
'sModuleId' => 'a/',
|
||||
'name' => 'a',
|
||||
'version' => '1.0.0',
|
||||
],
|
||||
'missing everything except name' => [
|
||||
'sModuleId' => 'a',
|
||||
'name' => 'a',
|
||||
'version' => '1.0.0',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->RequireOnceItopFile('setup/modulediscovery.class.inc.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider GetModuleNameProvider
|
||||
*/
|
||||
public function testGetModuleName($sModuleId, $expectedName, $expectedVersion)
|
||||
{
|
||||
$this->assertEquals([$expectedName, $expectedVersion], \ModuleDiscovery::GetModuleName($sModuleId));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user