From bcb42fdc8145180052bdc93c002b8dd2ea4a9fad Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Thu, 25 Jun 2026 11:17:51 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B09639=20-=20Refactor=20deletion=20plan=20?= =?UTF-8?q?handling=20with=20new=20entity=20classes=20for=20improved=20str?= =?UTF-8?q?ucture=20and=20clarity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataFeatureRemovalController.php | 2 +- .../src/Entity/DeletionPlanEntity.php | 27 +++++ .../src/Entity/DeletionPlanItem.php | 35 ++++++ .../src/Service/StaticDeletionPlan.php | 104 +++++++++++------- .../vendor/composer/autoload_classmap.php | 2 + .../vendor/composer/autoload_static.php | 2 + .../unattended-install/xml_setup/upgrade.xml | 2 +- .../AbstractCleanup.php | 14 +-- .../StaticDeletionPlanTest.php | 92 +++++++++++++--- 9 files changed, 220 insertions(+), 60 deletions(-) create mode 100644 datamodels/2.x/combodo-data-feature-removal/src/Entity/DeletionPlanEntity.php create mode 100644 datamodels/2.x/combodo-data-feature-removal/src/Entity/DeletionPlanItem.php diff --git a/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php b/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php index 299c47cfb3..28065f2cdd 100644 --- a/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php +++ b/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php @@ -274,7 +274,7 @@ class DataFeatureRemovalController extends Controller private function GetDeletionPlanSummaryTable(array $aRemovedClasses): array { $sName = 'DeletionPlanSummary'; - $oDataCleanupService = new DataCleanupService(); + $oDataCleanupService = new StaticDeletionPlan(); $aDeletionPlanSummaryEntities = $oDataCleanupService->GetCleanupSummary($aRemovedClasses); $aColumns = ['Class', 'Delete Count' , 'Update Count', 'Issue Count']; $aRows = []; diff --git a/datamodels/2.x/combodo-data-feature-removal/src/Entity/DeletionPlanEntity.php b/datamodels/2.x/combodo-data-feature-removal/src/Entity/DeletionPlanEntity.php new file mode 100644 index 0000000000..debc726abf --- /dev/null +++ b/datamodels/2.x/combodo-data-feature-removal/src/Entity/DeletionPlanEntity.php @@ -0,0 +1,27 @@ +oDelete = $oDelete ?? new DeletionPlanItem(); + $this->oUpdate = $oUpdate ?? new DeletionPlanItem(); + $this->oIssue = $oIssue ?? new DeletionPlanItem(); + } +} diff --git a/datamodels/2.x/combodo-data-feature-removal/src/Entity/DeletionPlanItem.php b/datamodels/2.x/combodo-data-feature-removal/src/Entity/DeletionPlanItem.php new file mode 100644 index 0000000000..81de7a261b --- /dev/null +++ b/datamodels/2.x/combodo-data-feature-removal/src/Entity/DeletionPlanItem.php @@ -0,0 +1,35 @@ +aQueries = $aQueries; + $this->aIds = $aIds; + } + + public function Merge(DeletionPlanItem $oItem): void + { + $this->aQueries = array_merge($this->aQueries, $oItem->aQueries); + $this->aIds = array_unique(array_merge($this->aIds, $oItem->aIds)); + } + + public function Count(): int + { + return count($this->aIds); + } +} diff --git a/datamodels/2.x/combodo-data-feature-removal/src/Service/StaticDeletionPlan.php b/datamodels/2.x/combodo-data-feature-removal/src/Service/StaticDeletionPlan.php index 28047d8723..e35ee088e5 100644 --- a/datamodels/2.x/combodo-data-feature-removal/src/Service/StaticDeletionPlan.php +++ b/datamodels/2.x/combodo-data-feature-removal/src/Service/StaticDeletionPlan.php @@ -8,35 +8,59 @@ namespace Combodo\iTop\DataFeatureRemoval\Service; use CMDBSource; +use Combodo\iTop\DataFeatureRemoval\Entity\DataCleanupSummaryEntity; +use Combodo\iTop\DataFeatureRemoval\Entity\DeletionPlanEntity; +use Combodo\iTop\DataFeatureRemoval\Entity\DeletionPlanItem; use MetaModel; class StaticDeletionPlan { + /** @var array */ private array $aDeletionPlan = []; + /** + * Get a summary of the deletion plan computed for the classes. + * The result is used for display + * + * @param array|null $aClasses + * + * @return array<\Combodo\iTop\DataFeatureRemoval\Entity\DataCleanupSummaryEntity> + * @throws \CoreException + * @throws \CoreUnexpectedValue + * @throws \MySQLException + * @throws \Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalException + */ + public function GetCleanupSummary(?array $aClasses): array + { + $aSummary = []; + $aDeletionPlan = $this->GetStaticDeletionPlan($aClasses ?? []); + + foreach ($aDeletionPlan as $sClass => $oDeletionPlanEntity) { + $oDataCleanupSummary = new DataCleanupSummaryEntity($sClass); + $oDataCleanupSummary->iUpdateCount = $oDeletionPlanEntity->oUpdate->Count(); + $oDataCleanupSummary->iDeleteCount = $oDeletionPlanEntity->oDelete->Count(); + $oDataCleanupSummary->iIssueCount = $oDeletionPlanEntity->oIssue->Count(); + + $aSummary[$sClass] = $oDataCleanupSummary; + } + + return $aSummary; + } + /** * @param array $aClasses Classes to clean entirely * - * @return array ['class' => [ - * 'delete' => [ids], - * 'delete_sql' => string, - * 'update_extkey_nullable' => [ids], - * 'update_extkey_nullable_sql' => [sSQL], - * 'update_hierarchical' => [ids], - * 'update_hierarchical_sql' => [sSQL], - * 'issue' => [id], - * ]]; + * @return array ['class' => DeletionPlanEntity]; * * @throws \CoreException */ public function GetStaticDeletionPlan(array $aClasses): array { foreach ($aClasses as $sClass) { - [$sDeleteSQL, $aIds] = $this->GetInitialClassDeletionPlan($sClass); - $this->aDeletionPlan[$sClass] = [ - 'delete' => $aIds, - 'delete_sql' => $sDeleteSQL, - ]; + $oDeletionPlanItem = $this->GetInitialClassDeletionPlan($sClass); + $oDeletionPlanEntity = new DeletionPlanEntity(); + $oDeletionPlanEntity->oDelete->Merge($oDeletionPlanItem); + $this->aDeletionPlan[$sClass] = $oDeletionPlanEntity; $this->DeletionPlanForReferencingClasses($sClass); } @@ -46,10 +70,14 @@ class StaticDeletionPlan private function DeletionPlanForReferencingClasses(string $sClass): void { - $sIdsToRemove = implode(', ', $this->aDeletionPlan[$sClass]['delete']); + $sIdsToRemove = implode(', ', $this->aDeletionPlan[$sClass]->oDelete->aIds); $aReferencingMe = MetaModel::EnumReferencingClasses($sClass); foreach ($aReferencingMe as $sRemoteClass => $aExtKeys) { $sRemoteTable = MetaModel::DBGetTable($sRemoteClass); + if (!isset($this->aDeletionPlan[$sRemoteClass])) { + $this->aDeletionPlan[$sRemoteClass] = new DeletionPlanEntity(); + } + $oDeletionPlanEntity = $this->aDeletionPlan[$sRemoteClass]; /** @var \AttributeExternalKey $oExtKeyAttDef */ foreach ($aExtKeys as $sExtKeyAttCode => $oExtKeyAttDef) { // skip if this external key is behind an external field @@ -59,9 +87,8 @@ class StaticDeletionPlan if ($oExtKeyAttDef->IsNullAllowed()) { // update - [$sUpdateSQL, $aIds] = $this->UpdateExtKeyNullable($sRemoteTable, $sExtKeyAttCode, $sIdsToRemove); - $this->aDeletionPlan[$sRemoteClass]['update_extkey_nullable_sql'][$sExtKeyAttCode] = $sUpdateSQL; - $this->aDeletionPlan[$sRemoteClass]['update_extkey_nullable'] = array_unique(array_merge($this->aDeletionPlan[$sRemoteClass]['update_extkey_nullable'] ?? [], $aIds)); + $oUpdateItem = $this->UpdateExtKeyNullable($sRemoteTable, $sExtKeyAttCode, $sIdsToRemove); + $oDeletionPlanEntity->oUpdate->Merge($oUpdateItem); } else { // delete $aRemoteIdsToRemove = $this->GetRemoteIdsForExtKey($sRemoteTable, $sExtKeyAttCode, $sIdsToRemove); @@ -69,28 +96,28 @@ class StaticDeletionPlan $iDeletePropagationOption = $oExtKeyAttDef->GetDeletionPropagationOption(); if ($iDeletePropagationOption == DEL_MANUAL) { // Issue, do not recurse - if (count($aRemoteIdsToRemove) > 0) { - $this->aDeletionPlan[$sRemoteClass]['issue'] = array_unique(array_merge($this->aDeletionPlan[$sRemoteClass]['issue'] ?? [], $aRemoteIdsToRemove)); - } + $oDeletionPlanItem = new DeletionPlanItem(aIds: $aRemoteIdsToRemove); + $oDeletionPlanEntity->oIssue->Merge($oDeletionPlanItem); continue; } if (($iDeletePropagationOption == DEL_MOVEUP) && ($oExtKeyAttDef->IsHierarchicalKey())) { // update hierarchical keys due to row cleanup in the same table - $sIdsToRemove = implode(',', $this->aDeletionPlan[$sRemoteClass]['delete']); - [$sUpdateSQL, $aIds] = $this->UpdateHierarchicalExtKey($sRemoteTable, $sExtKeyAttCode, $sIdsToRemove); - $this->aDeletionPlan[$sRemoteClass]['update_hierarchical_sql'][$sExtKeyAttCode] = $sUpdateSQL; - $this->aDeletionPlan[$sRemoteClass]['update_hierarchical'] = array_unique(array_merge($this->aDeletionPlan[$sRemoteClass]['update_hierarchical'] ?? [], $aIds)); + $sIdsToRemove = implode(',', $this->aDeletionPlan[$sRemoteClass]->oDelete->aIds); + $oUpdateItem = $this->UpdateHierarchicalExtKey($sRemoteTable, $sExtKeyAttCode, $sIdsToRemove); + $oDeletionPlanEntity->oUpdate->Merge($oUpdateItem); // do not recurse continue; } // Delete entries in Remote Class - $this->aDeletionPlan[$sRemoteClass]['delete'] = array_unique(array_merge($this->aDeletionPlan[$sRemoteClass]['delete'] ?? [], $aRemoteIdsToRemove)); - $sRemoteIdsToDelete = implode(',', $aRemoteIdsToRemove); - $this->aDeletionPlan[$sRemoteClass]['delete_sql'] = "DELETE FROM $sRemoteTable WHERE id IN ($sRemoteIdsToDelete)"; + if (count($aRemoteIdsToRemove) !== 0) { + $sRemoteIdsToDelete = implode(',', $aRemoteIdsToRemove); + $sSQL = "DELETE FROM $sRemoteTable WHERE id IN ($sRemoteIdsToDelete)"; + $oDeletionPlanEntity->oDelete->Merge(new DeletionPlanItem([$sSQL], $aRemoteIdsToRemove)); - $this->DeletionPlanForReferencingClasses($sRemoteClass); + $this->DeletionPlanForReferencingClasses($sRemoteClass); + } } } } @@ -101,9 +128,9 @@ class StaticDeletionPlan * @param string $sExtKeyAttCode * @param string $sIdsToRemoveInTargetClass * - * @return array + * @return \Combodo\iTop\DataFeatureRemoval\Entity\DeletionPlanItem */ - public function UpdateExtKeyNullable(string $sRemoteTable, string $sExtKeyAttCode, string $sIdsToRemoveInTargetClass): array + public function UpdateExtKeyNullable(string $sRemoteTable, string $sExtKeyAttCode, string $sIdsToRemoveInTargetClass): DeletionPlanItem { $aIds = $this->GetRemoteIdsForExtKey($sRemoteTable, $sExtKeyAttCode, $sIdsToRemoveInTargetClass); @@ -113,10 +140,10 @@ FROM $sRemoteTable AS updated WHERE updated.$sExtKeyAttCode IN ($sIdsToRemoveInTargetClass) SQL; - return [$sUpdateSQL, $aIds]; + return new DeletionPlanItem([$sExtKeyAttCode => $sUpdateSQL], $aIds); } - public function UpdateHierarchicalExtKey(string $sRemoteTable, string $sExtKeyAttCode, string $sIdsToRemoveInTargetClass): array + public function UpdateHierarchicalExtKey(string $sRemoteTable, string $sExtKeyAttCode, string $sIdsToRemoveInTargetClass): DeletionPlanItem { $sUpdateSQL = << $sUpdateSQL], $aIds); } public function GetRemoteIdsForExtKey(string $sRemoteTable, string $sExtKeyAttCode, string $sIdsToRemoveInTargetClass): array { + if (\utils::IsNullOrEmptyString($sIdsToRemoveInTargetClass)) { + return []; + } $sSQL = "SELECT id FROM $sRemoteTable WHERE $sExtKeyAttCode IN ($sIdsToRemoveInTargetClass)"; return CMDBSource::QueryToCol($sSQL, 'id'); @@ -146,18 +176,18 @@ SQL; /** * @param string $sClass * - * @return array + * @return \Combodo\iTop\DataFeatureRemoval\Entity\DeletionPlanItem * @throws \CoreException * @throws \MySQLException */ - public function GetInitialClassDeletionPlan(string $sClass): array + public function GetInitialClassDeletionPlan(string $sClass): DeletionPlanItem { $sTable = MetaModel::DBGetTable($sClass); $sSQL = "SELECT id FROM $sTable"; $aIds = CMDBSource::QueryToCol($sSQL, 'id'); $sDeleteSQL = "DELETE FROM $sTable"; - return [$sDeleteSQL, $aIds]; + return new DeletionPlanItem([$sDeleteSQL], $aIds); } } diff --git a/datamodels/2.x/combodo-data-feature-removal/vendor/composer/autoload_classmap.php b/datamodels/2.x/combodo-data-feature-removal/vendor/composer/autoload_classmap.php index 6527138d59..b8d4886620 100644 --- a/datamodels/2.x/combodo-data-feature-removal/vendor/composer/autoload_classmap.php +++ b/datamodels/2.x/combodo-data-feature-removal/vendor/composer/autoload_classmap.php @@ -8,6 +8,8 @@ $baseDir = dirname($vendorDir); return array( 'Combodo\\iTop\\DataFeatureRemoval\\Controller\\DataFeatureRemovalController' => $baseDir . '/src/Controller/DataFeatureRemovalController.php', 'Combodo\\iTop\\DataFeatureRemoval\\Entity\\DataCleanupSummaryEntity' => $baseDir . '/src/Entity/DataCleanupSummaryEntity.php', + 'Combodo\\iTop\\DataFeatureRemoval\\Entity\\DeletionPlanEntity' => $baseDir . '/src/Entity/DeletionPlanEntity.php', + 'Combodo\\iTop\\DataFeatureRemoval\\Entity\\DeletionPlanItem' => $baseDir . '/src/Entity/DeletionPlanItem.php', 'Combodo\\iTop\\DataFeatureRemoval\\Helper\\DataFeatureRemovalConfig' => $baseDir . '/src/Helper/DataFeatureRemovalConfig.php', 'Combodo\\iTop\\DataFeatureRemoval\\Helper\\DataFeatureRemovalException' => $baseDir . '/src/Helper/DataFeatureRemovalException.php', 'Combodo\\iTop\\DataFeatureRemoval\\Helper\\DataFeatureRemovalHelper' => $baseDir . '/src/Helper/DataFeatureRemovalHelper.php', diff --git a/datamodels/2.x/combodo-data-feature-removal/vendor/composer/autoload_static.php b/datamodels/2.x/combodo-data-feature-removal/vendor/composer/autoload_static.php index 06de56135f..a86266cd44 100644 --- a/datamodels/2.x/combodo-data-feature-removal/vendor/composer/autoload_static.php +++ b/datamodels/2.x/combodo-data-feature-removal/vendor/composer/autoload_static.php @@ -23,6 +23,8 @@ class ComposerStaticInit4f96a7199e2c0d90e547333758b26464 public static $classMap = array ( 'Combodo\\iTop\\DataFeatureRemoval\\Controller\\DataFeatureRemovalController' => __DIR__ . '/../..' . '/src/Controller/DataFeatureRemovalController.php', 'Combodo\\iTop\\DataFeatureRemoval\\Entity\\DataCleanupSummaryEntity' => __DIR__ . '/../..' . '/src/Entity/DataCleanupSummaryEntity.php', + 'Combodo\\iTop\\DataFeatureRemoval\\Entity\\DeletionPlanEntity' => __DIR__ . '/../..' . '/src/Entity/DeletionPlanEntity.php', + 'Combodo\\iTop\\DataFeatureRemoval\\Entity\\DeletionPlanItem' => __DIR__ . '/../..' . '/src/Entity/DeletionPlanItem.php', 'Combodo\\iTop\\DataFeatureRemoval\\Helper\\DataFeatureRemovalConfig' => __DIR__ . '/../..' . '/src/Helper/DataFeatureRemovalConfig.php', 'Combodo\\iTop\\DataFeatureRemoval\\Helper\\DataFeatureRemovalException' => __DIR__ . '/../..' . '/src/Helper/DataFeatureRemovalException.php', 'Combodo\\iTop\\DataFeatureRemoval\\Helper\\DataFeatureRemovalHelper' => __DIR__ . '/../..' . '/src/Helper/DataFeatureRemovalHelper.php', diff --git a/setup/unattended-install/xml_setup/upgrade.xml b/setup/unattended-install/xml_setup/upgrade.xml index 0272bd2551..bef34398af 100644 --- a/setup/unattended-install/xml_setup/upgrade.xml +++ b/setup/unattended-install/xml_setup/upgrade.xml @@ -41,5 +41,5 @@ - off + on diff --git a/tests/php-unit-tests/unitary-tests/datamodels/2.x/combodo-data-feature-removal/AbstractCleanup.php b/tests/php-unit-tests/unitary-tests/datamodels/2.x/combodo-data-feature-removal/AbstractCleanup.php index 61891dc5d9..cc292574b3 100644 --- a/tests/php-unit-tests/unitary-tests/datamodels/2.x/combodo-data-feature-removal/AbstractCleanup.php +++ b/tests/php-unit-tests/unitary-tests/datamodels/2.x/combodo-data-feature-removal/AbstractCleanup.php @@ -6,7 +6,6 @@ */ use Combodo\iTop\Test\UnitTest\ItopCustomDatamodelTestCase; -use Combodo\iTop\Test\UnitTest\ItopDataTestCase; class AbstractCleanup extends ItopCustomDatamodelTestCase { @@ -45,12 +44,13 @@ class AbstractCleanup extends ItopCustomDatamodelTestCase $sRight = trim($sRight); if (preg_match("/(?(?[^_]+)_\d+)(\s+\((?\w+)\))?/", $sRight, $aMatches) !== false) { + $sName = $aMatches['name']; + $sChildClass = $aMatches['class']; + $sExtKey = $aMatches['extkey'] ?? 'extkey_id'; + + $iRightId = $this->GivenObjectInDB($sChildClass, ['name' => $sName, $sExtKey => $iLeftId]); + $this->aIdByClass[$sChildClass][] = $iRightId; + $this->aIdByObjectName[$sRight] = $iRightId; } - - [$sChildClass] = explode('_', $sRight, 2); - - $iRightId = $this->GivenObjectInDB($sChildClass, ['name' => $sRight, 'extkey_id' => $iLeftId]); - $this->aIdByClass[$sChildClass][] = $iRightId; - $this->aIdByObjectName[$sRight] = $iRightId; } } diff --git a/tests/php-unit-tests/unitary-tests/datamodels/2.x/combodo-data-feature-removal/StaticDeletionPlanTest.php b/tests/php-unit-tests/unitary-tests/datamodels/2.x/combodo-data-feature-removal/StaticDeletionPlanTest.php index 406d855a8b..5f88460d1f 100644 --- a/tests/php-unit-tests/unitary-tests/datamodels/2.x/combodo-data-feature-removal/StaticDeletionPlanTest.php +++ b/tests/php-unit-tests/unitary-tests/datamodels/2.x/combodo-data-feature-removal/StaticDeletionPlanTest.php @@ -7,6 +7,8 @@ namespace Combodo\iTop\Test\UnitTest\Module\DataFeatureRemoval; * @license http://opensource.org/licenses/AGPL-3.0 */ +use Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalException; +use Combodo\iTop\DataFeatureRemoval\Service\DataCleanupService; use Combodo\iTop\DataFeatureRemoval\Service\StaticDeletionPlan; use MetaModel; @@ -26,12 +28,12 @@ class StaticDeletionPlanTest extends \AbstractCleanup EOF); $oService = new StaticDeletionPlan(); - $aRes = $oService->GetInitialClassDeletionPlan('DFRToRemoveLeaf'); - self::assertCount(2, $aRes[1]); - self::assertEquals($this->aIdByClass['DFRToRemoveLeaf'], $aRes[1]); + $oDeletionPlanItem = $oService->GetInitialClassDeletionPlan('DFRToRemoveLeaf'); + self::assertEquals(2, $oDeletionPlanItem->Count()); + self::assertEquals($this->aIdByClass['DFRToRemoveLeaf'], $oDeletionPlanItem->aIds); $sTable = MetaModel::DBGetTable('DFRToRemoveLeaf'); $sExpectedSQL = "DELETE FROM $sTable"; - self::assertEquals($sExpectedSQL, $aRes[0]); + self::assertEquals($sExpectedSQL, $oDeletionPlanItem->aQueries[0]); } public function testUpdateExtKeyNullable() @@ -46,23 +48,22 @@ class StaticDeletionPlanTest extends \AbstractCleanup // WHEN $oService = new StaticDeletionPlan(); $sRemoteTable = MetaModel::DBGetTable('DFRToUpdate'); - $aRes = $oService->UpdateExtKeyNullable( + $oDeletionPlanItem = $oService->UpdateExtKeyNullable( $sRemoteTable, 'extkey_id', implode(',', $this->aIdByClass['DFRToRemoveLeaf']) ); - $sUpdateSQL = $aRes[0]; - $aIds = $aRes[1]; + $sUpdateSQL = $oDeletionPlanItem->aQueries['extkey_id']; // THEN $sExpectedSQLEnd = " IN (".implode(',', $this->aIdByClass['DFRToRemoveLeaf']).")"; self::assertStringEndsWith($sExpectedSQLEnd, $sUpdateSQL); - self::assertCount(3, $aIds); + self::assertEquals(3, $oDeletionPlanItem->Count()); $sIdsToRemoveInTargetClass = implode(',', $this->aIdByClass['DFRToRemoveLeaf']); $aExpectedIds = $oService->GetRemoteIdsForExtKey($sRemoteTable, 'extkey_id', $sIdsToRemoveInTargetClass); - self::assertEquals($aExpectedIds, $aIds); + self::assertEquals($aExpectedIds, $oDeletionPlanItem->aIds); // var_export($aRes); // var_export($this->aIdByClass); @@ -80,7 +81,7 @@ class StaticDeletionPlanTest extends \AbstractCleanup $this->assertEmpty($aResult, 'Expected result to be empty array when input is null.'); } - public function testExecuteCleanup_DeleteOneObjPerClass() + public function testGetStaticDeletionPlan_DeleteObjRecursively() { $this->GivenDFRTreeInDB(<<GetStaticDeletionPlan($aClasses); - var_export($aRes); + self::assertArrayHasKey('DFRRemovedCollateralCascade', $aRes); - var_export($this->aIdByClass); - - self::assertTrue(true); + // echo json_encode($aRes, JSON_PRETTY_PRINT)."\n"; + // echo json_encode($this->aIdByClass, JSON_PRETTY_PRINT); } + + public function testGetStaticDeletionPlan_IssuesArePresent() + { + $this->GivenDFRTreeInDB(<<expectException(DataFeatureRemovalException::class); + // $this->expectExceptionMessage('Deletion Plan cannot be executed due to issues'); + $oService = new StaticDeletionPlan(); + $aRes = $oService->GetStaticDeletionPlan($aClasses); + + self::assertEquals(1, $aRes['DFRManual']->oIssue->Count()); + self::assertEquals($this->aIdByClass['DFRManual'], $aRes['DFRManual']->oIssue->aIds); + + // echo json_encode($aRes, JSON_PRETTY_PRINT)."\n"; + // echo json_encode($this->aIdByClass, JSON_PRETTY_PRINT); + + } + + public function testGetStaticDeletionPlan_UpdateMultipleExtKeys() + { + $this->GivenDFRTreeInDB(<<GetStaticDeletionPlan($aClasses); + + self::assertArrayHasKey('DFRToUpdate', $aRes); + + echo json_encode($aRes, JSON_PRETTY_PRINT)."\n"; + echo json_encode($this->aIdByClass, JSON_PRETTY_PRINT); + } + + public function testGetCleanupSummary() + { + $this->GivenDFRTreeInDB(<<GetCleanupSummary($aClasses); + + echo json_encode($aRes, JSON_PRETTY_PRINT)."\n"; + echo json_encode($this->aIdByClass, JSON_PRETTY_PRINT); + + self::assertEquals(1, $aRes['DFRManual']->iIssueCount); + + } + }