if ($returnField === 'contribution_contact_id') {
$returnField = 'contact_id';
}
- $this->assertTrue((!empty($contribution[$returnField]) || $contribution[$returnField] === "0"), $returnField);
+ $this->assertTrue((!empty($contribution[$returnField]) || $contribution[$returnField] === '0'), $returnField);
}
$entityFinancialTrxn = $this->callAPISuccess('EntityFinancialTrxn', 'get', [
'entity_id' => $contributionID,
$ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
$params = $this->_params;
- $params['custom_' . $ids['custom_field_id']] = "custom string";
+ $params['custom_' . $ids['custom_field_id']] = 'custom string';
$result = $this->callAPIAndDocument($this->entity, 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals($result['id'], $result['values'][$result['id']]['id']);
* This is the test for creating soft credits.
*/
public function testCreateContributionWithSoftCredit() {
- $description = "Demonstrates creating contribution with SoftCredit.";
- $subfile = "ContributionCreateWithSoftCredit";
+ $description = 'Demonstrates creating contribution with SoftCredit.';
+ $subfile = 'ContributionCreateWithSoftCredit';
$contact2 = $this->callAPISuccess('Contact', 'create', [
'display_name' => 'superman',
'contact_type' => 'Individual',
}
public function testCreateContributionWithSoftCreditDefaults() {
- $description = "Demonstrates creating contribution with Soft Credit defaults for amount and type.";
- $subfile = "ContributionCreateWithSoftCreditDefaults";
+ $description = 'Demonstrates creating contribution with Soft Credit defaults for amount and type.';
+ $subfile = 'ContributionCreateWithSoftCreditDefaults';
$contact2 = $this->callAPISuccess('Contact', 'create', [
'display_name' => 'superman',
'contact_type' => 'Individual',
$this->assertEquals($contact2['id'], $result['values'][0]['soft_credit'][1]['contact_id']);
// Default soft credit amount = contribution.total_amount
$this->assertEquals($this->_params['total_amount'], $result['values'][0]['soft_credit'][1]['amount']);
- $this->assertEquals(CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"), $result['values'][0]['soft_credit'][1]['soft_credit_type']);
+ $this->assertEquals(CRM_Core_OptionGroup::getDefaultValue('soft_credit_type'), $result['values'][0]['soft_credit'][1]['soft_credit_type']);
$this->callAPISuccess('contribution', 'delete', ['id' => $contribution['id']]);
$this->callAPISuccess('contact', 'delete', ['id' => $contact2['id']]);
* Test creating contribution with Soft Credit by passing in honor_contact_id.
*/
public function testCreateContributionWithHonoreeContact() {
- $description = "Demonstrates creating contribution with Soft Credit by passing in honor_contact_id.";
- $subfile = "ContributionCreateWithHonoreeContact";
+ $description = 'Demonstrates creating contribution with Soft Credit by passing in honor_contact_id.';
+ $subfile = 'ContributionCreateWithHonoreeContact';
$contact2 = $this->callAPISuccess('Contact', 'create', [
'display_name' => 'superman',
'contact_type' => 'Individual',
'currency:::USD',
'receive_date:::' . date('Ymd', strtotime($contribution['receive_date'])),
"receipt_date:::\n",
- 'contributeMode:::notify',
'title:::Contribution',
- 'displayName:::Mr. Anthony Anderson II',
'contributionStatus:::Completed',
]);
$mut->stop();
/**
* Test completing a transaction via the API with a non-USD transaction.
*/
- public function testCompleteTransactionEuro() {
+ public function testCompleteTransactionEuro(): void {
$mut = new CiviMailUtils($this, TRUE);
$this->swapMessageTemplateForTestTemplate();
$this->createLoggedInUser();
'currency:::EUR',
'receive_date:::' . date('Ymd', strtotime($contribution['receive_date'])),
"receipt_date:::\n",
- 'contributeMode:::notify',
'title:::Contribution',
- 'displayName:::Mr. Anthony Anderson II',
'contributionStatus:::Completed',
]);
$mut->stop();
'is_pay_later:::1',
'email:::anthony_anderson@civicrm.org',
'pay_later_receipt:::This is a pay later receipt',
- 'displayName:::Mr. Anthony Anderson II',
'contributionPageId:::' . $contributionPageID,
'title:::Test Contribution Page',
'amount:::100',
*/
public function contributionStatusProvider() {
$contributionStatuses = civicrm_api3('OptionValue', 'get', [
- 'return' => ["id", "name"],
- 'option_group_id' => "contribution_status",
+ 'return' => ['id', 'name'],
+ 'option_group_id' => 'contribution_status',
]);
foreach ($contributionStatuses['values'] as $statusName) {
$statuses[] = [$statusName];
'currency:::USD',
'receive_date:::' . date('Ymd', strtotime($receive_date)),
'receipt_date:::' . date('Ymd'),
- 'contributeMode:::notify',
'title:::Contribution',
- 'displayName:::Mr. Anthony Anderson II',
'trxn_id:::kazam',
'contactID:::' . $this->_params['contact_id'],
'contributionID:::' . $contribution['id'],
$contributionPage = $this->callAPISuccess('ContributionPage', 'create', [
'receipt_from_name' => 'Mickey Mouse',
'receipt_from_email' => 'mickey@mouse.com',
- 'title' => "Test Contribution Page",
+ 'title' => 'Test Contribution Page',
'financial_type_id' => 1,
'currency' => 'NZD',
'goal_amount' => 50,
* Test if renewal activity is create after changing Pending contribution to
* Completed via offline
*
- * @throws \CRM_Core_Exception
- * @throws \CRM_Core_Exception
- * @throws \CiviCRM_API3_Exception
+ * @throws \CRM_Core_Exception|\CiviCRM_API3_Exception
*/
public function testPendingToCompleteContribution(): void {
$this->createPriceSetWithPage('membership');
'status_id' => 'Scheduled',
]);
$this->assertEquals(1, $activity['count']);
-
+ $_REQUEST['id'] = $this->getContributionID();
+ $_REQUEST['action'] = 'update';
// change pending contribution to completed
- $form = new CRM_Contribute_Form_Contribution();
-
- $form->_params = [
- 'id' => $this->getContributionID(),
+ /* @var CRM_Contribute_Form_Contribution $form */
+ $form = $this->getFormObject('CRM_Contribute_Form_Contribution', [
'total_amount' => 20,
'net_amount' => 20,
'fee_amount' => 0,
'hidden_AdditionalDetail' => 1,
'hidden_Premium' => 1,
'from_email_address' => '"civi45" <civi45@civicrm.com>',
- 'receipt_date' => '',
- 'receipt_date_time' => '',
'payment_processor_id' => $this->paymentProcessorID,
'currency' => 'USD',
'contribution_page_id' => $this->_ids['contribution_page'],
'source' => 'Membership Signup and Renewal',
- ];
-
- $form->testSubmit($form->_params, CRM_Core_Action::UPDATE);
+ ]);
+ $form->buildForm();
+ $form->postProcess();
// Case 2: After successful payment for Pending backoffice there are three activities created
// 2.a Update status of existing Scheduled Membership Signup (created in step 1) to Completed
// Need to figure out how to stop this some other day
// We don't care about the Payment Processor because this is Pay Later
// The point of this test is to check we get the pay_later version of the mail
- if ($e->getMessage() !== "Undefined variable: CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromContributionPage") {
+ if ($e->getMessage() !== 'Undefined variable: CRM16923AnUnreliableMethodHasBeenUserToDeterminePaymentProcessorFromContributionPage') {
throw $e;
}
}
$contributionPage = $this->callAPISuccess('ContributionPage', 'create', array_merge([
'receipt_from_name' => 'Mickey Mouse',
'receipt_from_email' => 'mickey@mouse.com',
- 'title' => "Test Contribution Page",
+ 'title' => 'Test Contribution Page',
'financial_type_id' => 1,
'currency' => 'CAD',
'is_monetary' => TRUE,
$this->assertNotContains('$', $result['values']);
$result = $this->callAPISuccess('Contribution', 'getoptions', [
'field' => 'currency',
- 'context' => "abbreviate",
+ 'context' => 'abbreviate',
]);
$this->assertEquals('$', $result['values']['USD']);
$this->assertNotContains('US Dollar', $result['values']);