Skip to content

Commit

Permalink
test failure fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
monishdeb committed Jul 4, 2017
1 parent 81a7f7b commit f5e1054
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 7 deletions.
Expand Up @@ -67,6 +67,7 @@ function contribution_create_expectedresult() {
'net_amount' => '95',
'trxn_id' => '',
'invoice_id' => '',
'invoice_number' => '',
'currency' => 'USD',
'cancel_date' => '',
'cancel_reason' => '',
Expand Down
Expand Up @@ -70,6 +70,7 @@ function contribution_create_expectedresult() {
'net_amount' => '90',
'trxn_id' => '12345',
'invoice_id' => '67890',
'invoice_number' => '',
'currency' => 'USD',
'cancel_date' => '',
'cancel_reason' => '',
Expand Down
Expand Up @@ -73,6 +73,7 @@ function contribution_create_expectedresult() {
'net_amount' => '95',
'trxn_id' => '',
'invoice_id' => '',
'invoice_number' => '',
'currency' => 'USD',
'cancel_date' => '',
'cancel_reason' => '',
Expand Down
Expand Up @@ -67,6 +67,7 @@ function contribution_create_expectedresult() {
'net_amount' => '95',
'trxn_id' => '',
'invoice_id' => '',
'invoice_number' => '',
'currency' => 'USD',
'cancel_date' => '',
'cancel_reason' => '',
Expand Down
6 changes: 3 additions & 3 deletions api/v3/examples/Contribution/Create.php
Expand Up @@ -7,7 +7,7 @@
*/
function contribution_create_example() {
$params = array(
'contact_id' => 1,
'contact_id' => 35,
'receive_date' => '20120511',
'total_amount' => '100',
'financial_type_id' => 1,
Expand Down Expand Up @@ -54,7 +54,7 @@ function contribution_create_expectedresult() {
'values' => array(
'1' => array(
'id' => '1',
'contact_id' => '1',
'contact_id' => '35',
'financial_type_id' => '1',
'contribution_page_id' => '1',
'payment_instrument_id' => '4',
Expand All @@ -65,6 +65,7 @@ function contribution_create_expectedresult() {
'net_amount' => '100',
'trxn_id' => '12345',
'invoice_id' => '67890',
'invoice_number' => '',
'currency' => 'USD',
'cancel_date' => '',
'cancel_reason' => '',
Expand All @@ -83,7 +84,6 @@ function contribution_create_expectedresult() {
'tax_amount' => '',
'revenue_recognition_date' => '',
'contribution_type_id' => '1',
'invoice_number' => '',
),
),
);
Expand Down
1 change: 1 addition & 0 deletions api/v3/examples/Contribution/CreateWithNestedLineItems.php
Expand Up @@ -84,6 +84,7 @@ function contribution_create_expectedresult() {
'net_amount' => '90',
'trxn_id' => '12345',
'invoice_id' => '67890',
'invoice_number' => '',
'currency' => 'USD',
'cancel_date' => '',
'cancel_reason' => '',
Expand Down
8 changes: 4 additions & 4 deletions api/v3/examples/Contribution/Get.php
Expand Up @@ -51,6 +51,8 @@ function contribution_get_expectedresult() {
'display_name' => 'Mr. Anthony Anderson II',
'contribution_id' => '1',
'currency' => 'USD',
'payment_instrument' => 'Check',
'payment_instrument_id' => '4',
'receive_date' => '2010-01-20 00:00:00',
'non_deductible_amount' => '10.00',
'total_amount' => '100.00',
Expand All @@ -67,6 +69,7 @@ function contribution_get_expectedresult() {
'contribution_recur_id' => '',
'is_test' => 0,
'is_pay_later' => 0,
'contribution_status' => 'Completed',
'contribution_status_id' => '1',
'contribution_check_number' => '',
'contribution_campaign_id' => '',
Expand All @@ -86,11 +89,8 @@ function contribution_get_expectedresult() {
'contribution_campaign_title' => '',
'contribution_note' => '',
'contribution_batch' => '',
'contribution_status' => 'Completed',
'payment_instrument' => 'Check',
'payment_instrument_id' => '4',
'instrument_id' => '4',
'check_number' => '',
'instrument_id' => '4',
'id' => '1',
'contribution_type_id' => '1',
),
Expand Down
18 changes: 18 additions & 0 deletions tests/phpunit/api/v3/ContributionTest.php
Expand Up @@ -1148,6 +1148,9 @@ public function testCreateUpdateContributionPaymentInstrument() {
$contribution = $this->callAPISuccess('contribution', 'create', $newParams);
$this->assertAPISuccess($contribution);
$this->_checkFinancialTrxn($contribution, 'paymentInstrument', $instrumentId);

// cleanup - delete created payment instrument
$this->_deletedAddedPaymentInstrument();
}

/**
Expand All @@ -1173,6 +1176,9 @@ public function testCreateUpdateNegativeContributionPaymentInstrument() {
$contribution = $this->callAPISuccess('contribution', 'create', $newParams);
$this->assertAPISuccess($contribution);
$this->_checkFinancialTrxn($contribution, 'paymentInstrument', $instrumentId, array('total_amount' => '-100.00'));

// cleanup - delete created payment instrument
$this->_deletedAddedPaymentInstrument();
}

/**
Expand Down Expand Up @@ -3428,6 +3434,18 @@ public function _addPaymentInstrument() {
return $optionValue['values'][$optionValue['id']]['value'];
}

public function _deletedAddedPaymentInstrument() {
$result = $this->callAPISuccess('OptionValue', 'get', array(
'option_group_id' => 'payment_instrument',
'name' => 'Test Card',
'value' => '6',
'is_active' => 1,
));
if ($id = CRM_Utils_Array::value('id', $result)) {
$this->callAPISuccess('OptionValue', 'delete', array('id' => $id));
}
}

/**
* Set up the basic recurring contribution for tests.
*
Expand Down

0 comments on commit f5e1054

Please sign in to comment.