Skip to content

Commit

Permalink
Merge pull request #15312 from seamuslee001/export_hook_test
Browse files Browse the repository at this point in the history
Extend Export test to cover altering sqlColumns and headerRows via ho…
  • Loading branch information
eileenmcnaughton authored Oct 4, 2019
2 parents 9b970fb + 4224fb6 commit eab346e
Showing 1 changed file with 15 additions and 0 deletions.
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

0 comments on commit eab346e

Please sign in to comment.