From 6137fac4d7e1d092820fe8da7fb18ace8d575ce2 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 24 Dec 2020 07:47:33 +1100 Subject: [PATCH] Add in unit test to lock in the fix for dev_core_2272 --- tests/phpunit/CRM/Export/BAO/ExportTest.php | 34 +++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/phpunit/CRM/Export/BAO/ExportTest.php b/tests/phpunit/CRM/Export/BAO/ExportTest.php index 3bdeb7971c..49d0500a21 100644 --- a/tests/phpunit/CRM/Export/BAO/ExportTest.php +++ b/tests/phpunit/CRM/Export/BAO/ExportTest.php @@ -664,6 +664,40 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { $this->assertEquals('household sauce', $row['Contact Source']); } + /** + * Test exporting contacts merged into households + * + * This is to ensure that dev/core#2272 remains fixed. + * + * @dataProvider getBooleanDataProvider + * + * @param bool $includeHouseHold + * + * @throws CRM_Core_Exception + * @throws \League\Csv\Exception + */ + public function testExportMergeToHousehold($includeHouseHold) { + list($householdID, $houseHoldTypeID) = $this->setUpHousehold(); + + if ($includeHouseHold) { + $this->contactIDs[] = $householdID; + } + $selectedFields = [ + ['contact_type' => 'Individual', 'name' => 'contact_source', 'location_type_id' => ''], + ]; + $this->doExportTest([ + 'ids' => $this->contactIDs, + 'fields' => $selectedFields, + 'mergeSameHousehold' => TRUE, + 'componentTable' => 'civicrm_contact', + 'componentClause' => 'contact_a.id IN (' . implode(',', $this->contactIDs) . ')', + ]); + $row = $this->csv->fetchOne(); + $this->assertCount(1, $this->csv); + $this->assertEquals($householdID, $row['Household ID']); + + } + /** * Test exporting relationships. * -- 2.25.1