From 5f3fda95fcecb51e12af87743b296079cfdcf44b Mon Sep 17 00:00:00 2001 From: odain Date: Thu, 1 Apr 2021 18:32:02 +0200 Subject: [PATCH] ci enhance DatasynchroTest --- test/synchro/DataSynchroTest.php | 69 ++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/test/synchro/DataSynchroTest.php b/test/synchro/DataSynchroTest.php index bc759f2d0..db62b4e57 100644 --- a/test/synchro/DataSynchroTest.php +++ b/test/synchro/DataSynchroTest.php @@ -82,18 +82,6 @@ class DataSynchroTest extends ItopDataTestCase /** * Run a series of data synchronization through the REST API - * - * @dataProvider SynchroScenariosProvider - * - * @param $sDescription - * @param $sTargetClass - * @param $aSourceProperties - * @param $aSourceData - * @param $aTargetData - * @param $aAttributes - * - * @param bool $bSynchroByHttp - * * @throws \ArchivedObjectException * @throws \CoreCannotSaveObjectException * @throws \CoreException @@ -102,9 +90,16 @@ class DataSynchroTest extends ItopDataTestCase * @throws \MySQLException * @throws \OQLException */ - public function testSynchroImportPage($sDescription, $sTargetClass, $aSourceProperties, $aSourceData, $aTargetData, $aAttributes, $bSynchroByHttp) + public function RunDataSynchroTest($aUserLoginUsecase) { - var_dump($bSynchroByHttp); + $sDescription = $aUserLoginUsecase['desc']; + $sTargetClass = $aUserLoginUsecase['target_class']; + $aSourceProperties = $aUserLoginUsecase['source_properties']; + $aSourceData = $aUserLoginUsecase['source_data']; + $aTargetData = $aUserLoginUsecase['target_data']; + $aAttributes =$aUserLoginUsecase['attributes']; + $bSynchroByHttp = $aUserLoginUsecase['bSynchroByHttp']; + $sClass = $sTargetClass; $aTargetAttributes = array_shift($aTargetData); @@ -319,7 +314,7 @@ class DataSynchroTest extends ItopDataTestCase $aKeys = ["creation", "update", "deletion"]; foreach ($aKeys as $sKey){ - $this->assertContains("$sKey errors: 0", $sResultsViewable); + $this->assertContains("$sKey errors: 0", $sResultsViewable, $sResultsViewable); } //N°3805 : potential javascript returned like @@ -343,10 +338,8 @@ class DataSynchroTest extends ItopDataTestCase } } - public function SynchroScenariosProvider() - { - $aTestCases = array(); - $aUserLoginUsecase = array( + private function GetNominalUsecaseData(){ + return array( 'desc' => 'Load user logins', 'target_class' => 'UserLocal', 'source_properties' => array( @@ -391,13 +384,20 @@ class DataSynchroTest extends ItopDataTestCase ), 'bSynchroByHttp' => false ); + } - $aTestCases['Load user logins'] = $aUserLoginUsecase; - $aTestCases['Load user logins by http'] = $aUserLoginUsecase; - $aTestCases['Load user logins by http']['bSynchroByHttp'] = true; + public function testDataSynchroByCli(){ + $this->RunDataSynchroTest($this->GetNominalUsecaseData()); + } - //TODO fix below usecases with Romain. be aware they are coupled with each other. - /*$aTestCases['Simple scenario with delete option (and extkey given as org/name)'] = array( + public function testDataSynchroByHttp(){ + $aUserLoginUsecase = $this->GetNominalUsecaseData(); + $aUserLoginUsecase['bSynchroByHttp'] = true; + $this->RunDataSynchroTest($aUserLoginUsecase); + } + + public function testWithDeleteOption(){ + $aUserLoginUsecase = array( 'desc' => 'Simple scenario with delete option (and extkey given as org/name)', 'target_class' => 'ApplicationSolution', 'source_properties' => array( @@ -462,8 +462,12 @@ class DataSynchroTest extends ItopDataTestCase ), ), 'bSynchroByHttp' => false - );*/ - /*$aTestCases['Update then delete with retention (to complete with manual testing) and reconciliation on org/name'] = array( + ); + $this->RunDataSynchroTest($aUserLoginUsecase); + } + + /*public function testUpdateThenDeleteWithRetention(){ + $aUserLoginUsecase = array( 'desc' => 'Update then delete with retention (to complete with manual testing) and reconciliation on org/name', 'target_class' => 'ApplicationSolution', 'source_properties' => array( @@ -514,8 +518,13 @@ class DataSynchroTest extends ItopDataTestCase ), ), 'bSynchroByHttp' => false - );*/ - /*$aTestCases['Simple scenario loading a few ApplicationSolution'] = array( + ); + $this->RunDataSynchroTest($aUserLoginUsecase); + }*/ + + + public function testLoadingApplicationSolution(){ + $aUserLoginUsecase= array( 'desc' => 'Simple scenario loading a few ApplicationSolution', 'target_class' => 'ApplicationSolution', 'source_properties' => array( @@ -611,7 +620,7 @@ class DataSynchroTest extends ItopDataTestCase ), ), 'bSynchroByHttp' => false - );*/ - return $aTestCases; + ); + $this->RunDataSynchroTest($aUserLoginUsecase); } }