$returnProperties = array_merge($returnProperties, $moreReturnProperties);
}
- $exportParams['postal_mailing_export']['temp_columns'] = [];
- if ($exportParams['exportOption'] == 2 &&
- isset($exportParams['postal_mailing_export']) &&
- CRM_Utils_Array::value('postal_mailing_export', $exportParams['postal_mailing_export']) == 1
+ if ($processor->getRequestedFields() &&
+ $processor->isPostalableOnly()
) {
$postalColumns = ['is_deceased', 'do_not_mail', 'street_address', 'supplemental_address_1'];
+ $exportParams['postal_mailing_export']['temp_columns'] = [];
foreach ($postalColumns as $column) {
if (!array_key_exists($column, $returnProperties)) {
$returnProperties[$column] = 1;
* @throws \League\Csv\Exception
*/
public function testExportComponentsNull() {
- $this->startCapturingOutput();
- try {
- list($tableName) = CRM_Export_BAO_Export::exportComponents(
- TRUE,
- [],
- [],
- NULL,
- NULL,
- NULL,
- CRM_Export_Form_Select::CONTACT_EXPORT,
- NULL,
- NULL,
- FALSE,
- FALSE,
- [
- 'exportOption' => 1,
- ]
- );
- }
- catch (CRM_Core_Exception_PrematureExitException $e) {
- }
- $this->processor = $e->errorData['processor'];
- ob_end_clean();
+ $this->doExportTest([]);
}
/**
FALSE,
FALSE,
[
- 'exportOption' => CRM_Export_Form_Select::CONTACT_EXPORT,
'suppress_csv_for_testing' => TRUE,
]
);
FALSE,
FALSE,
[
- 'exportOption' => CRM_Export_Form_Select::CONTACT_EXPORT,
'suppress_csv_for_testing' => TRUE,
]
);
FALSE,
FALSE,
[
- 'exportOption' => CRM_Export_Form_Select::CONTACT_EXPORT,
'suppress_csv_for_testing' => TRUE,
]
);
FALSE,
TRUE,
[
- 'exportOption' => CRM_Export_Form_Select::CONTACT_EXPORT,
'suppress_csv_for_testing' => TRUE,
]
);
FALSE,
TRUE,
[
- 'exportOption' => CRM_Export_Form_Select::CONTACT_EXPORT,
'suppress_csv_for_testing' => TRUE,
]
);
FALSE,
FALSE,
[
- 'exportOption' => CRM_Export_Form_Select::CONTACT_EXPORT,
'suppress_csv_for_testing' => TRUE,
]
);
TRUE,
FALSE,
[
- 'exportOption' => CRM_Export_Form_Select::CONTACT_EXPORT,
'mergeOption' => TRUE,
'suppress_csv_for_testing' => TRUE,
'postal_mailing_export' => [
FALSE,
FALSE,
[
- 'exportOption' => CRM_Export_Form_Select::CONTACT_EXPORT,
'suppress_csv_for_testing' => TRUE,
]
);
FALSE,
FALSE,
[
- 'exportOption' => CRM_Export_Form_Select::CONTRIBUTE_EXPORT,
'suppress_csv_for_testing' => TRUE,
]
);
]);
}
+ /**
+ * Test export components.
+ *
+ * Tests the exportComponents function with the provided parameters.
+ *
+ * This exportComponents will export a csv but it will also throw a prematureExitException
+ * which we catch & grab the processor from.
+ *
+ * $this->processor is set to the export processor.
+ *
+ * @param $params
+ *
+ * @throws \CRM_Core_Exception
+ */
+ protected function doExportTest($params) {
+ $this->startCapturingOutput();
+ try {
+ CRM_Export_BAO_Export::exportComponents(
+ CRM_Utils_Array::value('selectAll', $params, (empty($params['fields']))),
+ CRM_Utils_Array::value('ids', $params, []),
+ CRM_Utils_Array::value('params', $params, []),
+ CRM_Utils_Array::value('order', $params),
+ CRM_Utils_Array::value('fields', $params),
+ CRM_Utils_Array::value('moreReturnProperties', $params),
+ CRM_Utils_Array::value('exportMode', $params, CRM_Export_Form_Select::CONTACT_EXPORT),
+ CRM_Utils_Array::value('componentClause', $params, FALSE),
+ CRM_Utils_Array::value('componentTable', $params),
+ CRM_Utils_Array::value('mergeSameAddress', $params, FALSE),
+ CRM_Utils_Array::value('mergeSameHousehold', $params, FALSE)
+ );
+ }
+ catch (CRM_Core_Exception_PrematureExitException $e) {
+ $this->processor = $e->errorData['processor'];
+ ob_end_clean();
+ return;
+ }
+ $this->fail('We expected a premature exit exception');
+ }
+
}