CRM-17286 - Add Soft Credit Amount, Soft Credit Type, Soft Credit For, Soft Credit...
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 29 Sep 2015 11:41:54 +0000 (17:11 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Tue, 29 Sep 2015 11:41:54 +0000 (17:11 +0530)
CRM/Core/BAO/Mapping.php
tests/phpunit/WebTest/Export/ContactTest.php

index b0fb993398f371cda5fe8625e2b088385c58a4cb..ba5e33dd5c7859484c23c2b9de0d53b0c121a5ce 100644 (file)
@@ -398,9 +398,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
     if (($mappingType == 'Search Builder') || ($exportMode == CRM_Export_Form_Select::CONTRIBUTE_EXPORT)) {
       if (CRM_Core_Permission::access('CiviContribute')) {
         $fields['Contribution'] = CRM_Contribute_BAO_Contribution::exportableFields();
-        foreach (array('contribution_contact_id', 'contribution_soft_credit_name', 'contribution_soft_credit_amount', 'contribution_soft_credit_type', 'contribution_soft_credit_contribution_id') as $element) {
-          unset($fields['Contribution'][$element]);
-        }
+        unset($fields['Contribution']['contribution_contact_id']);
         $compArray['Contribution'] = ts('Contribution');
       }
     }
index 9cbc1a3e53e4920dc8c441bda32ee75d9e46d08d..34adfbb8eee377b391bd86d9e42d59d58b2b6c07 100644 (file)
@@ -474,4 +474,84 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase {
     return $optionLabel;
   }
 
+  /**
+   *  CRM-17286 - Test Contribution Export for Soft Credit fields.
+   */
+  public function testContributionExport() {
+    $this->webtestLogin();
+
+    // Create a contact to be used as soft creditor
+    $softCreditFname = substr(sha1(rand()), 0, 7);
+    $softCreditLname = substr(sha1(rand()), 0, 7);
+    $this->webtestAddContact($softCreditFname, $softCreditLname, FALSE);
+
+    $firstName = 'a' . substr(sha1(rand()), 0, 7);
+    $this->openCiviPage('contribute/add', 'reset=1&action=add&context=standalone', '_qf_Contribution_upload-bottom');
+    $this->webtestNewDialogContact($firstName);
+    // select financial type
+    $this->select("financial_type_id", "value=1");
+
+    // fill in Received Date
+    $this->webtestFillDate('receive_date');
+
+    // source
+    $this->type("source", "Mailer 1");
+
+    // total amount
+    $this->type("total_amount", "100");
+
+    // create first soft credit
+    $this->click("softCredit");
+    $this->waitForElementPresent("soft_credit_amount_1");
+    $this->webtestFillAutocomplete("{$softCreditLname}, {$softCreditFname}", 's2id_soft_credit_contact_id_1');
+    $this->type("soft_credit_amount_1", "50");
+
+    // Clicking save.
+    $this->clickLink("_qf_Contribution_upload");
+
+    $this->openCiviPage("contribute/search", "reset=1", "_qf_Search_refresh");
+    $this->type("sort_name", $firstName);
+    $this->clickLink("_qf_Search_refresh");
+    // Is contact present in search result?
+    $this->assertElementContainsText('css=div.crm-search-results', $firstName, "Contact did not found in search result!");
+    $contributionID = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='contributionSearch']/table/tbody/tr/td[11]/span/a[text()='Edit']@href"));
+    // select to export all the contacts from search result.
+    $this->click("toggleSelect");
+
+    // Select the task action to export.
+    $this->click("task");
+    $this->select("task", "label=Export contributions");
+    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->click('CIVICRM_QFID_2_4');
+    $this->clickLink('_qf_Select_next-bottom');
+
+    $this->select("mapper_1_0_0", 'Contribution');
+    $this->select("mapper_1_0_1", 'Soft Credit Amount');
+
+    $this->select("mapper_1_1_0", 'Contribution');
+    $this->select("mapper_1_1_1", 'Soft Credit For');
+
+    $this->select("mapper_1_2_0", 'Contribution');
+    $this->select("mapper_1_2_1", 'Soft Credit For Contribution ID');
+
+    $this->select("mapper_1_3_0", 'Contribution');
+    $this->select("mapper_1_3_1", 'Soft Credit Type');
+
+    $csvFile = $this->downloadCSV("_qf_Map_next-bottom", 'CiviCRM_Contribution_Search.csv');
+
+    // All other rows to be check.
+    $checkRows = array(
+      1 => array(
+        'Soft Credit Amount' => 50.00,
+        'Soft Credit For' => "{$softCreditLname}, {$softCreditFname}",
+        'Soft Credit For Contribution ID' => $contributionID,
+        'Soft Credit Type' => 'Solicited',
+      ),
+    );
+
+    // Read CSV and fire assertions.
+    $this->reviewCSV($csvFile, array(), $checkRows, 1);
+
+  }
+
 }