mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 15:22:17 +02:00
N°9412 - Analysis results screen wip
This commit is contained in:
@@ -69,7 +69,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
||||
|
||||
$aClasses = [ 'DFRToRemoveLeaf' ];
|
||||
$oService = new DataCleanupService();
|
||||
$aRes = $oService->ExecuteCleanup($aClasses);
|
||||
$aRes = $oService->ExecuteCleanup($aClasses, []);
|
||||
$aExpected = [
|
||||
['DFRToUpdate', 1, 0 ],
|
||||
['DFRToRemoveLeaf', 0, 1 ],
|
||||
@@ -97,7 +97,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
||||
|
||||
$aClasses = [ 'DFRToRemoveLeaf' ];
|
||||
$oService = new DataCleanupService();
|
||||
$aRes = $oService->ExecuteCleanup($aClasses);
|
||||
$aRes = $oService->ExecuteCleanup($aClasses, []);
|
||||
$aExpected = [
|
||||
['DFRToUpdate', 3, 0 ],
|
||||
['DFRToRemoveLeaf', 0, 3 ],
|
||||
@@ -107,6 +107,59 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
||||
$this->AssertSummaryEquals($aExpected, $aRes);
|
||||
}
|
||||
|
||||
public function testExecuteCleanup_CheckSummaryIsEnrichedAfterEachPass()
|
||||
{
|
||||
$aExecutionSummary = [];
|
||||
|
||||
$this->GivenDFRTreeInDB(
|
||||
<<<EOF
|
||||
DFRToRemoveLeaf_1 <- DFRToUpdate_1
|
||||
DFRToRemoveLeaf_1 <- DFRRemovedCollateral_1
|
||||
DFRRemovedCollateral_1 <- DFRRemovedCollateralCascade_1
|
||||
|
||||
DFRToRemoveLeaf_2 <- DFRToUpdate_2
|
||||
DFRToRemoveLeaf_2 <- DFRRemovedCollateral_2
|
||||
DFRRemovedCollateral_2 <- DFRRemovedCollateralCascade_2
|
||||
|
||||
DFRToRemoveLeaf_3 <- DFRToUpdate_3
|
||||
DFRToRemoveLeaf_3 <- DFRRemovedCollateral_3
|
||||
DFRRemovedCollateral_3 <- DFRRemovedCollateralCascade_3
|
||||
EOF
|
||||
);
|
||||
|
||||
$aClasses = ['DFRToRemoveLeaf'];
|
||||
$oService = new DataCleanupService();
|
||||
$aExecutionSummary = $oService->ExecuteCleanup($aClasses, $aExecutionSummary);
|
||||
|
||||
$aExpected = [
|
||||
['DFRToUpdate', 3, 0 ],
|
||||
['DFRToRemoveLeaf', 0, 3 ],
|
||||
['DFRRemovedCollateral', 0, 3 ],
|
||||
['DFRRemovedCollateralCascade', 0, 3 ],
|
||||
];
|
||||
$this->AssertSummaryEquals($aExpected, $aExecutionSummary);
|
||||
|
||||
$this->GivenDFRTreeInDB(
|
||||
<<<EOF
|
||||
DFRToRemoveLeaf_4 <- DFRToUpdate_4
|
||||
DFRToRemoveLeaf_4 <- DFRRemovedCollateral_4
|
||||
DFRRemovedCollateral_4 <- DFRRemovedCollateralCascade_4
|
||||
EOF
|
||||
);
|
||||
|
||||
$aClasses = ['DFRToRemoveLeaf'];
|
||||
$oService = new DataCleanupService();
|
||||
$aExecutionSummary = $oService->ExecuteCleanup($aClasses, $aExecutionSummary);
|
||||
|
||||
$aExpected = [
|
||||
['DFRToUpdate', 1, 0, 0, 4 ],
|
||||
['DFRToRemoveLeaf', 0, 1, 0, 0, 4 ],
|
||||
['DFRRemovedCollateral', 0, 1, 0, 0, 4 ],
|
||||
['DFRRemovedCollateralCascade', 0, 1, 0, 0, 4 ],
|
||||
];
|
||||
$this->AssertSummaryEquals($aExpected, $aExecutionSummary);
|
||||
}
|
||||
|
||||
public function testGetCleanupSummary_DeleteManyObjPerClassWithoutLimit()
|
||||
{
|
||||
$this->GivenDFRTreeInDB(<<<EOF
|
||||
@@ -145,7 +198,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
||||
$this->expectException(DataFeatureRemovalException::class);
|
||||
$this->expectExceptionMessage('Deletion Plan cannot be executed due to issues');
|
||||
$oService = new DataCleanupService();
|
||||
$oService->ExecuteCleanup($aClasses);
|
||||
$oService->ExecuteCleanup($aClasses, []);
|
||||
}
|
||||
|
||||
public function testGetCleanupSummary_ManualDeleteShouldFail()
|
||||
@@ -174,11 +227,16 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
||||
$iUpdate = $line[1];
|
||||
$iDelete = $line[2];
|
||||
$iIssue = $line[3] ?? 0;
|
||||
$iTotalUpdate = $line[4] ?? $iUpdate;
|
||||
$iTotalDelete = $line[5] ?? $iDelete;
|
||||
|
||||
$oCleanupSummaryEntity = new DataCleanupSummaryEntity($sClass);
|
||||
$oCleanupSummaryEntity->iUpdateCount = $iUpdate;
|
||||
$oCleanupSummaryEntity->iDeleteCount = $iDelete;
|
||||
$oCleanupSummaryEntity->iIssueCount = $iIssue;
|
||||
$oCleanupSummaryEntity->iTotalUpdateCount = $iTotalUpdate;
|
||||
$oCleanupSummaryEntity->iTotalDeleteCount = $iTotalDelete;
|
||||
|
||||
$aExpected[$sClass] = $oCleanupSummaryEntity;
|
||||
}
|
||||
$this->assertEquals($aExpected, $actual, $sMessage);
|
||||
@@ -252,7 +310,7 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
||||
$oDeletionPlaService = new DataCleanupService();
|
||||
$this->GivenExecutionLimits($iExecutionCount);
|
||||
$this->SetNonPublicProperty($oDeletionPlaService, 'oExecutionLimits', $this->oExecutionLimits);
|
||||
$aRes = $oDeletionPlaService->ExecuteCleanup($aClasses);
|
||||
$aRes = $oDeletionPlaService->ExecuteCleanup($aClasses, []);
|
||||
$this->AssertSummaryEquals($aExpected, $aRes);
|
||||
}
|
||||
|
||||
@@ -270,18 +328,18 @@ class DataCleanupServiceTest extends ItopCustomDatamodelTestCase
|
||||
private array $aIdByObjectName = [];
|
||||
private function GivenDFRTreeLineInDB(string $sLine)
|
||||
{
|
||||
list($sLeft, $sRight) = explode('<-', $sLine);
|
||||
[$sLeft, $sRight] = explode('<-', $sLine);
|
||||
$sLeft = trim($sLeft);
|
||||
|
||||
$iLeftId = $this->aIdByObjectName[$sLeft] ?? 0;
|
||||
if ($iLeftId === 0) {
|
||||
list($sChildClass, ) = explode('_', $sLeft, 2);
|
||||
[$sChildClass, ] = explode('_', $sLeft, 2);
|
||||
$iLeftId = $this->GivenObjectInDB($sChildClass, ['name' => $sLeft]);
|
||||
$this->aIdByObjectName[$sLeft] = $iLeftId;
|
||||
}
|
||||
|
||||
$sRight = trim($sRight);
|
||||
list($sChildClass, ) = explode('_', $sRight, 2);
|
||||
[$sChildClass, ] = explode('_', $sRight, 2);
|
||||
$iRightId = $this->GivenObjectInDB($sChildClass, ['name' => $sRight, 'extkey_id' => $iLeftId]);
|
||||
$this->aIdByObjectName[$sRight] = $iRightId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user