$this->assertEquals(date('Y-m-d 00:00:00', strtotime('+1 month')), $contributionRecur['next_sched_contribution_date']);
}
+ /**
+ * Test completing a pledge with the completeTransaction api..
+ *
+ * Note that we are creating a logged in user because email goes out from
+ * that person.
+ */
+ public function testCompleteTransactionUpdatePledgePayment() {
+ $mut = new CiviMailUtils($this, TRUE);
+ $mut->clearMessages();
+ $this->createLoggedInUser();
+ $contributionID = $this->createPendingPledgeContribution();
+ $this->callAPISuccess('contribution', 'completetransaction', array(
+ 'id' => $contributionID,
+ 'trxn_date' => '1 Feb 2013',
+ ));
+ $pledge = $this->callAPISuccessGetSingle('Pledge', array(
+ 'id' => $this->_ids['pledge'],
+ ));
+ $this->assertEquals('Completed', $pledge['pledge_status']);
+
+ $status = $this->callAPISuccessGetValue('PledgePayment', array(
+ 'pledge_id' => $this->_ids['pledge'],
+ 'return' => 'status_id',
+ ));
+ $this->assertEquals(1, $status);
+ $mut->checkMailLog(array(
+ '$ 500.00',
+ 'May 11th, 2012 12:00 AM',
+ ));
+ $mut->stop();
+ }
+
/**
* Test completing a transaction with an event via the API.
*
}
}
+ /**
+ * Create a pending contribution & linked pending pledge record.
+ */
+ public function createPendingPledgeContribution() {
+
+ $pledgeID = $this->pledgeCreate(array('contact_id' => $this->_individualId, 'installments' => 1, 'amount' => 500));
+ $this->_ids['pledge'] = $pledgeID;
+ $contribution = $this->callAPISuccess('contribution', 'create', array_merge($this->_params, array(
+ 'contribution_status_id' => 'Pending',
+ 'total_amount' => 500,
+ ))
+ );
+ $paymentID = $this->callAPISuccessGetValue('PledgePayment', array(
+ 'options' => array('limit' => 1),
+ 'return' => 'id',
+ ));
+ $this->callAPISuccess('PledgePayment', 'create', array(
+ 'id' => $paymentID,
+ 'contribution_id' =>
+ $contribution['id'],
+ 'status_id' => 'Pending',
+ 'scheduled_amount' => 500,
+ ));
+
+ return $contribution['id'];
+ }
+
/**
* Create a pending contribution & linked pending participant record (along with an event).
*/