N°7348 - Enable to param maximum depth of impact analysis in function Ticket::UpdateImpactedItems (#633)

This commit is contained in:
Anne-Catherine
2024-10-25 15:29:09 +02:00
committed by GitHub
parent dd34fda42e
commit 0688405f86
3 changed files with 105 additions and 3 deletions

View File

@@ -75,6 +75,8 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
]);
}
public function testImpactShouldBePropagatedInOneWayOnly()
{
/**
@@ -117,6 +119,48 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
]);
}
public function testImpactShouldBePropagatedRecursivelyUpToMaxDepth()
{
/**
* ApplicationSolution_0 +----> ApplicationSolution_1 +----> ApplicationSolution_2 +-----> ..... +----> ApplicationSolution_12
*/
$this->GivenCITreeInDB(<<<EOF
ApplicationSolution_0 <-> ApplicationSolution_1
ApplicationSolution_1 <-> ApplicationSolution_2
ApplicationSolution_2 <-> ApplicationSolution_3
ApplicationSolution_3 <-> ApplicationSolution_4
ApplicationSolution_4 <-> ApplicationSolution_5
ApplicationSolution_5 <-> ApplicationSolution_6
ApplicationSolution_6 <-> ApplicationSolution_7
ApplicationSolution_7 <-> ApplicationSolution_8
ApplicationSolution_8 <-> ApplicationSolution_9
ApplicationSolution_9 <-> ApplicationSolution_10
ApplicationSolution_10 <-> ApplicationSolution_11
ApplicationSolution_11 <-> ApplicationSolution_12
ApplicationSolution_12 <-> ApplicationSolution_13
EOF);
$oTicket = $this->GivenTicketWithCIsOrPersons([
'ApplicationSolution_0' => 'manual'
]);
$oTicket->UpdateImpactedItems(); // impact analysis
// By default Max depth is 10. Can be changed by overriding _Ticket::GetImpactAnalysisMaxDepth
$this->assertCIsOrPersonsListEquals($oTicket, [
'ApplicationSolution_0' => 'manual',
'ApplicationSolution_1' => 'computed',
'ApplicationSolution_2' => 'computed',
'ApplicationSolution_3' => 'computed',
'ApplicationSolution_4' => 'computed',
'ApplicationSolution_5' => 'computed',
'ApplicationSolution_6' => 'computed',
'ApplicationSolution_7' => 'computed',
'ApplicationSolution_8' => 'computed',
'ApplicationSolution_9' => 'computed',
'ApplicationSolution_10' => 'computed',
]);
}
public function testImpactShouldNotBeFurtherPropagatedWhenCINotAllowed()
{
/**
@@ -445,7 +489,12 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
list($sCI, $sPerson) = explode('<->', $sLine);
$sPersonId = $this->GivenCIOrPersonInDB(trim($sPerson));
$sCIId = $this->GivenCIOrPersonInDB(trim($sCI));
$this->GivenLnkContactToFunctionalCIInDB($sPersonId, $sCIId);
if (str_starts_with(trim($sPerson),'ApplicationSolution'))
{
$this->GivenLnkApplicationSolutionToFunctionalCIInDB($sPersonId, $sCIId);
} else {
$this->GivenLnkContactToFunctionalCIInDB($sPersonId, $sCIId);
}
return;
}
list($sCIParent, $sChildren) = explode('->', $sLine);
@@ -482,6 +531,9 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
case 'VirtualMachine':
$sCIId = $this->GivenVirtualMachineInDB($sRef, $aChildrenIdsByClass['Farm']);
break;
case 'ApplicationSolution':
$sCIId = $this->GivenApplicationSolutionInDB($sRef);
break;
default:
throw new Exception("Unhandled class $sClass");
}
@@ -525,3 +577,4 @@ class UpdateImpactedItemsTest extends ItopDataTestCase
$this->ResetMetaModelQueyCacheGetObject();
}
}