From ceda70c1e845378da2fb551887f976a820a6ad0a Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 27 Aug 2022 13:23:22 +1200 Subject: [PATCH] Make validation output clearer --- CRM/Import/DataSource.php | 5 +++-- CRM/Import/Parser.php | 2 +- tests/phpunit/CRMTraits/Import/ParserTrait.php | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CRM/Import/DataSource.php b/CRM/Import/DataSource.php index 744ce5c9fe..17fdcefbfa 100644 --- a/CRM/Import/DataSource.php +++ b/CRM/Import/DataSource.php @@ -648,7 +648,7 @@ abstract class CRM_Import_DataSource { */ protected function getStatusMapping(): array { return [ - CRM_Import_Parser::VALID => ['imported', 'new', 'soft_credit_imported', 'pledge_payment_imported'], + CRM_Import_Parser::VALID => ['imported', 'new', 'valid', 'soft_credit_imported', 'pledge_payment_imported'], CRM_Import_Parser::ERROR => ['error', 'invalid', 'soft_credit_error', 'pledge_payment_error'], CRM_Import_Parser::DUPLICATE => ['duplicate'], CRM_Import_Parser::NO_MATCH => ['invalid_no_match'], @@ -657,7 +657,8 @@ abstract class CRM_Import_DataSource { CRM_Contribute_Import_Parser_Contribution::SOFT_CREDIT => ['soft_credit_imported'], CRM_Contribute_Import_Parser_Contribution::PLEDGE_PAYMENT => ['pledge_payment_imported'], CRM_Contribute_Import_Parser_Contribution::PLEDGE_PAYMENT_ERROR => ['pledge_payment_error'], - 'new' => ['new'], + 'new' => ['new', 'valid'], + 'valid' => ['valid'], ]; } diff --git a/CRM/Import/Parser.php b/CRM/Import/Parser.php index f6f71be5ae..011b15f50a 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -1623,7 +1623,7 @@ abstract class CRM_Import_Parser implements UserJobInterface { $rowNumber = $row['_id']; $values = array_values($row); $this->validateValues($values); - $this->setImportStatus($rowNumber, 'NEW', ''); + $this->setImportStatus($rowNumber, 'VALID', ''); } catch (CRM_Core_Exception $e) { $this->setImportStatus($rowNumber, 'ERROR', $e->getMessage()); diff --git a/tests/phpunit/CRMTraits/Import/ParserTrait.php b/tests/phpunit/CRMTraits/Import/ParserTrait.php index 722ac2abde..e2180eac7e 100644 --- a/tests/phpunit/CRMTraits/Import/ParserTrait.php +++ b/tests/phpunit/CRMTraits/Import/ParserTrait.php @@ -68,6 +68,7 @@ trait CRMTraits_Import_ParserTrait { } catch (CRM_Core_Exception_PrematureExitException $e) { $queue = Civi::queue('user_job_' . $this->userJobID); + $this->assertEquals(1, CRM_Core_DAO::singleValueQuery('SELECT COUNT(*) FROM civicrm_queue_item')); $runner = new CRM_Queue_Runner([ 'queue' => $queue, 'errorMode' => CRM_Queue_Runner::ERROR_ABORT, -- 2.25.1