From 4d2da15c96e02ee7d09834fa03b1907b654a77bd Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Thu, 25 Jun 2026 13:44:02 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B09639=20-=20Add=20messages=20to=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StaticDeletionPlanTest.php | 39 ++++++------------- 1 file changed, 12 insertions(+), 27 deletions(-) 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 32060477c3..9e4e04158f 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 @@ -29,11 +29,11 @@ class StaticDeletionPlanTest extends \AbstractCleanup $oService = new StaticDeletionPlan(); $oDeletionPlanItem = $oService->GetInitialClassDeletionPlan('DFRToRemoveLeaf'); - self::assertEquals(2, $oDeletionPlanItem->Count()); - self::assertEquals($this->aIdByClass['DFRToRemoveLeaf'], $oDeletionPlanItem->aIds); + self::assertEquals(2, $oDeletionPlanItem->Count(), 'All entries of root table should be removed'); + self::assertEquals($this->aIdByClass['DFRToRemoveLeaf'], $oDeletionPlanItem->aIds, 'All the Ids found in root table should correspond to the one created'); $sTable = MetaModel::DBGetTable('DFRToRemoveLeaf'); $sExpectedSQL = "DELETE FROM $sTable"; - self::assertEquals($sExpectedSQL, $oDeletionPlanItem->aQueries[0]); + self::assertEquals($sExpectedSQL, $oDeletionPlanItem->aQueries[0], 'Removing elements in root class should suppress all entries'); } public function testUpdateExtKeyNullable() @@ -57,16 +57,13 @@ class StaticDeletionPlanTest extends \AbstractCleanup // THEN $sExpectedSQLEnd = " IN (".implode(',', $this->aIdByClass['DFRToRemoveLeaf']).")"; - self::assertStringEndsWith($sExpectedSQLEnd, $sUpdateSQL); + self::assertStringEndsWith($sExpectedSQLEnd, $sUpdateSQL, 'The query should be filtered with the ids of the root class'); - self::assertEquals(3, $oDeletionPlanItem->Count()); + self::assertEquals(3, $oDeletionPlanItem->Count(), 'All entries of root table should be removed'); $sIdsToRemoveInTargetClass = implode(',', $this->aIdByClass['DFRToRemoveLeaf']); $aExpectedIds = $oService->GetRemoteIdsForExtKey($sRemoteClass, 'extkey_id', $sIdsToRemoveInTargetClass); - self::assertEquals($aExpectedIds, $oDeletionPlanItem->aIds); - - // var_export($aRes); - // var_export($this->aIdByClass); + self::assertEquals($aExpectedIds, $oDeletionPlanItem->aIds, 'All entries pointing on root class should be removed'); } /** @@ -94,7 +91,7 @@ class StaticDeletionPlanTest extends \AbstractCleanup $oService = new StaticDeletionPlan(); $aRes = $oService->GetStaticDeletionPlan($aClasses); - self::assertArrayHasKey('DFRRemovedCollateralCascade', $aRes); + self::assertArrayHasKey('DFRRemovedCollateralCascade', $aRes, 'The cleanup should descend to the cascaded classes'); // echo json_encode($aRes, JSON_PRETTY_PRINT)."\n"; // echo json_encode($this->aIdByClass, JSON_PRETTY_PRINT); @@ -111,17 +108,11 @@ class StaticDeletionPlanTest extends \AbstractCleanup EOF); $aClasses = [ 'DFRToRemoveLeaf' ]; - // $this->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); - + self::assertEquals(1, $aRes['DFRManual']->oIssue->Count(), 'Issue should be found because of DEL_MANUAL deletion policy'); + self::assertEquals($this->aIdByClass['DFRManual'], $aRes['DFRManual']->oIssue->aIds, 'Issue should be correspond to the entries created'); } public function testGetStaticDeletionPlan_UpdateMultipleExtKeys() @@ -136,10 +127,8 @@ class StaticDeletionPlanTest extends \AbstractCleanup $oService = new StaticDeletionPlan(); $aRes = $oService->GetStaticDeletionPlan($aClasses); - self::assertArrayHasKey('DFRToUpdate', $aRes); - - echo json_encode($aRes, JSON_PRETTY_PRINT)."\n"; - echo json_encode($this->aIdByClass, JSON_PRETTY_PRINT); + self::assertArrayHasKey('DFRToUpdate', $aRes, 'Class to update should be targeted'); + self::assertEquals(2, $aRes['DFRToUpdate']->oUpdate->Count(), 'Update should be counted only for removed pointed classes'); } public function testGetCleanupSummary() @@ -156,11 +145,7 @@ class StaticDeletionPlanTest extends \AbstractCleanup $oService = new StaticDeletionPlan(); $aRes = $oService->GetCleanupSummary($aClasses); - echo json_encode($aRes, JSON_PRETTY_PRINT)."\n"; - echo json_encode($this->aIdByClass, JSON_PRETTY_PRINT); - - self::assertEquals(1, $aRes['DFRManual']->iIssueCount); - + self::assertEquals(1, $aRes['DFRManual']->iIssueCount, 'Issue should have been detected during cleanup count'); } }