Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Export test to cover altering sqlColumns and headerRows via ho… #15312

Merged
merged 1 commit into from
Oct 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/phpunit/CRM/Export/BAO/ExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public function testExportComponentsContribution() {
['contact_type' => 'Individual', 'name' => 'email', 1],
['name' => 'trxn_id'],
];
$this->hookClass->setHook('civicrm_export', array($this, 'confirmHookWasCalled'));

$this->doExportTest([
'ids' => $this->contributionIDs,
Expand All @@ -129,6 +130,20 @@ public function testExportComponentsContribution() {
'exportMode' => CRM_Export_Form_Select::CONTRIBUTE_EXPORT,
'componentClause' => 'civicrm_contribution.id IN ( ' . implode(',', $this->contributionIDs) . ')',
]);
$this->assertContains('display', array_values($this->csv->getHeader()));
$row = $this->csv->fetchOne(0);
$this->assertEquals('This is a test', $row['display']);
}

/**
* Implements hook_civicrm_export().
*
*/
public function confirmHookWasCalled(&$exportTempTable, &$headerRows, &$sqlColumns, $exportMode, $componentTable, $ids) {
$sqlColumns['display'] = 'display varchar(255)';
$headerRows[] = 'display';
CRM_Core_DAO::executeQuery("ALTER TABLE $exportTempTable ADD COLUMN display varchar(255)");
CRM_Core_DAO::executeQuery("UPDATE $exportTempTable SET display = 'This is a test'");
}

/**
Expand Down