], CRM_PCP_BAO_PCP::getPcpDashboardInfo($contactID));
}
+ /**
+ * Test that CRM_Contribute_BAO_Contribution::_gatherMessageValues() works
+ * with PCP.
+ */
+ public function testGatherMessageValuesForPCP() {
+ // set up a pcp page
+ $block = CRM_PCP_BAO_PCPBlock::create($this->pcpBlockParams());
+ // The owner of the pcp, who gets the soft credit
+ $contact_owner = $this->individualCreate([], 0, TRUE);
+ $contributionPage = $this->callAPISuccessGetSingle('ContributionPage', []);
+ $pcp = $this->callAPISuccess('Pcp', 'create', [
+ 'contact_id' => $contact_owner,
+ 'title' => 'pcp',
+ 'page_id' => $contributionPage['id'],
+ 'pcp_block_id' => $block->id,
+ 'is_active' => TRUE,
+ 'status_id' => 'Approved',
+ ]);
+
+ // set up a payment processor
+ $payment_processor_type = $this->callAPISuccess('PaymentProcessorType', 'get', ['name' => 'Dummy']);
+ $payment_processor = $this->callAPISuccess('PaymentProcessor', 'create', [
+ 'name' => 'Dummy PP',
+ 'payment_processor_type_id' => $payment_processor_type['id'],
+ 'class_name' => $payment_processor_type['values'][$payment_processor_type['id']]['class_name'],
+ ]);
+
+ // create a contribution with the pcp soft credit
+ $contact_contributor = $this->individualCreate([], 1, TRUE);
+ $address = $this->callAPISuccess('address', 'create', [
+ 'address_name' => "Giver {$contact_contributor}",
+ 'street_address' => '123 Main St.',
+ 'location_type_id' => 'Billing',
+ 'is_billing' => 1,
+ 'contact_id' => $contact_contributor,
+ ]);
+ $contribution = $this->callAPISuccess('Contribution', 'create', [
+ 'contact_id' => $contact_contributor,
+ 'address_id' => $address['id'],
+ 'total_amount' => 10,
+ 'receive_date' => date('YmdHis'),
+ 'financial_type_id' => 'Donation',
+ 'payment_processor' => $payment_processor['id'],
+ 'payment_instrument_id' => 'Credit Card',
+ ]);
+ $contribution_soft = $this->callAPISuccess('ContributionSoft', 'create', [
+ 'contribution_id' => $contribution['id'],
+ 'amount' => 10,
+ 'contact_id' => $contact_owner,
+ 'pcp_id' => $pcp['id'],
+ 'pcp_display_in_roll' => 1,
+ 'pcp_roll_nickname' => "Giver {$contact_contributor}",
+ 'soft_credit_type_id' => 'pcp',
+ ]);
+
+ // Retrieve it using BAO so we can call gatherMessageValues
+ $contribution_bao = new CRM_Contribute_BAO_Contribution();
+ $contribution_bao->id = $contribution['id'];
+ $contribution_bao->find(TRUE);
+
+ $contribution_bao->_component = 'contribute';
+
+ // call and check result. $values has to be defined since it's pass-by-ref.
+ $values = [
+ 'receipt_from_name' => 'CiviCRM Fundraising Dept.',
+ 'receipt_from_email' => 'donationFake@civicrm.org',
+ 'contribution_status' => 'Completed',
+ ];
+ $gathered_values = $contribution_bao->_gatherMessageValues(
+ [
+ 'payment_processor_id' => $payment_processor['id'],
+ 'is_email_receipt' => TRUE,
+ ],
+ $values,
+ [
+ 'component' => 'contribute',
+ 'contact_id' => $contact_contributor,
+ 'contact' => $contact_contributor,
+ 'financialType' => $contribution['values'][$contribution['id']]['financial_type_id'],
+ 'contributionType' => $contribution['values'][$contribution['id']]['contribution_type_id'],
+ 'contributionPage' => $contributionPage['id'],
+ 'membership' => [],
+ 'paymentProcessor' => $payment_processor['id'],
+ 'contribution' => $contribution['id'],
+ ]
+ );
+
+ $this->assertEquals([
+ 'receipt_from_name' => 'CiviCRM Fundraising Dept.',
+ 'receipt_from_email' => 'donationFake@civicrm.org',
+ 'contribution_status' => 'Completed',
+ 'billingName' => "Giver {$contact_contributor}",
+ 'address' => "Giver {$contact_contributor}\n123 Main St.\n",
+ 'softContributions' => NULL,
+ 'title' => 'Contribution',
+ 'priceSetID' => '1',
+ 'useForMember' => FALSE,
+ 'lineItem' => [
+ 0 => [
+ 1 => [
+ 'qty' => 1.0,
+ 'label' => 'Contribution Amount',
+ 'unit_price' => '10.00',
+ 'line_total' => '10.00',
+ 'price_field_id' => '1',
+ 'participant_count' => NULL,
+ 'price_field_value_id' => '1',
+ 'field_title' => 'Contribution Amount',
+ 'html_type' => 'Text',
+ 'description' => NULL,
+ 'entity_id' => '1',
+ 'entity_table' => 'civicrm_contribution',
+ 'contribution_id' => '1',
+ 'financial_type_id' => '1',
+ 'financial_type' => 'Donation',
+ 'membership_type_id' => NULL,
+ 'membership_num_terms' => NULL,
+ 'tax_amount' => 0.0,
+ 'price_set_id' => '1',
+ 'tax_rate' => FALSE,
+ 'subTotal' => 10.0,
+ ],
+ ],
+ ],
+ 'customGroup' => [],
+ 'is_pay_later' => '0',
+ ], $gathered_values);
+ }
+
}