From 3f968a0c2bc6bde8b1632e0f94e4e8d9ec4628c9 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Mon, 5 Feb 2024 15:32:03 +0100 Subject: [PATCH 01/16] =?UTF-8?q?N=C2=B07216=20-=20Import=20:=20bug=20when?= =?UTF-8?q?=20last=20field=20as=20ExtFieldAttribute=20is=20null=20in=20csv?= =?UTF-8?q?=20file=20or=20missing=20a=20comma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/bulkchange.class.inc.php | 24 +++++++++++++++++++++--- pages/ajax.csvimport.php | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/core/bulkchange.class.inc.php b/core/bulkchange.class.inc.php index ee60143248..78ff6a78d5 100644 --- a/core/bulkchange.class.inc.php +++ b/core/bulkchange.class.inc.php @@ -519,7 +519,7 @@ protected function IsNullExternalKeySpec($aRowData, $sAttCode) foreach ($this->m_aExtKeys[$sAttCode] as $sForeignAttCode => $iCol) { // The foreign attribute is one of our reconciliation key - if (strlen($aRowData[$iCol]) > 0) + if (isset($aRowData[$iCol]) && strlen($aRowData[$iCol]) > 0) { return false; } @@ -1233,11 +1233,19 @@ public function Process(CMDBChange $oChange = null) $iPreviousTimeLimit = ini_get('max_execution_time'); $iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop'); + $iNBFields = count($this->m_aAttList) + count($this->m_aExtKeys); + // Avoid too many events cmdbAbstractObject::SetEventDBLinksChangedBlocked(true); try { foreach ($this->m_aData as $iRow => $aRowData) { set_time_limit(intval($iLoopTimeLimit)); + //stop if not enough cols in $aRowData + if(count($aRowData) != $iNBFields){ + $aResult[$iRow]["__STATUS__"] = new RowStatus_Issue('not enough col at line '.$iRow ); + continue; + } + if (isset($aResult[$iRow]["__STATUS__"])) { // An issue at the earlier steps - skip the rest continue; @@ -1348,7 +1356,12 @@ public function Process(CMDBChange $oChange = null) { if (!array_key_exists($iCol, $aResult[$iRow])) { - $aResult[$iRow][$iCol] = new CellStatus_Void($aRowData[$iCol]); + if(isset($aRowData[$iCol])) { + $aResult[$iRow][$iCol] = new CellStatus_Void($aRowData[$iCol]); + } else { + //TODO improve message + $aResult[$iRow][$iCol] = new CellStatus_Void('!missing value!'); + } } } foreach($this->m_aExtKeys as $sAttCode => $aForeignAtts) @@ -1362,7 +1375,12 @@ public function Process(CMDBChange $oChange = null) if (!array_key_exists($iCol, $aResult[$iRow])) { // The foreign attribute is one of our reconciliation key - $aResult[$iRow][$iCol] = new CellStatus_Void($aRowData[$iCol]); + if(isset($aRowData[$iCol])) { + $aResult[$iRow][$iCol] = new CellStatus_Void($aRowData[$iCol]); + } else { + //TODO improve message + $aResult[$iRow][$iCol] = new CellStatus_Void('!missing value!'); + } } } } diff --git a/pages/ajax.csvimport.php b/pages/ajax.csvimport.php index f8f23bde06..adb0d449ed 100644 --- a/pages/ajax.csvimport.php +++ b/pages/ajax.csvimport.php @@ -345,7 +345,7 @@ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMo $oPanel->AddSubBlock($oTable); $oPage->AddSubBlock($oPanel); - if (empty($sInitSearchField)) { + if (empty($sInitSearchField) || empty($aInitFieldMapping)) { // Propose a reconciliation scheme // $aReconciliationKeys = MetaModel::GetReconcKeys($sClassName); From 4222761d662a64bd88fe4ea07982c3041c7a783d Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Mon, 12 Feb 2024 16:35:52 +0100 Subject: [PATCH 02/16] =?UTF-8?q?N=C2=B07216=20-=20Import=20:=20bug=20when?= =?UTF-8?q?=20last=20field=20as=20ExtFieldAttribute=20is=20null=20in=20csv?= =?UTF-8?q?=20file=20or=20missing=20a=20comma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/bulkchange.class.inc.php | 8 +++----- dictionaries/en.dictionary.itop.ui.php | 2 ++ dictionaries/fr.dictionary.itop.ui.php | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/bulkchange.class.inc.php b/core/bulkchange.class.inc.php index 78ff6a78d5..0053eb468a 100644 --- a/core/bulkchange.class.inc.php +++ b/core/bulkchange.class.inc.php @@ -1242,7 +1242,7 @@ public function Process(CMDBChange $oChange = null) set_time_limit(intval($iLoopTimeLimit)); //stop if not enough cols in $aRowData if(count($aRowData) != $iNBFields){ - $aResult[$iRow]["__STATUS__"] = new RowStatus_Issue('not enough col at line '.$iRow ); + $aResult[$iRow]["__STATUS__"] = new RowStatus_Issue(Dict::Format('UI:CSVReport-Row-Issue-NbField',count($aRowData),$iNBFields) ); continue; } @@ -1359,8 +1359,7 @@ public function Process(CMDBChange $oChange = null) if(isset($aRowData[$iCol])) { $aResult[$iRow][$iCol] = new CellStatus_Void($aRowData[$iCol]); } else { - //TODO improve message - $aResult[$iRow][$iCol] = new CellStatus_Void('!missing value!'); + $aResult[$iRow][$iCol] = new CellStatus_Issue('', null, Dict::S('UI:CSVReport-Value-Issue-NoValue')); } } } @@ -1378,8 +1377,7 @@ public function Process(CMDBChange $oChange = null) if(isset($aRowData[$iCol])) { $aResult[$iRow][$iCol] = new CellStatus_Void($aRowData[$iCol]); } else { - //TODO improve message - $aResult[$iRow][$iCol] = new CellStatus_Void('!missing value!'); + $aResult[$iRow][$iCol] = new CellStatus_Issue('', null, 'UI:CSVReport-Value-Issue-NoValue'); } } } diff --git a/dictionaries/en.dictionary.itop.ui.php b/dictionaries/en.dictionary.itop.ui.php index b56976a4de..c5dc6c85a9 100644 --- a/dictionaries/en.dictionary.itop.ui.php +++ b/dictionaries/en.dictionary.itop.ui.php @@ -719,6 +719,8 @@ 'UI:CSVReport-Row-Issue-Reconciliation' => 'failed to reconcile', 'UI:CSVReport-Row-Issue-Ambiguous' => 'ambiguous reconciliation', 'UI:CSVReport-Row-Issue-Internal' => 'Internal error: %1$s, %2$s', + 'UI:CSVReport-Value-Issue-NoValue' => 'No value', + 'UI:CSVReport-Row-Issue-NbField' => 'Not the expected number of fields (current : %1$s fields, expected :%2$s)', 'UI:CSVReport-Icon-Unchanged' => 'Unchanged', 'UI:CSVReport-Icon-Modified' => 'Modified', diff --git a/dictionaries/fr.dictionary.itop.ui.php b/dictionaries/fr.dictionary.itop.ui.php index 0406f7178a..effe80a9f3 100644 --- a/dictionaries/fr.dictionary.itop.ui.php +++ b/dictionaries/fr.dictionary.itop.ui.php @@ -4,7 +4,7 @@ * * @copyright Copyright (C) 2010-2024 Combodo SAS * @license https://opensource.org/licenses/AGPL-3.0 - * + * */ /** * @@ -678,6 +678,8 @@ 'UI:CSVReport-Row-Issue-ExpectedDateFormat' => 'Expected format: %1$s~~', 'UI:CSVReport-Row-Issue-Inconsistent' => 'Incohérence entre attributs: %1$s', 'UI:CSVReport-Row-Issue-Internal' => 'Erreur interne: %1$s, %2$s', + 'UI:CSVReport-Value-Issue-NoValue' => 'Pas de valeur', + 'UI:CSVReport-Row-Issue-NbField' => 'Le nombre de champs ne correspond pas à ce qui est attendu (courant : %1$s champs, %2$s champs attendus )', 'UI:CSVReport-Row-Issue-MissingExtKey' => 'Ne peut pas être créé car il manque des clés externes : %1$s', 'UI:CSVReport-Row-Issue-Reconciliation' => 'Echec de réconciliation', 'UI:CSVReport-Row-Unchanged' => 'inchangé', From e9758a251cd9357e2d9bcd177f2064478a57b927 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Wed, 10 Jul 2024 15:50:27 +0200 Subject: [PATCH 03/16] Add tests --- core/bulkchange.class.inc.php | 5 +- .../unitary-tests/core/BulkChangeTest.php | 76 ++++++++++++++----- 2 files changed, 63 insertions(+), 18 deletions(-) diff --git a/core/bulkchange.class.inc.php b/core/bulkchange.class.inc.php index 0053eb468a..bf4101ba81 100644 --- a/core/bulkchange.class.inc.php +++ b/core/bulkchange.class.inc.php @@ -1181,6 +1181,9 @@ public function Process(CMDBChange $oChange = null) foreach($this->m_aData as $iRow => $aRowData) { $sFormat = $sDateTimeFormat; + if(!isset($this->m_aData[$iRow][$iCol])){ + continue; + } $sValue = $this->m_aData[$iRow][$iCol]; if (!empty($sValue)) { @@ -1241,7 +1244,7 @@ public function Process(CMDBChange $oChange = null) foreach ($this->m_aData as $iRow => $aRowData) { set_time_limit(intval($iLoopTimeLimit)); //stop if not enough cols in $aRowData - if(count($aRowData) != $iNBFields){ + if(count($aRowData) < $iNBFields){ $aResult[$iRow]["__STATUS__"] = new RowStatus_Issue(Dict::Format('UI:CSVReport-Row-Issue-NbField',count($aRowData),$iNBFields) ); continue; } diff --git a/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php b/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php index 7ca006bfae..a498147c6c 100644 --- a/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php +++ b/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php @@ -293,21 +293,21 @@ public function bulkChangeWithExistingDataProvider() { ["1", "Server1", "production", ""], "csvData" => [[">Demo", "Server1"]], - "attributes"=> - ["name" => 1], - "extKeys"=> - ["org_id" => ["name" => 0]], - "reconcilKeys"=> - ["name"], - "expectedResult"=> - [ - 0 => ">Demo", - "org_id" => "n/a", - 1 => "Server1", - "id" => "Invalid value for attribute", - "__STATUS__" => "Issue: ambiguous reconciliation", - "__ERRORS__" => "Allowed 'status' value(s): stock,implementation,production,obsolete", - ], + "attributes"=> + ["name" => 1], + "extKeys"=> + ["org_id" => ["name" => 0]], + "reconcilKeys"=> + ["name"], + "expectedResult"=> + [ + 0 => ">Demo", + "org_id" => "n/a", + 1 => "Server1", + "id" => "Invalid value for attribute", + "__STATUS__" => "Issue: ambiguous reconciliation", + "__ERRORS__" => "Allowed 'status' value(s): stock,implementation,production,obsolete", + ], "expectedResultHTML"=> [ 0 => ">Demo", @@ -321,9 +321,9 @@ public function bulkChangeWithExistingDataProvider() { "Case 6 - 1 : Unexpected value (update)" => [ "initData"=> ["1", ">ServerTest", "production", ""], - "csvData"=> + "csvData"=> [["Demo", ">ServerTest", "key - will be automatically overwritten by test", ">BadValue", ""]], - "attributes"=> + "attributes"=> ["name" => 1, "id" => 2, "status" => 3, "purchase_date" => 4], "extKeys"=> ["org_id" => ["name" => 0]], @@ -579,6 +579,48 @@ public function bulkChangeWithExistingDataProvider() { [ "id" => "{Id of the server created by the test}", 0 => "Demo", "org_id" => "n/a", 1 => ">ServerTest", 2 => "1", 3 => "production", 4 => "'2020-20-03' is an invalid value", "id" => 1, "__STATUS__" => "Issue: wrong date format"], ], + "Case 11 : Missing AttributeDateTime cell should issue an error" => [ + "initData"=> + ["1", "ServerTest", "production", "2020-02-01"], + "csvData"=> + [["Demo", "ServerTest", "1", "production"]], + "attributes"=> + ["name" => 1, "id" => 2, "status" => 3, "purchase_date" => 4], + "extKeys"=> + ["org_id" => ["name" => 0]], + "reconcilKeys"=> + ["id"], + "expectedResult"=> + [ 0 => "Demo", "org_id" => "n/a", 1 => "ServerTest", 2 => "1", 3 => "production", 4 => "'' is an invalid value", "id" => 1, "__STATUS__" => 'Issue: Not the expected number of fields (current : 4 fields, expected :5)'], + ], + "Case 12 : Missing AttributeEnum cell should issue an error" => [ + "initData"=> + ["1", "ServerTest", "production", "2020-02-01"], + "csvData"=> + [["Demo", "ServerTest", "1", "2020-02-01"]], // missing status + "attributes"=> + ["name" => 1, "id" => 2, "purchase_date" => 3, "status" => 4], + "extKeys"=> + ["org_id" => ["name" => 0]], + "reconcilKeys"=> + ["id"], + "expectedResult"=> + [ 0 => "Demo", "org_id" => "n/a", 1 => "ServerTest", 2 => "1", 3 => "2020-02-01", 4 => "'' is an invalid value", "id" => 1, "__STATUS__" => "Issue: Not the expected number of fields (current : 4 fields, expected :5)"], + ], + "Case 13 : Missing AttributeExternalKey cell should issue an error" => [ + "initData"=> + ["1", "ServerTest", "production", "2020-02-01"], + "csvData"=> + [["ServerTest", "1", "production", "2020-02-01"]], // missing org_id + "attributes"=> + ["name" => 0, "id" => 1, "status" => 2, "purchase_date" => 3], + "extKeys"=> + ["org_id" => ["name" => 4]], + "reconcilKeys"=> + ["id"], + "expectedResult"=> + [ 0 => "ServerTest", "org_id" => "n/a", 1 => "1", 2 => "1", 3 => "2020-02-01", 4 => "'' is an invalid value", "id" => 1, "__STATUS__" => "Issue: Not the expected number of fields (current : 4 fields, expected :5)"], + ], ]; } From b4a7b411310c5f8a3cded2e1da1c6db9287c7f76 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Wed, 10 Jul 2024 16:53:41 +0200 Subject: [PATCH 04/16] Fix tests --- core/bulkchange.class.inc.php | 4 +- .../unitary-tests/core/BulkChangeTest.php | 67 ++++++++++--------- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/core/bulkchange.class.inc.php b/core/bulkchange.class.inc.php index bf4101ba81..142a3ef76c 100644 --- a/core/bulkchange.class.inc.php +++ b/core/bulkchange.class.inc.php @@ -1243,8 +1243,8 @@ public function Process(CMDBChange $oChange = null) try { foreach ($this->m_aData as $iRow => $aRowData) { set_time_limit(intval($iLoopTimeLimit)); - //stop if not enough cols in $aRowData - if(count($aRowData) < $iNBFields){ + //stop if not the good number of cols in $aRowData + if(count($aRowData) != $iNBFields){ $aResult[$iRow]["__STATUS__"] = new RowStatus_Issue(Dict::Format('UI:CSVReport-Row-Issue-NbField',count($aRowData),$iNBFields) ); continue; } diff --git a/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php b/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php index a498147c6c..cc3db2b923 100644 --- a/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php +++ b/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php @@ -221,30 +221,33 @@ public function bulkChangeWithoutInitDataProvider() { * @param $aExtKeys * @param $aReconcilKeys */ - public function testBulkChangeWithExistingData($aInitData, $aCsvData, $aAttributes, $aExtKeys, $aReconcilKeys, $aResult, $aResultHTML= null) { + public function testBulkChangeWithExistingData($aInitData, $aCsvData, $aAttributes, $aExtKeys, $aReconcilKeys, $aResult, $aResultHTML= null, $bSetId = true ) { //change value during the test $db_core_transactions_enabled=MetaModel::GetConfig()->Get('db_core_transactions_enabled'); MetaModel::GetConfig()->Set('db_core_transactions_enabled',false); - if (is_array($aInitData) && sizeof($aInitData) != 0) { - /** @var Server $oServer */ - $oServer = $this->createObject('Server', array( - 'name' => $aInitData[1], - 'status' => $aInitData[2], - 'org_id' => $aInitData[0], - 'purchase_date' => $aInitData[3], - )); - $aCsvData[0][2]=$oServer->GetKey(); - $aResult[2]=$oServer->GetKey(); - if ($aResult["id"]==="{Id of the server created by the test}") { - $aResult["id"]=$oServer->GetKey(); - if ($aResultHTML!==null){ - $aResultHTML[2]=$oServer->GetKey(); - $aResultHTML["id"]=$oServer->GetKey(); + if($bSetId) { + if (is_array($aInitData) && sizeof($aInitData) != 0) { + /** @var Server $oServer */ + $oServer = $this->createObject('Server', array( + 'name' => $aInitData[1], + 'status' => $aInitData[2], + 'org_id' => $aInitData[0], + 'purchase_date' => $aInitData[3], + )); + $aCsvData[0][2] = $oServer->GetKey(); + $aResult[2] = $oServer->GetKey(); + if ($aResult["id"] === "{Id of the server created by the test}") { + $aResult["id"] = $oServer->GetKey(); + if ($aResultHTML !== null) { + $aResultHTML[2] = $oServer->GetKey(); + $aResultHTML["id"] = $oServer->GetKey(); + } } + $this->debug("oServer->GetKey():".$oServer->GetKey()); } - $this->debug("oServer->GetKey():".$oServer->GetKey()); } + $oBulk = new BulkChange( "Server", $aCsvData, @@ -300,23 +303,21 @@ public function bulkChangeWithExistingDataProvider() { "reconcilKeys"=> ["name"], "expectedResult"=> - [ - 0 => ">Demo", - "org_id" => "n/a", - 1 => "Server1", - "id" => "Invalid value for attribute", - "__STATUS__" => "Issue: ambiguous reconciliation", - "__ERRORS__" => "Allowed 'status' value(s): stock,implementation,production,obsolete", - ], + [ + 0 => ">Demo", + "org_id" => "No match for value '>Demo'", + 1 => "Server1", + "name" => "Invalid value for attribute", + "__STATUS__" => "Issue: Unexpected attribute value(s)", + "__ERRORS__" => "Object not found", + ], "expectedResultHTML"=> [ 0 => ">Demo", - "org_id" => "n/a", + "org_id" => "No match for value '>Demo'", 1 => "Server1", - "id" => "Invalid value for attribute", - "__STATUS__" => "Issue: ambiguous reconciliation", - "__ERRORS__" => "Allowed 'status' value(s): stock,implementation,production,obsolete", ], + "setId" => false ], "Case 6 - 1 : Unexpected value (update)" => [ "initData"=> @@ -625,7 +626,6 @@ public function bulkChangeWithExistingDataProvider() { } - /** * test $oBulk->Process with new server and new organization datas * @@ -637,7 +637,7 @@ public function bulkChangeWithExistingDataProvider() { * @param $aExtKeys * @param $aReconcilKeys */ - public function testBulkChangeWithExistingDataAndSpecificOrg($aInitData, $aCsvData, $aAttributes, $aExtKeys, $aReconcilKeys, $aResult, $aResultHTML = null) { + public function testBulkChangeWithExistingDataAndSpecificOrg($aInitData, $aCsvData, $aAttributes, $aExtKeys, $aReconcilKeys, $aResult, $aResultHTML = null, $bSetId = true) { //change value during the test $db_core_transactions_enabled=MetaModel::GetConfig()->Get('db_core_transactions_enabled'); MetaModel::GetConfig()->Set('db_core_transactions_enabled',false); @@ -659,7 +659,9 @@ public function testBulkChangeWithExistingDataAndSpecificOrg($aInitData, $aCsvDa 'org_id' => $oOrganisation->GetKey(), 'purchase_date' => $aInitData["serverPurchaseDate"], )); - $aCsvData[0][2]=$oServer->GetKey(); + if($bSetId) { + $aCsvData[0][2] = $oServer->GetKey(); + } $aResult[2]=$oServer->GetKey(); if ($aResult["id"]==="{Id of the server created by the test}") { $aResult["id"]=$oServer->GetKey(); @@ -739,6 +741,7 @@ public function bulkChangeWithExistingDataAndSpecificOrgProvider() { "__STATUS__" => "Issue: failed to reconcile", "__ERRORS__" => "Allowed 'status' value(s): stock,implemfentation,production,obsolete", ], + "setId" => false ], "Case 3 : unchanged name" => [ "initData"=> From 730ff54ee28151b1dfd186c0fdc5753a0102ebf8 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Mon, 5 Feb 2024 15:32:03 +0100 Subject: [PATCH 05/16] =?UTF-8?q?N=C2=B07216=20-=20Import=20:=20bug=20when?= =?UTF-8?q?=20last=20field=20as=20ExtFieldAttribute=20is=20null=20in=20csv?= =?UTF-8?q?=20file=20or=20missing=20a=20comma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/bulkchange.class.inc.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/core/bulkchange.class.inc.php b/core/bulkchange.class.inc.php index 142a3ef76c..3f0fc3b76f 100644 --- a/core/bulkchange.class.inc.php +++ b/core/bulkchange.class.inc.php @@ -1359,11 +1359,7 @@ public function Process(CMDBChange $oChange = null) { if (!array_key_exists($iCol, $aResult[$iRow])) { - if(isset($aRowData[$iCol])) { - $aResult[$iRow][$iCol] = new CellStatus_Void($aRowData[$iCol]); - } else { - $aResult[$iRow][$iCol] = new CellStatus_Issue('', null, Dict::S('UI:CSVReport-Value-Issue-NoValue')); - } + $aResult[$iRow][$iCol] = new CellStatus_Void(utils::HtmlEntities($aRowData[$iCol])); } } foreach($this->m_aExtKeys as $sAttCode => $aForeignAtts) @@ -1377,11 +1373,7 @@ public function Process(CMDBChange $oChange = null) if (!array_key_exists($iCol, $aResult[$iRow])) { // The foreign attribute is one of our reconciliation key - if(isset($aRowData[$iCol])) { - $aResult[$iRow][$iCol] = new CellStatus_Void($aRowData[$iCol]); - } else { - $aResult[$iRow][$iCol] = new CellStatus_Issue('', null, 'UI:CSVReport-Value-Issue-NoValue'); - } + $aResult[$iRow][$iCol] = new CellStatus_Void(utils::HtmlEntities($aRowData[$iCol])); } } } From b73fa9b55172227640969c21e751ca4042e43dca Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Mon, 12 Feb 2024 16:35:52 +0100 Subject: [PATCH 06/16] =?UTF-8?q?N=C2=B07216=20-=20Import=20:=20bug=20when?= =?UTF-8?q?=20last=20field=20as=20ExtFieldAttribute=20is=20null=20in=20csv?= =?UTF-8?q?=20file=20or=20missing=20a=20comma?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/bulkchange.class.inc.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/bulkchange.class.inc.php b/core/bulkchange.class.inc.php index 3f0fc3b76f..198ffed90b 100644 --- a/core/bulkchange.class.inc.php +++ b/core/bulkchange.class.inc.php @@ -1360,6 +1360,9 @@ public function Process(CMDBChange $oChange = null) if (!array_key_exists($iCol, $aResult[$iRow])) { $aResult[$iRow][$iCol] = new CellStatus_Void(utils::HtmlEntities($aRowData[$iCol])); + } else { + $aResult[$iRow][$iCol] = new CellStatus_Issue('', null, Dict::S('UI:CSVReport-Value-Issue-NoValue')); + } } } foreach($this->m_aExtKeys as $sAttCode => $aForeignAtts) @@ -1374,6 +1377,9 @@ public function Process(CMDBChange $oChange = null) { // The foreign attribute is one of our reconciliation key $aResult[$iRow][$iCol] = new CellStatus_Void(utils::HtmlEntities($aRowData[$iCol])); + } else { + $aResult[$iRow][$iCol] = new CellStatus_Issue('', null, 'UI:CSVReport-Value-Issue-NoValue'); + } } } } From 2a800f8788af7bbae46776f13f99448b8ed85397 Mon Sep 17 00:00:00 2001 From: Anne-Catherine <57360138+accognet@users.noreply.github.com> Date: Thu, 11 Jul 2024 09:30:05 +0200 Subject: [PATCH 07/16] Update core/bulkchange.class.inc.php Co-authored-by: Thomas Casteleyn --- core/bulkchange.class.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/bulkchange.class.inc.php b/core/bulkchange.class.inc.php index 198ffed90b..e083fcbc60 100644 --- a/core/bulkchange.class.inc.php +++ b/core/bulkchange.class.inc.php @@ -1243,7 +1243,7 @@ public function Process(CMDBChange $oChange = null) try { foreach ($this->m_aData as $iRow => $aRowData) { set_time_limit(intval($iLoopTimeLimit)); - //stop if not the good number of cols in $aRowData + // Stop if not the good number of cols in $aRowData if(count($aRowData) != $iNBFields){ $aResult[$iRow]["__STATUS__"] = new RowStatus_Issue(Dict::Format('UI:CSVReport-Row-Issue-NbField',count($aRowData),$iNBFields) ); continue; From 49584474f2bc050d88a4d432112b3a255dabce9a Mon Sep 17 00:00:00 2001 From: Anne-Catherine <57360138+accognet@users.noreply.github.com> Date: Thu, 11 Jul 2024 09:30:12 +0200 Subject: [PATCH 08/16] Update dictionaries/en.dictionary.itop.ui.php Co-authored-by: Thomas Casteleyn --- dictionaries/en.dictionary.itop.ui.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dictionaries/en.dictionary.itop.ui.php b/dictionaries/en.dictionary.itop.ui.php index c5dc6c85a9..14761e2088 100644 --- a/dictionaries/en.dictionary.itop.ui.php +++ b/dictionaries/en.dictionary.itop.ui.php @@ -719,8 +719,8 @@ 'UI:CSVReport-Row-Issue-Reconciliation' => 'failed to reconcile', 'UI:CSVReport-Row-Issue-Ambiguous' => 'ambiguous reconciliation', 'UI:CSVReport-Row-Issue-Internal' => 'Internal error: %1$s, %2$s', - 'UI:CSVReport-Value-Issue-NoValue' => 'No value', - 'UI:CSVReport-Row-Issue-NbField' => 'Not the expected number of fields (current : %1$s fields, expected :%2$s)', + 'UI:CSVReport-Value-Issue-NoValue' => 'No value', + 'UI:CSVReport-Row-Issue-NbField' => 'Not the expected number of fields (current : %1$s fields, expected :%2$s)', 'UI:CSVReport-Icon-Unchanged' => 'Unchanged', 'UI:CSVReport-Icon-Modified' => 'Modified', From 9580e1354e12725dafd0a87a0857ffd4dc919fd7 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Fri, 27 Sep 2024 17:16:35 +0200 Subject: [PATCH 09/16] =?UTF-8?q?N=C2=B07276=20-=20Update=20french=20dicti?= =?UTF-8?q?onary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/bulkchange.class.inc.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/bulkchange.class.inc.php b/core/bulkchange.class.inc.php index e083fcbc60..6a17eb7465 100644 --- a/core/bulkchange.class.inc.php +++ b/core/bulkchange.class.inc.php @@ -1359,7 +1359,8 @@ public function Process(CMDBChange $oChange = null) { if (!array_key_exists($iCol, $aResult[$iRow])) { - $aResult[$iRow][$iCol] = new CellStatus_Void(utils::HtmlEntities($aRowData[$iCol])); + if(isset($aRowData[$iCol])) { + $aResult[$iRow][$iCol] = new CellStatus_Void(utils::HtmlEntities($aRowData[$iCol])); } else { $aResult[$iRow][$iCol] = new CellStatus_Issue('', null, Dict::S('UI:CSVReport-Value-Issue-NoValue')); } @@ -1376,7 +1377,8 @@ public function Process(CMDBChange $oChange = null) if (!array_key_exists($iCol, $aResult[$iRow])) { // The foreign attribute is one of our reconciliation key - $aResult[$iRow][$iCol] = new CellStatus_Void(utils::HtmlEntities($aRowData[$iCol])); + if(isset($aRowData[$iCol])) { + $aResult[$iRow][$iCol] = new CellStatus_Void(utils::HtmlEntities($aRowData[$iCol])); } else { $aResult[$iRow][$iCol] = new CellStatus_Issue('', null, 'UI:CSVReport-Value-Issue-NoValue'); } From 0ce4c20291ab2354600e8deb484f77acd7c4ab67 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Fri, 27 Sep 2024 17:45:28 +0200 Subject: [PATCH 10/16] Fix test --- .../2.x/itop-config/BulkChangeExtKeyTest.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/BulkChangeExtKeyTest.php b/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/BulkChangeExtKeyTest.php index f30675e0d9..4e43cb9898 100644 --- a/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/BulkChangeExtKeyTest.php +++ b/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/BulkChangeExtKeyTest.php @@ -183,11 +183,17 @@ public function testExternalFieldIssueImportFail_AllObjectsVisibleByCurrentUser_ null, null, null, + null, 'Found 2 matches' ); } - + /*public function ReconciliationKeyProvider(){ + return [ + 'rack_id NOT a reconcilication key' => [ false ], + 'rack_id reconcilication key' => [ true ], + ]; + }*/ /** * @dataProvider ReconciliationKeyProvider */ @@ -209,6 +215,7 @@ public function testExternalFieldIssueImportFail_AllObjectsVisibleByCurrentUser_ null, $bIsRackReconKey, $aCsvData, + ['description'=>3], $aExtKeys, $sSearchLinkUrl ); @@ -224,7 +231,7 @@ private function GetUid(){ } public function performBulkChangeTest($sExpectedDisplayableValue, $sExpectedDescription, $oOrg, $bIsRackReconKey, - $aAdditionalCsvData=null, $aExtKeys=null, $sSearchLinkUrl=null, $sError="Object not found") { + $aAdditionalCsvData=null, $aAdditionalAttributes=null, $aExtKeys=null, $sSearchLinkUrl=null, $sError="Object not found") { if ($sSearchLinkUrl===null){ $sSearchLinkUrl = 'UI.php?operation=search&filter='.rawurlencode('%5B%22SELECT+%60Rack%60+FROM+Rack+AS+%60Rack%60+WHERE+%28%60Rack%60.%60name%60+%3D+%3Aname%29%22%2C%7B%22name%22%3A%22UnexistingRack%22%7D%2C%5B%5D%5D'); } @@ -247,6 +254,9 @@ public function performBulkChangeTest($sExpectedDisplayableValue, $sExpectedDesc } } $aAttributes = ["name" => 2]; + if ($aAdditionalAttributes !== null){ + $aAttributes = array_merge($aAttributes, $aAdditionalAttributes); + } if ($aExtKeys == null){ $aExtKeys = ["org_id" => ["name" => 0], "rack_id" => ["name" => 1]]; } From 257c159223b4825530203fc9af533ec4c00ef171 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Fri, 27 Sep 2024 17:46:10 +0200 Subject: [PATCH 11/16] Fix test --- .../datamodels/2.x/itop-config/BulkChangeExtKeyTest.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/BulkChangeExtKeyTest.php b/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/BulkChangeExtKeyTest.php index 4e43cb9898..4374856846 100644 --- a/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/BulkChangeExtKeyTest.php +++ b/tests/php-unit-tests/unitary-tests/datamodels/2.x/itop-config/BulkChangeExtKeyTest.php @@ -188,12 +188,6 @@ public function testExternalFieldIssueImportFail_AllObjectsVisibleByCurrentUser_ ); } - /*public function ReconciliationKeyProvider(){ - return [ - 'rack_id NOT a reconcilication key' => [ false ], - 'rack_id reconcilication key' => [ true ], - ]; - }*/ /** * @dataProvider ReconciliationKeyProvider */ From a10f88de750f8cea6bdfc199c163862239fc5d8f Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Tue, 8 Oct 2024 13:21:25 +0200 Subject: [PATCH 12/16] Fix test after rebase --- .../unitary-tests/core/BulkChangeTest.php | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php b/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php index cc3db2b923..faafa63339 100644 --- a/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php +++ b/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php @@ -221,33 +221,33 @@ public function bulkChangeWithoutInitDataProvider() { * @param $aExtKeys * @param $aReconcilKeys */ - public function testBulkChangeWithExistingData($aInitData, $aCsvData, $aAttributes, $aExtKeys, $aReconcilKeys, $aResult, $aResultHTML= null, $bSetId = true ) { + public function testBulkChangeWithExistingData($aInitData, $aCsvData, $aAttributes, $aExtKeys, $aReconcilKeys, $aResult, $aResultHTML= null ) { //change value during the test $db_core_transactions_enabled=MetaModel::GetConfig()->Get('db_core_transactions_enabled'); MetaModel::GetConfig()->Set('db_core_transactions_enabled',false); - if($bSetId) { - if (is_array($aInitData) && sizeof($aInitData) != 0) { - /** @var Server $oServer */ - $oServer = $this->createObject('Server', array( - 'name' => $aInitData[1], - 'status' => $aInitData[2], - 'org_id' => $aInitData[0], - 'purchase_date' => $aInitData[3], - )); - $aCsvData[0][2] = $oServer->GetKey(); - $aResult[2] = $oServer->GetKey(); - if ($aResult["id"] === "{Id of the server created by the test}") { - $aResult["id"] = $oServer->GetKey(); - if ($aResultHTML !== null) { - $aResultHTML[2] = $oServer->GetKey(); - $aResultHTML["id"] = $oServer->GetKey(); - } + + if (is_array($aInitData) && sizeof($aInitData) != 0) { + /** @var Server $oServer */ + $oServer = $this->createObject('Server', array( + 'name' => $aInitData[1], + 'status' => $aInitData[2], + 'org_id' => $aInitData[0], + 'purchase_date' => $aInitData[3], + )); + $aCsvData[0][2] = $oServer->GetKey(); + $aResult[2] = $oServer->GetKey(); + if ($aResult["id"] === "{Id of the server created by the test}") { + $aResult["id"] = $oServer->GetKey(); + if ($aResultHTML !== null) { + $aResultHTML[2] = $oServer->GetKey(); + $aResultHTML["id"] = $oServer->GetKey(); } - $this->debug("oServer->GetKey():".$oServer->GetKey()); } + $this->debug("oServer->GetKey():".$oServer->GetKey()); } + $oBulk = new BulkChange( "Server", $aCsvData, @@ -272,7 +272,7 @@ public function testBulkChangeWithExistingData($aInitData, $aCsvData, $aAttribut $this->debug('GetCLIValue:'.$oCell->GetCLIValue()); $this->debug("aResult:".$aResult[$i]); $this->assertEquals( $aResult[$i], $oCell->GetCLIValue(), "failure on " . get_class($oCell) . ' cell type for cell number ' . $i ); - if (null !== $aResultHTML) { + if (null !== $aResultHTML && array_key_exists($i, $aResultHTML)) { $this->assertEquals($aResultHTML[$i], $oCell->GetHTMLValue(), "failure on " . get_class($oCell) . ' cell type for cell number ' . $i); } } else if ($i === "__ERRORS__") { @@ -297,7 +297,7 @@ public function bulkChangeWithExistingDataProvider() { "csvData" => [[">Demo", "Server1"]], "attributes"=> - ["name" => 1], + ["name" => 1,"status" => 2], "extKeys"=> ["org_id" => ["name" => 0]], "reconcilKeys"=> @@ -305,19 +305,23 @@ public function bulkChangeWithExistingDataProvider() { "expectedResult"=> [ 0 => ">Demo", - "org_id" => "No match for value '>Demo'", + "org_id" => "n/a", 1 => "Server1", + "id" => "Invalid value for attribute", "name" => "Invalid value for attribute", - "__STATUS__" => "Issue: Unexpected attribute value(s)", + "__STATUS__" => "Issue: ambiguous reconciliation", "__ERRORS__" => "Object not found", ], "expectedResultHTML"=> [ 0 => ">Demo", - "org_id" => "No match for value '>Demo'", + "org_id" => "n/a", 1 => "Server1", - ], - "setId" => false + "id" => "Invalid value for attribute", + "name" => "Invalid value for attribute", + "__STATUS__" => "Issue: ambiguous reconciliation", + "__ERRORS__" => "Object not found", + ] ], "Case 6 - 1 : Unexpected value (update)" => [ "initData"=> From a3b332a380604eb007d991f4c8c667feef3b5966 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Tue, 8 Oct 2024 13:21:52 +0200 Subject: [PATCH 13/16] Fix change after rebase --- core/bulkchange.class.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/bulkchange.class.inc.php b/core/bulkchange.class.inc.php index 6a17eb7465..de5960e861 100644 --- a/core/bulkchange.class.inc.php +++ b/core/bulkchange.class.inc.php @@ -1360,7 +1360,7 @@ public function Process(CMDBChange $oChange = null) if (!array_key_exists($iCol, $aResult[$iRow])) { if(isset($aRowData[$iCol])) { - $aResult[$iRow][$iCol] = new CellStatus_Void(utils::HtmlEntities($aRowData[$iCol])); + $aResult[$iRow][$iCol] = new CellStatus_Void($aRowData[$iCol]); } else { $aResult[$iRow][$iCol] = new CellStatus_Issue('', null, Dict::S('UI:CSVReport-Value-Issue-NoValue')); } @@ -1378,7 +1378,7 @@ public function Process(CMDBChange $oChange = null) { // The foreign attribute is one of our reconciliation key if(isset($aRowData[$iCol])) { - $aResult[$iRow][$iCol] = new CellStatus_Void(utils::HtmlEntities($aRowData[$iCol])); + $aResult[$iRow][$iCol] = new CellStatus_Void($aRowData[$iCol]); } else { $aResult[$iRow][$iCol] = new CellStatus_Issue('', null, 'UI:CSVReport-Value-Issue-NoValue'); } From 5e0755435277dd6fa1e8f5e5b44960367d0727be Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Tue, 8 Oct 2024 13:26:48 +0200 Subject: [PATCH 14/16] Fix test after rebase --- .../unitary-tests/core/BulkChangeTest.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php b/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php index faafa63339..7c552b45e9 100644 --- a/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php +++ b/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php @@ -641,7 +641,7 @@ public function bulkChangeWithExistingDataProvider() { * @param $aExtKeys * @param $aReconcilKeys */ - public function testBulkChangeWithExistingDataAndSpecificOrg($aInitData, $aCsvData, $aAttributes, $aExtKeys, $aReconcilKeys, $aResult, $aResultHTML = null, $bSetId = true) { + public function testBulkChangeWithExistingDataAndSpecificOrg($aInitData, $aCsvData, $aAttributes, $aExtKeys, $aReconcilKeys, $aResult, $aResultHTML = null) { //change value during the test $db_core_transactions_enabled=MetaModel::GetConfig()->Get('db_core_transactions_enabled'); MetaModel::GetConfig()->Set('db_core_transactions_enabled',false); @@ -663,9 +663,7 @@ public function testBulkChangeWithExistingDataAndSpecificOrg($aInitData, $aCsvDa 'org_id' => $oOrganisation->GetKey(), 'purchase_date' => $aInitData["serverPurchaseDate"], )); - if($bSetId) { - $aCsvData[0][2] = $oServer->GetKey(); - } + $aCsvData[0][2] = $oServer->GetKey(); $aResult[2]=$oServer->GetKey(); if ($aResult["id"]==="{Id of the server created by the test}") { $aResult["id"]=$oServer->GetKey(); @@ -695,7 +693,7 @@ public function testBulkChangeWithExistingDataAndSpecificOrg($aInitData, $aCsvDa $this->debug('GetCLIValue:'.$oCell->GetCLIValue()); $this->debug("aResult:".$aResult[$i]); $this->assertEquals($aResult[$i], $oCell->GetCLIValue(), "$i cell is incorrect"); - if (null !== $aResultHTML) { + if (null !== $aResultHTML && array_key_exists($i, $aResultHTML)) { $this->assertEquals($aResultHTML[$i], $oCell->GetHTMLValue()); } } elseif ($i === "__STATUS__") { @@ -722,7 +720,7 @@ public function bulkChangeWithExistingDataAndSpecificOrgProvider() { "csvData" => [["Demo", ">Server1"]], "attributes"=> - ["name" => 1], + ["name" => 1,"status" => 2], "extKeys"=> ["org_id" => ["name" => 0]], "reconcilKeys"=> @@ -744,8 +742,7 @@ public function bulkChangeWithExistingDataAndSpecificOrgProvider() { "id" => "Invalid value for attribute", "__STATUS__" => "Issue: failed to reconcile", "__ERRORS__" => "Allowed 'status' value(s): stock,implemfentation,production,obsolete", - ], - "setId" => false + ] ], "Case 3 : unchanged name" => [ "initData"=> From 4fe257ad484627924b54af4453c27a166b4598bc Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Tue, 8 Oct 2024 13:27:44 +0200 Subject: [PATCH 15/16] Fix test after rebase --- tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php b/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php index 7c552b45e9..54d78ac8b7 100644 --- a/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php +++ b/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php @@ -321,7 +321,7 @@ public function bulkChangeWithExistingDataProvider() { "name" => "Invalid value for attribute", "__STATUS__" => "Issue: ambiguous reconciliation", "__ERRORS__" => "Object not found", - ] + ], ], "Case 6 - 1 : Unexpected value (update)" => [ "initData"=> @@ -358,7 +358,6 @@ public function bulkChangeWithExistingDataProvider() { "__STATUS__" => "Issue: Unexpected attribute value(s)", "__ERRORS__" => "Allowed 'status' value(s): stock,implementation,production,obsolete", ], - ], "Case 6 - 2 : Unexpected value (update)" => [ "initData"=> @@ -742,7 +741,7 @@ public function bulkChangeWithExistingDataAndSpecificOrgProvider() { "id" => "Invalid value for attribute", "__STATUS__" => "Issue: failed to reconcile", "__ERRORS__" => "Allowed 'status' value(s): stock,implemfentation,production,obsolete", - ] + ], ], "Case 3 : unchanged name" => [ "initData"=> From 0fc0546720c49f8ff995900508603fea2bac20b6 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Wed, 23 Oct 2024 09:36:33 +0200 Subject: [PATCH 16/16] Fix test --- .../unitary-tests/core/BulkChangeTest.php | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php b/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php index 54d78ac8b7..856bd68ce5 100644 --- a/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php +++ b/tests/php-unit-tests/unitary-tests/core/BulkChangeTest.php @@ -235,13 +235,16 @@ public function testBulkChangeWithExistingData($aInitData, $aCsvData, $aAttribut 'org_id' => $aInitData[0], 'purchase_date' => $aInitData[3], )); - $aCsvData[0][2] = $oServer->GetKey(); - $aResult[2] = $oServer->GetKey(); - if ($aResult["id"] === "{Id of the server created by the test}") { - $aResult["id"] = $oServer->GetKey(); - if ($aResultHTML !== null) { - $aResultHTML[2] = $oServer->GetKey(); - $aResultHTML["id"] = $oServer->GetKey(); + if(array_key_exists('id', $aAttributes)) { + $iColumnForId = $aAttributes['id']; + $aCsvData[0][$iColumnForId] = $oServer->GetKey(); + $aResult[$iColumnForId] = $oServer->GetKey(); + if ($aResult["id"] === "{Id of the server created by the test}") { + $aResult["id"] = $oServer->GetKey(); + if ($aResultHTML !== null) { + $aResultHTML[$iColumnForId] = $oServer->GetKey(); + $aResultHTML["id"] = $oServer->GetKey(); + } } } $this->debug("oServer->GetKey():".$oServer->GetKey()); @@ -297,7 +300,7 @@ public function bulkChangeWithExistingDataProvider() { "csvData" => [[">Demo", "Server1"]], "attributes"=> - ["name" => 1,"status" => 2], + ["name" => 1], "extKeys"=> ["org_id" => ["name" => 0]], "reconcilKeys"=> @@ -399,9 +402,9 @@ public function bulkChangeWithExistingDataProvider() { "initData"=> [], "csvData"=> - [["Demo", ">ServerTest", "", ""]], + [["Demo", ">ServerTest", "", 1]], "attributes"=> - ["name" => 1, "status" => 2, "purchase_date" => 3], + ["name" => 1, "status" => 2, 'id'=> 3], "extKeys"=> ["org_id" => ["name" => 0]], "reconcilKeys"=> @@ -413,7 +416,7 @@ public function bulkChangeWithExistingDataProvider() { "org_id" => "3", 1 => "\">ServerTest\"", 2 => '\'\' is an invalid value', - 3 => "", + 3 => "1", "__STATUS__" => "Issue: Unexpected attribute value(s)", "__ERRORS__" => "Allowed 'status' value(s): stock,implementation,production,obsolete", ], @@ -424,7 +427,7 @@ public function bulkChangeWithExistingDataProvider() { "org_id" => "3", 1 => ">ServerTest", 2 => "'<svg onclick"alert(1)">' is an invalid value", - 3 => "", + 3 => "1", "__STATUS__" => "Issue: Unexpected attribute value(s)", "__ERRORS__" => "Allowed 'status' value(s): stock,implementation,production,obsolete", ], @@ -587,15 +590,15 @@ public function bulkChangeWithExistingDataProvider() { "initData"=> ["1", "ServerTest", "production", "2020-02-01"], "csvData"=> - [["Demo", "ServerTest", "1", "production"]], + [["1"]], "attributes"=> - ["name" => 1, "id" => 2, "status" => 3, "purchase_date" => 4], + ["id" => 0,"purchase_date" => 1], "extKeys"=> - ["org_id" => ["name" => 0]], + [], "reconcilKeys"=> ["id"], "expectedResult"=> - [ 0 => "Demo", "org_id" => "n/a", 1 => "ServerTest", 2 => "1", 3 => "production", 4 => "'' is an invalid value", "id" => 1, "__STATUS__" => 'Issue: Not the expected number of fields (current : 4 fields, expected :5)'], + [ 1 => "'' is an invalid value", "id" => 1, "__STATUS__" => 'Issue: Not the expected number of fields (current : 1 fields, expected :2)'], ], "Case 12 : Missing AttributeEnum cell should issue an error" => [ "initData"=> @@ -623,7 +626,7 @@ public function bulkChangeWithExistingDataProvider() { "reconcilKeys"=> ["id"], "expectedResult"=> - [ 0 => "ServerTest", "org_id" => "n/a", 1 => "1", 2 => "1", 3 => "2020-02-01", 4 => "'' is an invalid value", "id" => 1, "__STATUS__" => "Issue: Not the expected number of fields (current : 4 fields, expected :5)"], + [ 0 => "ServerTest", "org_id" => "n/a", 1 => "1", 2 => "production", 3 => "2020-02-01", 4 => "'' is an invalid value", "id" => 1, "__STATUS__" => "Issue: Not the expected number of fields (current : 4 fields, expected :5)"], ], ]; } @@ -719,7 +722,7 @@ public function bulkChangeWithExistingDataAndSpecificOrgProvider() { "csvData" => [["Demo", ">Server1"]], "attributes"=> - ["name" => 1,"status" => 2], + ["name" => 1,"id" => 2], "extKeys"=> ["org_id" => ["name" => 0]], "reconcilKeys"=>