mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-20 07:42:17 +02:00
fix test + phpstan feedbacks
This commit is contained in:
@@ -20,12 +20,14 @@ class DataFeatureRemovalBackgroundTask implements iBackgroundProcess
|
|||||||
*/
|
*/
|
||||||
public function Process($iUnixTimeLimit)
|
public function Process($iUnixTimeLimit)
|
||||||
{
|
{
|
||||||
|
$iCount = 0;
|
||||||
while ($oBackgroundOperation = BackgroundOperationService::GetInstance()->GetNext()) {
|
while ($oBackgroundOperation = BackgroundOperationService::GetInstance()->GetNext()) {
|
||||||
$aClasses = BackgroundOperationService::GetInstance()->GetClasses($oBackgroundOperation);
|
$aClasses = BackgroundOperationService::GetInstance()->GetClasses($oBackgroundOperation);
|
||||||
$aRes = DeletionPlanService::GetInstance()->ExecuteDeletionPlan($aClasses, $iUnixTimeLimit);
|
$aRes = DeletionPlanService::GetInstance()->ExecuteDeletionPlan($aClasses, $iUnixTimeLimit);
|
||||||
|
|
||||||
IssueLog::Info(__METHOD__, null, $aRes);
|
IssueLog::Info(__METHOD__, null, $aRes);
|
||||||
|
|
||||||
IssueLog::Info(__METHOD__, null, [
|
IssueLog::Debug(__METHOD__, null, [
|
||||||
'$iUnixTimeLimit' => $iUnixTimeLimit,
|
'$iUnixTimeLimit' => $iUnixTimeLimit,
|
||||||
'time' => time(),
|
'time' => time(),
|
||||||
'timeout reached' => DataFeatureRemovalHelper::IsTimeLimitExceeded($iUnixTimeLimit),
|
'timeout reached' => DataFeatureRemovalHelper::IsTimeLimitExceeded($iUnixTimeLimit),
|
||||||
@@ -33,12 +35,14 @@ class DataFeatureRemovalBackgroundTask implements iBackgroundProcess
|
|||||||
|
|
||||||
if (DataFeatureRemovalHelper::IsTimeLimitExceeded($iUnixTimeLimit)) {
|
if (DataFeatureRemovalHelper::IsTimeLimitExceeded($iUnixTimeLimit)) {
|
||||||
//timeout reached
|
//timeout reached
|
||||||
return;
|
return "Handled $iCount operations.";
|
||||||
}
|
}
|
||||||
|
|
||||||
//execution finished before timeout: nothing left to remove
|
//execution finished before timeout: nothing left to remove
|
||||||
$oBackgroundOperation->DBDelete();
|
$oBackgroundOperation->DBDelete();
|
||||||
|
$iCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return "Handled $iCount operations.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use Combodo\iTop\Test\UnitTest\ItopCustomDatamodelTestCase;
|
|||||||
use DeletionPlan;
|
use DeletionPlan;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for the DeletionPlanService class in the Combodo Data Feature Removal module.
|
* Unit tests for the DeletionPlanService cf Combodo Data Feature Removal module.
|
||||||
*
|
*
|
||||||
* These tests cover:
|
* These tests cover:
|
||||||
* - GetDeletionPlanSummary method: handling null and empty input, and verifying summary output for various delete/update scenarios.
|
* - GetDeletionPlanSummary method: handling null and empty input, and verifying summary output for various delete/update scenarios.
|
||||||
@@ -34,12 +34,6 @@ use DeletionPlan;
|
|||||||
*/
|
*/
|
||||||
class DeletionPlanServiceTest extends ItopCustomDatamodelTestCase
|
class DeletionPlanServiceTest extends ItopCustomDatamodelTestCase
|
||||||
{
|
{
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
$this->RequireOnceItopFile('env-production/combodo-data-feature-removal/vendor/autoload.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
//--- GetDeletionPlanSummary tests ---
|
//--- GetDeletionPlanSummary tests ---
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -255,8 +249,6 @@ class DeletionPlanServiceTest extends ItopCustomDatamodelTestCase
|
|||||||
*/
|
*/
|
||||||
public function testExecuteDeletionPlanThrowsExceptionWhenIssuesExist(): void
|
public function testExecuteDeletionPlanThrowsExceptionWhenIssuesExist(): void
|
||||||
{
|
{
|
||||||
$this->RequireOnceItopFile('env-production/combodo-data-feature-removal/src/Helper/DataFeatureRemovalException.php');
|
|
||||||
|
|
||||||
$oDeletionPlan = $this->createMock(DeletionPlan::class);
|
$oDeletionPlan = $this->createMock(DeletionPlan::class);
|
||||||
$oDeletionPlan->method('GetIssues')->willReturn(['Some issue']);
|
$oDeletionPlan->method('GetIssues')->willReturn(['Some issue']);
|
||||||
$oDeletionPlan->method('ListDeletes')->willReturn([]);
|
$oDeletionPlan->method('ListDeletes')->willReturn([]);
|
||||||
|
|||||||
Reference in New Issue
Block a user