-
-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23736 from eileenmcnaughton/import_multi
dev/core#3498 Fix mishandled option values
- Loading branch information
Showing
7 changed files
with
218 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/** | ||
* @file | ||
* File for the CRM_Custom_Import_Parser_ContributionTest class. | ||
*/ | ||
|
||
/** | ||
* Test Contribution import parser. | ||
* | ||
* @package CiviCRM | ||
* @group headless | ||
*/ | ||
class CRM_Custom_Import_Parser_ApiTest extends CiviUnitTestCase { | ||
|
||
use CRMTraits_Custom_CustomDataTrait; | ||
use CRMTraits_Import_ParserTrait; | ||
|
||
/** | ||
* Test the full form-flow import. | ||
*/ | ||
public function testImport(): void { | ||
$this->individualCreate(); | ||
$this->createCustomGroupWithFieldOfType(['is_multiple' => TRUE, 'extends' => 'Contact'], 'select', 'level'); | ||
$customGroupID = $this->ids['CustomGroup']['level']; | ||
$dateFieldID = $this->createDateCustomField(['date_format' => 'yy', 'custom_group_id' => $customGroupID])['id']; | ||
$this->importCSV('custom_data_date_select.csv', [ | ||
['name' => 'contact_id'], | ||
['name' => $this->getCustomFieldName('levelselect')], | ||
['name' => 'do_not_import'], | ||
['name' => 'custom_' . $dateFieldID], | ||
], ['multipleCustomData' => $customGroupID]); | ||
$dataSource = new CRM_Import_DataSource_CSV($this->userJobID); | ||
$row = $dataSource->getRow(); | ||
$this->assertEquals('IMPORTED', $row['_status']); | ||
$row = $dataSource->getRow(); | ||
$this->assertEquals('IMPORTED', $row['_status']); | ||
$row = $dataSource->getRow(); | ||
$this->assertEquals('ERROR', $row['_status']); | ||
} | ||
|
||
/** | ||
* Get the import's datasource form. | ||
* | ||
* Defaults to contribution - other classes should override. | ||
* | ||
* @param array $submittedValues | ||
* | ||
* @return \CRM_Custom_Import_Form_DataSource | ||
* @noinspection PhpUnnecessaryLocalVariableInspection | ||
*/ | ||
protected function getDataSourceForm(array $submittedValues): CRM_Custom_Import_Form_DataSource { | ||
/* @var \CRM_Custom_Import_Form_DataSource $form */ | ||
$form = $this->getFormObject('CRM_Custom_Import_Form_DataSource', $submittedValues); | ||
return $form; | ||
} | ||
|
||
/** | ||
* Get the import's mapField form. | ||
* | ||
* Defaults to contribution - other classes should override. | ||
* | ||
* @param array $submittedValues | ||
* | ||
* @return \CRM_Custom_Import_Form_MapField | ||
* @noinspection PhpUnnecessaryLocalVariableInspection | ||
*/ | ||
protected function getMapFieldForm(array $submittedValues): CRM_Custom_Import_Form_MapField { | ||
/* @var \CRM_Custom_Import_Form_MapField $form */ | ||
$form = $this->getFormObject('CRM_Custom_Import_Form_MapField', $submittedValues); | ||
return $form; | ||
} | ||
|
||
/** | ||
* Get the import's preview form. | ||
* | ||
* Defaults to contribution - other classes should override. | ||
* | ||
* @param array $submittedValues | ||
* | ||
* @return \CRM_Custom_Import_Form_Preview | ||
* @noinspection PhpUnnecessaryLocalVariableInspection | ||
*/ | ||
protected function getPreviewForm(array $submittedValues): CRM_Custom_Import_Form_Preview { | ||
/* @var CRM_Custom_Import_Form_Preview $form */ | ||
$form = $this->getFormObject('CRM_Custom_Import_Form_Preview', $submittedValues); | ||
return $form; | ||
} | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
tests/phpunit/CRM/Custom/Import/Parser/data/custom_data_date_select.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
The Contact ID,The Level,The School,The Start Year | ||
3,Red,Ah Ha,2010-12-01 | ||
3,R,Bah bah,2022-01-02 | ||
3,Aqua,Cah cah,2022-02-03 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.