return TRUE;
}
- // Cache the various object fields
- // @todo - remove this after confirming this is just a compilation of other-wise-cached fields.
- static $fields = [];
-
- if (isset($values['note'])) {
- // add a note field
- if (!isset($params['note'])) {
- $params['note'] = [];
- }
- $noteBlock = count($params['note']) + 1;
-
- $params['note'][$noteBlock] = [];
- if (!isset($fields['Note'])) {
- $fields['Note'] = CRM_Core_DAO_Note::fields();
- }
-
- // get the current logged in civicrm user
- $session = CRM_Core_Session::singleton();
- $userID = $session->get('userID');
-
- if ($userID) {
- $values['contact_id'] = $userID;
- }
-
- _civicrm_api3_store_values($fields['Note'], $values, $params['note'][$noteBlock]);
-
- return TRUE;
- }
-
// Check for custom field values
$customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $values),
FALSE, FALSE, NULL, NULL, FALSE, FALSE, FALSE
* @throws \CRM_Core_Exception
* @throws \League\Csv\CannotInsertRecord
*/
- public function testImport($csv, $mapper, $expectedOutcomes = [], $submittedValues = []): void {
+ public function testImport($csv, $mapper, $expectedOutcomes = [], $submittedValues = [], $apiLookup = []): void {
$this->importCSV($csv, $mapper, $submittedValues);
$dataSource = new CRM_Import_DataSource_CSV(UserJob::get(FALSE)->setSelect(['id'])->execute()->first()['id']);
foreach ($expectedOutcomes as $outcome => $count) {
$this->assertEquals($dataSource->getRowCount([$outcome]), $count);
}
+ if (!empty($apiLookup)) {
+ $this->callAPISuccessGetCount($apiLookup['entity'], $apiLookup['params'], $apiLookup['count']);
+ }
+
ob_start();
$_REQUEST['user_job_id'] = $dataSource->getUserJobID();
$_REQUEST['status'] = array_key_first($expectedOutcomes);
*/
public function importDataProvider(): array {
return [
+ 'individual_with_note.csv' => [
+ 'csv' => 'individual_with_note.csv',
+ 'mapper' => [['first_name'], ['last_name'], ['note']],
+ 'expected_outcomes' => [CRM_Import_Parser::VALID => 1],
+ 'check' => ['entity' => 'Note', 'params' => ['note' => 'Kinda dull'], 'count' => 1],
+ ],
'column_names_casing.csv' => [
'csv' => 'column_names_casing.csv',
'mapper' => [['first_name'], ['last_name'], ['do_not_import'], ['do_not_import'], ['do_not_import'], ['do_not_import']],