Skip to content

Commit

Permalink
Extend Export test to cover altering sqlColumns and headerRows via ho…
Browse files Browse the repository at this point in the history
…ok_civicrm_export
  • Loading branch information
seamuslee001 committed Sep 16, 2019
1 parent 04d8165 commit 9e74899
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'] = 'dipslay 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 9e74899

Please sign in to comment.