*/
class CRM_Core_Payment_BaseIPNTest extends CiviUnitTestCase {
- protected $_contributionTypeId;
+ protected $_financialTypeId;
protected $_contributionParams;
protected $_contactId;
protected $_contributionId;
public function setUp() {
parent::setUp();
+ $this->_processorId = $this->paymentProcessorAuthorizeNetCreate(array('is_test' => 0));
$this->input = $this->ids = $this->objects = array();
$this->IPN = new CRM_Core_Payment_AuthorizeNetIPN($this->input);
$this->_contributionParams = array(
'contact_id' => $this->_contactId,
+ 'version' => 3,
'financial_type_id' => $this->_financialTypeId,
'receive_date' => date('Ymd'),
'total_amount' => 150.00,
'is_test' => 1,
'contribution_status_id' => 2,
);
- $contribution = civicrm_api('contribution', 'create', $this->_contributionParams);
- $this->assertAPISuccess($contribution, 'line ' . __LINE__ . ' set-up of contribution ');
+ $contribution = $this->callAPISuccess('contribution', 'create', $this->_contributionParams);
$this->_contributionId = $contribution['id'];
$contribution = new CRM_Contribute_BAO_Contribution();
$this->_setUpMembershipObjects();
$this->_setUpRecurringContribution();
$this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId);
- $this->assertFalse(empty($this->objects['membership']), 'in line ' . __LINE__);
- $this->assertArrayHasKey($this->_membershipTypeID, $this->objects['membership'], 'in line ' . __LINE__);
+ $this->assertFalse(empty($this->objects['membership']));
+ $this->assertArrayHasKey($this->_membershipTypeID, $this->objects['membership']);
$this->assertTrue(is_a($this->objects['membership'][$this->_membershipTypeID], 'CRM_Member_BAO_Membership'));
$this->assertTrue(is_a($this->objects['contributionType'], 'CRM_Financial_BAO_FinancialType'));
- $this->assertFalse(empty($this->objects['contributionRecur']), __LINE__);
- $this->assertFalse(empty($this->objects['paymentProcessor']), __LINE__);
+ $this->assertFalse(empty($this->objects['contributionRecur']));
+ $this->assertFalse(empty($this->objects['paymentProcessor']));
}
/**
$values = array();
$this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId);
$msg = $this->IPN->sendMail($this->input, $this->ids, $this->objects, $values, FALSE, TRUE);
- $this->assertTrue(is_array($msg), "Message returned as an array in line" . __LINE__);
+ $this->assertTrue(is_array($msg), "Message returned as an array in line");
$this->assertEquals('Mr. Anthony Anderson II', $msg['to']);
$this->assertContains('<p>Please print this confirmation for your records.</p>', $msg['html']);
$this->assertContains('Membership Type: General', $msg['body']);
$this->assertTrue(is_a($this->objects['contribution'], 'CRM_Contribute_BAO_Contribution'));
$this->assertTrue(is_a($this->objects['pledge_payment'][0], 'CRM_Pledge_BAO_PledgePayment'));
$this->assertFalse(empty($this->objects['pledge_payment'][0]->id));
- $this->assertEquals($this->_contributionTypeId, $this->objects['contributionType']->id);
+ $this->assertEquals($this->_financialTypeId, $this->objects['contributionType']->id);
$this->assertEquals($this->_processorId, $this->objects['paymentProcessor']['id']);
$this->assertEquals($this->_contributionId, $this->objects['contribution']->id);
$this->assertEquals($this->_contactId, $this->objects['contact']->id);
}
/**
- *
* Test that an error is not if required set & no processor ID
*/
public function testRequiredWithContributionPage() {
$this->_setUpContributionObjects(TRUE);
-
$result = $this->IPN->loadObjects($this->input, $this->ids, $this->objects, TRUE, NULL, array('return_error' => 1));
- $this->assertFalse(is_array($result), $result['error_message']);
+ $this->assertEquals(1, $result['is_error']);
}
/**
$contribution->id = $this->_contributionId;
$contribution->find(TRUE);
$contributionPageID = NULL;
+
if (!empty($contributionPage)) {
$dao = new CRM_Core_DAO();
$contribution_page = $dao->createTestObject('CRM_Contribute_DAO_ContributionPage');
+ $contribution_page->payment_processor = 1;
+ $contribution_page->save();
$contribution->contribution_page_id = $contributionPageID = $contribution_page->id;
//for unknown reasons trying to do a find & save on a contribution with a receive_date set
// doesn't work. This seems of minimal relevance to this test so ignoring
}
$this->_membershipId = $membership['id'];
//we'll create membership payment here because to make setup more re-usable
- civicrm_api('membership_payment', 'create', array(
- 'version' => 3,
+ $this->callAPISuccess('membership_payment', 'create', array(
'contribution_id' => $this->_contributionId,
'membership_id' => $this->_membershipId,
));
'invoice_id' => 'c8acb91e080ad7bd8a2adc119c192885',
'contribution_status_id' => 2,
'is_test' => 1,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'version' => 3,
'payment_processor_id' => $this->_processorId,
);
public function _setUpPledgeObjects() {
$this->_pledgeId = $this->pledgeCreate($this->_contactId);
//we'll create membership payment here because to make setup more re-usable
- $pledgePayment = civicrm_api('pledge_payment', 'create', array(
+ $pledgePayment = $this->callAPISuccess('pledge_payment', 'create', array(
'version' => 3,
'pledge_id' => $this->_pledgeId,
'contribution_id' => $this->_contributionId,
'status_id' => 1,
'actual_amount' => 50,
));
- $this->assertAPISuccess($pledgePayment, 'line ' . __LINE__ . ' set-up of pledge payment');
+
$this->input = array(
'component' => 'contribute',
'total_amount' => 150.00,