+ /**
+ * Test exporting relationships.
+ *
+ * This is to ensure that CRM-13995 remains fixed.
+ */
+ public function testExportRelationshipsMergeToHousehold() {
+ list($householdID, $houseHoldTypeID) = $this->setUpHousehold();
+
+ $selectedFields = [
+ ['Individual', $houseHoldTypeID . '_a_b', 'state_province', ''],
+ ['Individual', $houseHoldTypeID . '_a_b', 'city', ''],
+ ['Individual', 'city', ''],
+ ['Individual', 'state_province', ''],
+ ];
+ list($tableName) = CRM_Export_BAO_Export::exportComponents(
+ FALSE,
+ $this->contactIDs,
+ [],
+ NULL,
+ $selectedFields,
+ NULL,
+ CRM_Export_Form_Select::CONTACT_EXPORT,
+ "contact_a.id IN (" . implode(",", $this->contactIDs) . ")",
+ NULL,
+ FALSE,
+ TRUE,
+ [
+ 'exportOption' => CRM_Export_Form_Select::CONTACT_EXPORT,
+ 'suppress_csv_for_testing' => TRUE,
+ ]
+ );
+ $dao = CRM_Core_DAO::executeQuery("SELECT * FROM {$tableName}");
+ while ($dao->fetch()) {
+ $this->assertEquals('Portland', $dao->city);
+ $this->assertEquals('ME', $dao->state_province);
+ $this->assertEquals($householdID, $dao->civicrm_primary_id);
+ $this->assertEquals($householdID, $dao->civicrm_primary_id);
+ }
+
+ }
+
+ /**
+ * Test exporting relationships.
+ */
+ public function testExportRelationshipsMergeToHouseholdAllFields() {
+ $this->markTestIncomplete('Does not yet work under CI due to mysql limitation (number of columns in table). Works on some boxes');
+ list($householdID) = $this->setUpHousehold();
+ list($tableName) = CRM_Export_BAO_Export::exportComponents(
+ FALSE,
+ $this->contactIDs,
+ [],
+ NULL,
+ NULL,
+ NULL,
+ CRM_Export_Form_Select::CONTACT_EXPORT,
+ "contact_a.id IN (" . implode(",", $this->contactIDs) . ")",
+ NULL,
+ FALSE,
+ TRUE,
+ [
+ 'exportOption' => CRM_Export_Form_Select::CONTACT_EXPORT,
+ 'suppress_csv_for_testing' => TRUE,
+ ]
+ );
+ $dao = CRM_Core_DAO::executeQuery("SELECT * FROM {$tableName}");
+ while ($dao->fetch()) {
+ $this->assertEquals('Portland', $dao->city);
+ $this->assertEquals('ME', $dao->state_province);
+ $this->assertEquals($householdID, $dao->civicrm_primary_id);
+ $this->assertEquals($householdID, $dao->civicrm_primary_id);
+ $this->assertEquals('Unit Test Household', $dao->addressee);
+ $this->assertEquals('Unit Test Household', $dao->display_name);
+ }
+ }
+