*/
protected $_individualId;
protected $_contribution;
- protected $_contributionTypeId = 1;
+ protected $_financialTypeId = 1;
protected $_apiversion;
protected $_entity = 'Contribution';
public $debug = 0;
'contact_id' => $this->_individualId,
'receive_date' => '20120511',
'total_amount' => 100.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'non_deductible_amount' => 10.00,
'fee_amount' => 5.00,
'net_amount' => 95.00,
'source' => 'SSF',
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
);
$this->_processorParams = array(
'domain_id' => 1,
'billing_mode' => 1,
);
$this->_pageParams = array(
- 'version' => 3,
'title' => 'Test Contribution Page',
'financial_type_id' => 1,
'currency' => 'USD',
}
function tearDown() {
-
- $this->contributionTypeDelete();
$this->quickCleanup(array(
'civicrm_contribution',
'civicrm_contribution_soft',
));
}
- ///////////////// civicrm_contribution_get methods
-
- function testGetParamsNotArrayContribution() {
- $params = 'contact_id= 1';
- $contribution = $this->callAPIFailure('contribution', 'get', $params);
- $this->assertEquals($contribution['error_message'], 'Input variable `params` is not an array');
- }
-
function testGetContribution() {
$p = array(
'contact_id' => $this->_individualId,
'receive_date' => '2010-01-20',
'total_amount' => 100.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'non_deductible_amount' => 10.00,
'fee_amount' => 5.00,
'net_amount' => 95.00,
'invoice_id' => 78910,
'source' => 'SSF',
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
);
$this->_contribution = $this->callAPISuccess('contribution', 'create', $p);
$params = array(
'contribution_id' => $this->_contribution['id'],
- 'version' => $this->_apiversion,
);
$contribution = $this->callAPIAndDocument('contribution', 'get', $params, __FUNCTION__, __FILE__);
- $financialParams['id'] = $this->_contributionTypeId;
+ $financialParams['id'] = $this->_financialTypeId;
$default = null;
$financialType = CRM_Financial_BAO_FinancialType::retrieve($financialParams,$default);
$contribution2 = $this->callAPISuccess('contribution', 'create', $p);
-
- $params = array(
- 'version' => $this->_apiversion,
- );
// now we have 2 - test getcount
- $contribution = civicrm_api('contribution', 'getcount', array(
- 'version' => $this->_apiversion,
- ));
+ $contribution = $this->callAPISuccess('contribution', 'getcount', array());
$this->assertEquals(2, $contribution);
//test id only format
- $contribution = $this->callAPISuccess('contribution', 'get', array
- ('version' => $this->_apiversion,
- 'id' => $this->_contribution['id'],
- 'format.only_id' => 1,
- )
- );
+ $contribution = $this->callAPISuccess('contribution', 'get', array(
+ 'id' => $this->_contribution['id'],
+ 'format.only_id' => 1,
+ ));
$this->assertEquals($this->_contribution['id'], $contribution, print_r($contribution,true) . " in line " . __LINE__);
//test id only format
- $contribution = $this->callAPISuccess('contribution', 'get', array
- ('version' => $this->_apiversion,
- 'id' => $contribution2['id'],
- 'format.only_id' => 1,
- )
- );
- $this->assertEquals($contribution2['id'], $contribution);
$contribution = $this->callAPISuccess('contribution', 'get', array(
- 'version' => $this->_apiversion,
- 'id' => $this->_contribution['id'],
- ));
+ 'id' => $contribution2['id'],
+ 'format.only_id' => 1,
+ ));
+ $this->assertEquals($contribution2['id'], $contribution);
//test id as field
-
+ $contribution = $this->callAPISuccess('contribution', 'get', array(
+ 'id' => $this->_contribution['id'],
+ ));
$this->assertEquals(1, $contribution['count'], 'In line ' . __LINE__);
- // $this->assertEquals($this->_contribution['id'], $contribution['id'] ) ;
+
//test get by contact id works
- $contribution = $this->callAPISuccess('contribution', 'get', array('version' => $this->_apiversion, 'contact_id' => $this->_individualId));
+ $contribution = $this->callAPISuccess('contribution', 'get', array('contact_id' => $this->_individualId));
$this->assertEquals(2, $contribution['count'], 'In line ' . __LINE__);
$this->callAPISuccess('Contribution', 'Delete', array(
'id' => $this->_contribution['id'],
- 'version' => $this->_apiversion,
- ));
+ ));
$this->callAPISuccess('Contribution', 'Delete', array(
'id' => $contribution2['id'],
- 'version' => $this->_apiversion,
- ));
+ ));
}
/**
'contact_id' => $this->_individualId,
'receive_date' => '2010-01-20',
'total_amount' => 100.00,
- 'contribution_type_id' => $this->_contributionTypeId,
+ 'contribution_type_id' => $this->_financialTypeId,
'non_deductible_amount' => 10.00,
'fee_amount' => 5.00,
'net_amount' => 95.00,
'invoice_id' => 78910,
'source' => 'SSF',
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
);
$this->_contribution = $this->callAPISuccess('contribution', 'create', $p);
$params = array(
'contribution_id' => $this->_contribution['id'],
- 'version' => $this->_apiversion,
);
$contribution = $this->callAPIAndDocument('contribution', 'get', $params, __FUNCTION__, __FILE__);
- $financialParams['id'] = $this->_contributionTypeId;
+ $financialParams['id'] = $this->_financialTypeId;
$default = null;
$financialType = CRM_Financial_BAO_FinancialType::retrieve($financialParams,$default);
$this->assertEquals(1,$contribution['count']);
$this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId, 'In line ' . __LINE__);
- $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], $this->_contributionTypeId);
- $this->assertEquals($contribution['values'][$contribution['id']]['contribution_type_id'], $this->_contributionTypeId);
+ $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], $this->_financialTypeId);
+ $this->assertEquals($contribution['values'][$contribution['id']]['contribution_type_id'], $this->_financialTypeId);
$this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['non_deductible_amount'], 10.00, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['fee_amount'], 5.00, 'In line ' . __LINE__);
$contribution2 = $this->callAPISuccess('contribution', 'create', $p);
- $params = array(
- 'version' => $this->_apiversion,
- );
// now we have 2 - test getcount
- $contribution = civicrm_api('contribution', 'getcount', array(
- 'version' => $this->_apiversion,
- ));
+ $contribution = $this->callAPISuccess('contribution', 'getcount', array());
$this->assertEquals(2, $contribution);
//test id only format
- $contribution = civicrm_api('contribution', 'get', array
- ('version' => $this->_apiversion,
- 'id' => $this->_contribution['id'],
- 'format.only_id' => 1,
- )
- );
+ $contribution = $this->callAPISuccess('contribution', 'get', array(
+ 'id' => $this->_contribution['id'],
+ 'format.only_id' => 1,
+ ));
$this->assertEquals($this->_contribution['id'], $contribution, print_r($contribution,true) . " in line " . __LINE__);
//test id only format
- $contribution = civicrm_api('contribution', 'get', array
- ('version' => $this->_apiversion,
- 'id' => $contribution2['id'],
- 'format.only_id' => 1,
- )
- );
+ $contribution = $this->callAPISuccess('contribution', 'get', array(
+ 'id' => $contribution2['id'],
+ 'format.only_id' => 1,
+ ));
$this->assertEquals($contribution2['id'], $contribution);
$contribution = $this->callAPISuccess('contribution', 'get', array(
- 'version' => $this->_apiversion,
'id' => $this->_contribution['id'],
));
//test id as field
$this->assertEquals(1, $contribution['count'], 'In line ' . __LINE__);
// $this->assertEquals($this->_contribution['id'], $contribution['id'] ) ;
//test get by contact id works
- $contribution = $this->callAPISuccess('contribution', 'get', array('version' => $this->_apiversion, 'contact_id' => $this->_individualId));
+ $contribution = $this->callAPISuccess('contribution', 'get', array('contact_id' => $this->_individualId));
$this->assertEquals(2, $contribution['count'], 'In line ' . __LINE__);
$this->callAPISuccess('Contribution', 'Delete', array(
'id' => $this->_contribution['id'],
- 'version' => $this->_apiversion,
));
$this->callAPISuccess('Contribution', 'Delete', array(
'id' => $contribution2['id'],
- 'version' => $this->_apiversion,
));
}
///////////////// civicrm_contribution_
'contribution_id' => FALSE,
'contact_id' => 1,
'total_amount' => 1,
- 'version' => 3,
'check_permissions' => false,
'financial_type_id' => 'Donation',
);
'contribution_id' => FALSE,
'contact_id' => 1,
'total_amount' => 1,
- 'version' => 3,
'check_permissions' => false,
'contribution_type_id' => 3,
);
$contribution = $this->callAPISuccess('contribution', 'create', $params);
- $contribution = civicrm_api('contribution', 'getsingle', array('version' => $this->_apiversion, 'id' => $contribution['id']));
+ $contribution = $this->callAPISuccess('contribution', 'getsingle', array( 'id' => $contribution['id']));
$this->assertEquals(3, $contribution['financial_type_id']);
}
- ///////////////// civicrm_contribution_
- function testCreateEmptyParamsContribution() {
- $params = array('version' => $this->_apiversion);
- $contribution = $this->callAPIFailure('contribution', 'create', $params);
- $this->assertEquals($contribution['error_message'], 'Mandatory key(s) missing from params array: financial_type_id, total_amount, contact_id', 'In line ' . __LINE__);
- }
-
- function testCreateParamsWithoutRequiredKeys() {
- $params = array('version' => 3);
- $contribution = $this->callAPIFailure('contribution', 'create', $params);
- $this->assertEquals($contribution['error_message'], 'Mandatory key(s) missing from params array: financial_type_id, total_amount, contact_id');
- }
-
/**
* check with complete array + custom field
* Note that the test is written on purpose without any
$result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals($result['id'], $result['values'][$result['id']]['id']);
$check = $this->callAPISuccess($this->_entity, 'get', array(
- 'return.custom_' . $ids['custom_field_id'] => 1,
- 'version' => 3,
- 'id' => $result['id'],
- )
- );
+ 'return.custom_' . $ids['custom_field_id'] => 1,
+ 'id' => $result['id'],
+ ));
$this->customFieldDelete($ids['custom_field_id']);
$this->customGroupDelete($ids['custom_group_id']);
$this->assertEquals("custom string", $check['values'][$check['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__);
function testCreateGetFieldsWithCustom() {
$ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
$idsContact = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, 'ContactTest.php');
- $result = $this->callAPISuccess('Contribution', 'getfields', array('version' => 3));
+ $result = $this->callAPISuccess('Contribution', 'getfields', array());
$this->assertArrayHasKey('custom_' . $ids['custom_field_id'], $result['values']);
$this->assertArrayNotHasKey('custom_' . $idsContact['custom_field_id'], $result['values']);
$this->customFieldDelete($ids['custom_field_id']);
'contact_id' => $this->_individualId,
'receive_date' => '20120511',
'total_amount' => 100.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'payment_instrument_id' => 1,
'non_deductible_amount' => 10.00,
'fee_amount' => 50.00,
'invoice_id' => 67890,
'source' => 'SSF',
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
'skipLineItem' => 1,
);
$contribution = $this->callAPISuccess('contribution', 'create', $params);
$lineItems = $this->callAPISuccess('line_item','get',array(
- 'version' => $this->_apiversion,
'entity_id' => $contribution['id'],
'entity_table' => 'civicrm_contribution',
'sequential' => 1,
'contact_id' => $this->_individualId,
'receive_date' => '20120511',
'total_amount' => 100.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'payment_instrument_id' => 1,
'non_deductible_amount' => 10.00,
'fee_amount' => 50.00,
'invoice_id' => 67890,
'source' => 'SSF',
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
'skipLineItem' => 1,
'api.line_item.create' => array(
array(
$contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__,__FILE__, $description, $subfile);
$lineItems = $this->callAPISuccess('line_item','get',array(
- 'version' => $this->_apiversion,
'entity_id' => $contribution['id'],
'entity_table' => 'civicrm_contribution',
'sequential' => 1,
'invoice_id' => 67890,
'source' => 'SSF',
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
);
- $contribution = civicrm_api('contribution', 'create', $params);
- $this->documentMe($params, $contribution, __FUNCTION__, __FILE__);
+ $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'],1, 'In line ' . __LINE__ );
$this->assertEquals($contribution['values'][$contribution['id']]['invoice_id'], 67890, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['source'], 'SSF', 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['contribution_status_id'], 1, 'In line ' . __LINE__);
- $lineItems = civicrm_api('line_item','get',array(
- 'version' => $this->_apiversion,
+ $lineItems = $this->callAPISuccess('line_item','get',array(
'entity_id' => $contribution['id'],
'entity_table' => 'civicrm_contribution',
'sequential' => 1,
$this->assertEquals(1, $lineItems['count']);
$this->assertEquals($contribution['id'], $lineItems['values'][0]['entity_id']);
$this->assertEquals($contribution['id'], $lineItems['values'][0]['entity_id']);
- $lineItems = civicrm_api('line_item','get',array(
- 'version' => $this->_apiversion,
- 'entity_id' => $contribution['id'],
- 'entity_table' => 'civicrm_contribution',
- 'sequential' => 1,
+ $lineItems = $this->callAPISuccess('line_item','get',array(
+ 'entity_id' => $contribution['id'],
+ 'entity_table' => 'civicrm_contribution',
+ 'sequential' => 1,
));
$this->assertEquals(1, $lineItems['count']);
$this->_checkFinancialRecords($contribution, 'offline');
function testGetContributionByPaymentInstrument() {
$params = $this->_params + array('payment_instrument' => 'EFT');
$params2 = $this->_params + array('payment_instrument' => 'Cash');
- civicrm_api('contribution','create',$params);
- $contribution = civicrm_api('contribution','create',$params2);
- $this->assertAPISuccess($contribution);
- $contribution = civicrm_api('contribution','get',array('version'=> 3, 'sequential' => 1, 'contribution_payment_instrument_id' => 'Cash'));
+ $this->callAPISuccess('contribution','create',$params);
+ $this->callAPISuccess('contribution','create',$params2);
+ $contribution = $this->callAPISuccess('contribution','get',array( 'sequential' => 1, 'contribution_payment_instrument_id' => 'Cash'));
$this->assertArrayHasKey('payment_instrument', $contribution['values'][0]);
$this->assertEquals('Cash',$contribution['values'][0]['payment_instrument']);
$this->assertEquals(1,$contribution['count']);
- $contribution = civicrm_api('contribution','get',array('version'=> 3, 'sequential' => 1, 'payment_instrument_id' => 'EFT'));
+ $contribution = $this->callAPISuccess('contribution','get',array('sequential' => 1, 'payment_instrument_id' => 'EFT'));
$this->assertArrayHasKey('payment_instrument', $contribution['values'][0]);
$this->assertEquals('EFT',$contribution['values'][0]['payment_instrument']);
$this->assertEquals(1, $contribution['count']);
- $contribution = civicrm_api('contribution','get',array('version'=> 3, 'sequential' => 1, 'payment_instrument_id' => 5));
+ $contribution = $this->callAPISuccess('contribution','get',array( 'sequential' => 1, 'payment_instrument_id' => 5));
$this->assertArrayHasKey('payment_instrument', $contribution['values'][0]);
$this->assertEquals('EFT',$contribution['values'][0]['payment_instrument']);
$this->assertEquals(1,$contribution['count']);
- $contribution = civicrm_api('contribution','get',array('version'=> 3, 'sequential' => 1, 'payment_instrument' => 'EFT'));
+ $contribution = $this->callAPISuccess('contribution','get',array( 'sequential' => 1, 'payment_instrument' => 'EFT'));
$this->assertArrayHasKey('payment_instrument', $contribution['values'][0]);
$this->assertEquals('EFT', $contribution['values'][0]['payment_instrument']);
$this->assertEquals(1, $contribution['count']);
- $contribution = civicrm_api('contribution', 'update', array('id' => $contribution['id'], 'version' => $this->_apiversion, 'payment_instrument' => 'Credit Card'));
- $this->assertAPISuccess($contribution);
- $contribution = civicrm_api('contribution','get',array('version'=> 3, 'sequential' => 1, 'id' => $contribution['id'], ));
+ $contribution = $this->callAPISuccess('contribution', 'update', array('id' => $contribution['id'], 'payment_instrument' => 'Credit Card'));
+ $contribution = $this->callAPISuccess('contribution','get',array( 'sequential' => 1, 'id' => $contribution['id'], ));
$this->assertArrayHasKey('payment_instrument', $contribution['values'][0]);
$this->assertEquals('Credit Card',$contribution['values'][0]['payment_instrument']);
$this->assertEquals(1,$contribution['count']);
'contact_id' => $this->_individualId,
'receive_date' => date('Ymd'),
'total_amount' => 100.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'payment_instrument_id' => 1,
'non_deductible_amount' => 10.00,
'fee_amount' => 50.00,
'invoice_id' => 67890,
'contribution_source' => 'SSF',
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
);
- $contribution = civicrm_api('contribution', 'create', $params);
-
- $this->assertAPISuccess($contribution, 'In line ' . __LINE__);
+ $contribution = $this->callAPISuccess('contribution', 'create', $params);
$this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['source'], 'SSF', 'In line ' . __LINE__);
}
'contact_id' => 999,
'receive_date' => date('Ymd'),
'total_amount' => 100.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'payment_instrument_id' => 1,
'non_deductible_amount' => 10.00,
'fee_amount' => 50.00,
'invoice_id' => 67890,
'contribution_source' => 'SSF',
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
);
- $contribution = civicrm_api('contribution', 'create', $params);
- $this->assertEquals($contribution['error_message'], 'contact_id is not valid : 999', 'In line ' . __LINE__);
+ $contribution = $this->callAPIFailure('contribution', 'create', $params,
+ 'contact_id is not valid : 999');
}
function testCreateContributionSourceInvalidContContac() {
'contribution_contact_id' => 999,
'receive_date' => date('Ymd'),
'total_amount' => 100.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'payment_instrument_id' => 1,
'non_deductible_amount' => 10.00,
'fee_amount' => 50.00,
'invoice_id' => 67890,
'contribution_source' => 'SSF',
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
);
- $contribution = civicrm_api('contribution', 'create', $params);
- $this->assertEquals($contribution['error_message'], 'contact_id is not valid : 999', 'In line ' . __LINE__);
+ $contribution = $this->callAPIFailure('contribution', 'create', $params,
+ 'contact_id is not valid : 999', 'In line ' . __LINE__);
}
function testCreateContributionWithNote() {
'contact_id' => $this->_individualId,
'receive_date' => '2012-01-01',
'total_amount' => 100.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'payment_instrument_id' => 1,
'non_deductible_amount' => 10.00,
'fee_amount' => 50.00,
'invoice_id' => 67890,
'source' => 'SSF',
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
'note' => 'my contribution note',
);
- $contribution = civicrm_api('contribution', 'create', $params);
- $this->documentMe($params, $contribution, __FUNCTION__, __FILE__, $description, $subfile);
- $result = civicrm_api('note', 'get', array('version' => 3, 'entity_table' => 'civicrm_contribution', 'entity_id' => $contribution['id'], 'sequential' => 1));
- $this->assertAPISuccess($result);
+ $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
+ $result = $this->callAPISuccess('note', 'get', array('entity_table' => 'civicrm_contribution', 'entity_id' => $contribution['id'], 'sequential' => 1));
$this->assertEquals('my contribution note', $result['values'][0]['note']);
- civicrm_api('contribution', 'delete', array('version' => 3, 'id' => $contribution['id']));
+ $this->callAPISuccess('contribution', 'delete', array('id' => $contribution['id']));
}
function testCreateContributionWithNoteUniqueNameAliases() {
'contact_id' => $this->_individualId,
'receive_date' => '2012-01-01',
'total_amount' => 100.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'payment_instrument_id' => 1,
'non_deductible_amount' => 10.00,
'fee_amount' => 50.00,
'invoice_id' => 67890,
'source' => 'SSF',
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
'contribution_note' => 'my contribution note',
);
- $contribution = civicrm_api('contribution', 'create', $params);
- $result = civicrm_api('note', 'get', array('version' => 3, 'entity_table' => 'civicrm_contribution', 'entity_id' => $contribution['id'], 'sequential' => 1));
- $this->assertAPISuccess($result);
+ $contribution = $this->callAPISuccess('contribution', 'create', $params);
+ $result = $this->callAPISuccess('note', 'get', array('entity_table' => 'civicrm_contribution', 'entity_id' => $contribution['id'], 'sequential' => 1));
$this->assertEquals('my contribution note', $result['values'][0]['note']);
- civicrm_api('contribution', 'delete', array('version' => 3, 'id' => $contribution['id']));
+ $this->callAPISuccess('contribution', 'delete', array('id' => $contribution['id']));
}
/*
* This is the test for creating soft credits - however a 'get' is not yet possible via API
function testCreateContributionWithSoftCredt() {
$description = "Demonstrates creating contribution with SoftCredit";
$subfile = "ContributionCreateWithSoftCredit";
- $contact2 = civicrm_api('Contact', 'create', array('version' => 3, 'display_name' => 'superman', 'version' => 3, 'contact_type' => 'Individual'));
+ $contact2 = $this->callAPISuccess('Contact', 'create', array('display_name' => 'superman', 'contact_type' => 'Individual'));
$params = $this->_params + array(
'soft_credit_to' => $contact2['id'],
);
- $contribution = civicrm_api('contribution', 'create', $params);
- $this->assertAPISuccess($contribution);
- $this->documentMe($params, $contribution, __FUNCTION__, __FILE__, $description, $subfile);
- // $result = civicrm_api('contribution','get', array('version' => 3,'return'=> 'soft_credit_to', 'sequential' => 1));
- // $this->assertAPISuccess($result);
+ $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
+ // $result = $this->callAPISuccess('contribution','get', array('return'=> 'soft_credit_to', 'sequential' => 1));
// $this->assertEquals($contact2['id'], $result['values'][$result['id']]['soft_credit_to']) ;
// well - the above doesn't work yet so lets do SQL
$query = "SELECT count(*) FROM civicrm_contribution_soft WHERE contact_id = " . $contact2['id'];
$count = CRM_Core_DAO::singleValueQuery($query);
$this->assertEquals(1, $count);
- civicrm_api('contribution', 'delete', array('version' => 3, 'id' => $contribution['id']));
- civicrm_api('contact', 'delete', array('version' => 3, 'id' => $contact2['id']));
+ $this->callAPISuccess('contribution', 'delete', array('id' => $contribution['id']));
+ $this->callAPISuccess('contact', 'delete', array('id' => $contact2['id']));
}
/**
*/
function testContributionCreateExample() {
//make sure at least on page exists since there is a truncate in tear down
- $page = civicrm_api('contribution_page', 'create', $this->_pageParams);
- $this->assertAPISuccess($page);
+ $page = $this->callAPISuccess('contribution_page', 'create', $this->_pageParams);
require_once 'api/v3/examples/ContributionCreate.php';
- $result = contribution_create_example();
+ $result = contribution_create_example();
$this->assertAPISuccess($result);
$contributionId = $result['id'];
$expectedResult = contribution_create_expectedresult();
'invoice_id' => 67890,
'source' => 'SSF',
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
);
- $contribution = civicrm_api('contribution', 'create', $params);
- $this->documentMe($params, $contribution, __FUNCTION__, __FILE__);
+ $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'],1, 'In line ' . __LINE__ );
$this->assertEquals($contribution['values'][$contribution['id']]['invoice_id'], 67890, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['source'], 'SSF', 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['contribution_status_id'], 1, 'In line ' . __LINE__);
- $lineItems = civicrm_api('line_item','get',array(
- 'version' => $this->_apiversion,
+ $lineItems = $this->callAPISuccess('line_item','get',array(
+
'entity_id' => $contribution['id'],
'entity_table' => 'civicrm_contribution',
'sequential' => 1,
$this->assertEquals(1, $lineItems['count']);
$this->assertEquals($contribution['id'], $lineItems['values'][0]['entity_id']);
$this->assertEquals($contribution['id'], $lineItems['values'][0]['entity_id']);
- $lineItems = civicrm_api('line_item','get',array(
- 'version' => $this->_apiversion,
+ $lineItems = $this->callAPISuccess('line_item','get',array(
+
'entity_id' => $contribution['id'],
'entity_table' => 'civicrm_contribution',
'sequential' => 1,
*/
function testCreateContributionOnline() {
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::create($this->_processorParams);
- $contributionPage = civicrm_api( 'contribution_page','create', $this->_pageParams );
- $this->assertAPISuccess($contributionPage);
+ $contributionPage = $this->callAPISuccess( 'contribution_page','create', $this->_pageParams );
$params = array(
'contact_id' => $this->_individualId,
'receive_date' => '20120511',
'invoice_id' => 67890,
'source' => 'SSF',
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
+
);
- $contribution = civicrm_api('contribution', 'create', $params);
- $this->documentMe($params, $contribution, __FUNCTION__, __FILE__);
+ $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'],1, 'In line ' . __LINE__ );
function testCreateContributionPayLaterOnline() {
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::create($this->_processorParams);
$this->_pageParams['is_pay_later'] = 1;
- $contributionPage = civicrm_api( 'contribution_page','create',$this->_pageParams );
- $this->assertAPISuccess($contributionPage);
+ $contributionPage = $this->callAPISuccess( 'contribution_page','create',$this->_pageParams );
$params = array(
'contact_id' => $this->_individualId,
'receive_date' => '20120511',
'invoice_id' => 67890,
'source' => 'SSF',
'contribution_status_id' => 2,
- 'version' => $this->_apiversion,
+
);
- $contribution = civicrm_api('contribution', 'create', $params);
- $this->documentMe($params, $contribution, __FUNCTION__, __FILE__);
+ $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'],1, 'In line ' . __LINE__ );
*/
function testCreateContributionPendingOnline() {
$paymentProcessor = CRM_Financial_BAO_PaymentProcessor::create($this->_processorParams);
- $contributionPage = civicrm_api( 'contribution_page', 'create', $this->_pageParams );
- $this->assertAPISuccess($contributionPage);
+ $contributionPage = $this->callAPISuccess( 'contribution_page', 'create', $this->_pageParams );
$params = array(
'contact_id' => $this->_individualId,
'receive_date' => '20120511',
'invoice_id' => 67890,
'source' => 'SSF',
'contribution_status_id' => 2,
- 'version' => $this->_apiversion,
);
- $contribution = civicrm_api('contribution', 'create', $params);
- $this->documentMe($params, $contribution, __FUNCTION__, __FILE__);
+ $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 100.00, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'],1, 'In line ' . __LINE__ );
* Function tests that line items, financial records are updated when contribution amount is changed
*/
function testCreateUpdateContributionChangeTotal() {
- $contribution = civicrm_api('contribution', 'create', $this->_params);
- $lineItems = civicrm_api('line_item','getvalue', array(
- 'version' => $this->_apiversion,
+ $contribution = $this->callAPISuccess('contribution', 'create', $this->_params);
+ $lineItems = $this->callAPISuccess('line_item','getvalue', array(
+
'entity_id' => $contribution['id'],
'entity_table' => 'civicrm_contribution',
'sequential' => 1,
// Financial trxn SUM = 100 + 5 (fee)
$this->assertEquals('105.00', $trxnAmount);
$newParams = array(
- 'version' => $this->_apiversion,
+
'id' => $contribution['id'],
'total_amount' => '125');
- $contribution = civicrm_api('contribution', 'update', $newParams);
+ $contribution = $this->callAPISuccess('contribution', 'update', $newParams);
+
+ $lineItems = $this->callAPISuccess('line_item','getvalue',array(
- $lineItems = civicrm_api('line_item','getvalue',array(
- 'version' => $this->_apiversion,
'entity_id' => $contribution['id'],
'entity_table' => 'civicrm_contribution',
'sequential' => 1,
'contact_id' => $this->_individualId,
'receive_date' => '2012-01-01',
'total_amount' => 100.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'payment_instrument_id' => 1,
'contribution_status_id' => 2,
'is_pay_later' => 1,
- 'version' => $this->_apiversion,
+
);
- $contribution = civicrm_api('contribution', 'create', $contribParams);
+ $contribution = $this->callAPISuccess('contribution', 'create', $contribParams);
$newParams = array_merge($contribParams, array(
'id' => $contribution['id'],
'contribution_status_id' => 1,)
);
- $contribution = civicrm_api('contribution', 'update', $newParams);
+ $contribution = $this->callAPISuccess('contribution', 'update', $newParams);
$contribution = $contribution['values'][$contribution['id']];
$this->assertEquals($contribution['contribution_status_id'],'1');
$this->_checkFinancialItem($contribution['id'], 'paylater');
$contribParams = array(
'contact_id' => $this->_individualId,
'total_amount' => 100.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'payment_instrument_id' => 4,
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
+
);
- $contribution = civicrm_api('contribution', 'create', $contribParams);
+ $contribution = $this->callAPISuccess('contribution', 'create', $contribParams);
$newParams = array_merge($contribParams, array(
'id' => $contribution['id'],
'payment_instrument_id' => $instrumentId,)
);
- $contribution = civicrm_api('contribution', 'update', $newParams);
- $this->assertAPISuccess($contribution);
+ $contribution = $this->callAPISuccess('contribution', 'update', $newParams);
$this->_checkFinancialTrxn($contribution, 'paymentInstrument');
}
'contact_id' => $this->_individualId,
'receive_date' => '2012-01-01',
'total_amount' => 100.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'payment_instrument_id' => 4,
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
+
);
- $contribution = civicrm_api('contribution', 'create', $contribParams);
+ $contribution = $this->callAPISuccess('contribution', 'create', $contribParams);
$newParams = array_merge($contribParams, array(
'id' => $contribution['id'],
'contribution_status_id' => 7,
)
);
- $contribution = civicrm_api('contribution', 'update', $newParams);
+ $contribution = $this->callAPISuccess('contribution', 'update', $newParams);
$this->_checkFinancialTrxn($contribution, 'refund');
$this->_checkFinancialItem($contribution['id'], 'refund');
}
'financial_type_id' => 1,
'payment_instrument_id' => 1,
'contribution_status_id' => 1,
- 'version' => 3,
);
- $contribution = civicrm_api('contribution', 'create', $contribParams);
+ $contribution = $this->callAPISuccess('contribution', 'create', $contribParams);
$newParams = array_merge($contribParams, array(
'id' => $contribution['id'],
'contribution_status_id' => 2,
)
);
- $contribution = $this->callAPIFailure('contribution', 'update', $newParams);
- $this->assertEquals($contribution['error_message'], ts('Cannot change contribution status from Completed to Pending.'), 'In line ' . __LINE__);
+ $contribution = $this->callAPIFailure('contribution', 'update', $newParams,
+ ts('Cannot change contribution status from Completed to Pending.')
+ );
}
'contact_id' => $this->_individualId,
'receive_date' => '2012-01-01',
'total_amount' => 100.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'payment_instrument_id' => 1,
'contribution_status_id' => 2,
'is_pay_later' => 1,
- 'version' => $this->_apiversion,
+
);
- $contribution = civicrm_api('contribution', 'create', $contribParams);
+ $contribution = $this->callAPISuccess('contribution', 'create', $contribParams);
$newParams = array_merge($contribParams, array(
'id' => $contribution['id'],
'contribution_status_id' => 3,
)
);
- $contribution = civicrm_api('contribution', 'update', $newParams);
+ $contribution = $this->callAPISuccess('contribution', 'update', $newParams);
$this->_checkFinancialTrxn($contribution, 'cancelPending');
$this->_checkFinancialItem($contribution['id'], 'cancelPending');
}
'financial_type_id' => 1,
'payment_instrument_id' => 1,
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
+
);
- $contribution = civicrm_api('contribution', 'create', $contribParams);
+ $contribution = $this->callAPISuccess('contribution', 'create', $contribParams);
$newParams = array_merge($contribParams, array(
'id' => $contribution['id'],
'financial_type_id' => 3,
)
);
- $contribution = civicrm_api('contribution', 'update', $newParams);
+ $contribution = $this->callAPISuccess('contribution', 'update', $newParams);
$this->_checkFinancialTrxn($contribution, 'changeFinancial');
$this->_checkFinancialItem($contribution['id'], 'changeFinancial');
}
//CHANGE: we require the API to do an incremental update
function testCreateUpdateContribution() {
- $contributionID = $this->contributionCreate($this->_individualId, $this->_contributionTypeId, 'idofsh', 212355);
+ $contributionID = $this->contributionCreate($this->_individualId, $this->_financialTypeId, 'idofsh', 212355);
$old_params = array(
'contribution_id' => $contributionID,
- 'version' => $this->_apiversion,
+
);
- $original = civicrm_api('contribution', 'get', $old_params);
- //Make sure it came back
- $this->assertAPISuccess($original, 'In line ' . __LINE__);
+ $original = $this->callAPISuccess('contribution', 'get', $old_params);
$this->assertEquals($original['id'], $contributionID, 'In line ' . __LINE__);
//set up list of old params, verify
'id' => $contributionID,
'contact_id' => $this->_individualId,
'total_amount' => 110.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'non_deductible_amount' => 10.00,
'net_amount' => 100.00,
'contribution_status_id' => 1,
'note' => 'Donating for Nobel Cause',
- 'version' => $this->_apiversion,
+
);
- $contribution = civicrm_api('contribution', 'create', $params);
+ $contribution = $this->callAPISuccess('contribution', 'create', $params);
$new_params = array(
'contribution_id' => $contribution['id'],
- 'version' => $this->_apiversion,
+
);
- $contribution = civicrm_api('contribution', 'get', $new_params);
+ $contribution = $this->callAPISuccess('contribution', 'get', $new_params);
$this->assertEquals($contribution['values'][$contributionID]['contact_id'], $this->_individualId, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contributionID]['total_amount'], 110.00, 'In line ' . __LINE__);
- $this->assertEquals($contribution['values'][$contributionID]['financial_type_id'],$this->_contributionTypeId, 'In line ' . __LINE__ );
+ $this->assertEquals($contribution['values'][$contributionID]['financial_type_id'],$this->_financialTypeId, 'In line ' . __LINE__ );
$this->assertEquals($contribution['values'][$contributionID]['instrument_id'], $old_payment_instrument, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contributionID]['non_deductible_amount'], 10.00, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contributionID]['fee_amount'], $old_fee_amount, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contributionID]['contribution_status'], 'Completed', 'In line ' . __LINE__);
$params = array(
'contribution_id' => $contributionID,
- 'version' => $this->_apiversion,
+
);
- $result = civicrm_api('contribution', 'delete', $params);
- $this->assertAPISuccess($result, 'in line' . __LINE__);
+ $result = $this->callAPISuccess('contribution', 'delete', $params);
}
///////////////// civicrm_contribution_delete methods
function testDeleteEmptyParamsContribution() {
- $params = array('version' => $this->_apiversion);
+ $params = array();
$contribution = $this->callAPIFailure('contribution', 'delete', $params);
}
function testDeleteWrongParamContribution() {
$params = array(
'contribution_source' => 'SSF',
- 'version' => $this->_apiversion,
+
);
$contribution = $this->callAPIFailure('contribution', 'delete', $params);
}
function testDeleteContribution() {
- $contributionID = $this->contributionCreate($this->_individualId, $this->_contributionTypeId, 'dfsdf', 12389);
+ $contributionID = $this->contributionCreate($this->_individualId, $this->_financialTypeId, 'dfsdf', 12389);
$params = array(
'id' => $contributionID,
- 'version' => $this->_apiversion,
);
- $result = civicrm_api('contribution', 'delete', $params);
- $this->documentMe($params, $result, __FUNCTION__, __FILE__);
- $this->assertAPISuccess($result, 0, 'In line ' . __LINE__);
+ $this->callAPIAndDocument('contribution', 'delete', $params, __FUNCTION__, __FILE__);
}
/**
* All available contributions expected.
*/
function testSearchEmptyParams() {
- $params = array('version' => $this->_apiversion);
+ $params = array();
$p = array(
'contact_id' => $this->_individualId,
'receive_date' => date('Ymd'),
'total_amount' => 100.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'non_deductible_amount' => 10.00,
'fee_amount' => 5.00,
'net_amount' => 95.00,
'invoice_id' => 78910,
'source' => 'SSF',
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
+
);
- $contribution = civicrm_api('contribution', 'create', $p);
+ $contribution = $this->callAPISuccess('contribution', 'create', $p);
- $result = civicrm_api('contribution', 'get', $params);
+ $result = $this->callAPISuccess('contribution', 'get', $params);
// We're taking the first element.
$res = $result['values'][$contribution['id']];
'contact_id' => $this->_individualId,
'receive_date' => date('Ymd'),
'total_amount' => 100.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'non_deductible_amount' => 10.00,
'contribution_status_id' => 1,
- 'version' => $this->_apiversion,
+
);
- $contribution1 = civicrm_api('contribution', 'create', $p1);
+ $contribution1 = $this->callAPISuccess('contribution', 'create', $p1);
$p2 = array(
'contact_id' => $this->_individualId,
'receive_date' => date('Ymd'),
'total_amount' => 200.00,
- 'financial_type_id' => $this->_contributionTypeId,
+ 'financial_type_id' => $this->_financialTypeId,
'non_deductible_amount' => 20.00,
'trxn_id' => 5454565,
'invoice_id' => 1212124,
'fee_amount' => 50.00,
'net_amount' => 60.00,
'contribution_status_id' => 2,
- 'version' => $this->_apiversion,
+
);
$contribution2 = $this->callAPISuccess('contribution', 'create', $p2);
$params = array(
'contribution_id' => $contribution2['id'],
- 'version' => $this->_apiversion,
+
);
$result = $this->callAPISuccess('contribution', 'get', $params);
$res = $result['values'][$contribution2['id']];
$mut = new CiviMailUtils( $this, true );
$contribution = $this->callAPISuccess('contribution','create',$this->_params);
$apiResult = $this->callAPISuccess('contribution', 'sendconfirmation', array(
- 'version' => $this->_apiversion,
+
'id' => $contribution['id'],
'receipt_from_email' => 'api@civicrm.org',
)
// to ensure it matches later on
'register_date' => '2007-07-21 00:00:00',
'source' => 'Online Event Registration: API Testing',
- 'version' => $this->_apiversion,
+
);
$participant = $this->callAPISuccess('participant', 'create', $participantParams);
$this->callAPISuccess('participant_payment', 'create', array(
- 'version' => 3,
'participant_id' => $participant['id'],
'contribution_id' => $contribution['id'],
));
$apiResult = $this->callAPISuccess('contribution', 'sendconfirmation', array(
- 'version' => $this->_apiversion,
+
'id' => $contribution['id'],
'receipt_from_email' => 'api@civicrm.org',
)
*/
function contributionGetnCheck($params, $id, $delete = 1) {
- $contribution = civicrm_api('Contribution', 'Get', array(
+ $contribution = $this->callAPISuccess('Contribution', 'Get', array(
'id' => $id,
- 'version' => $this->_apiversion,
+
));
if ($delete) {
- civicrm_api('contribution', 'delete', array(
- 'id' => $id,
- 'version' => $this->_apiversion,
- ));
+ $this->callAPISuccess('contribution', 'delete', array('id' => $id));
}
- $this->assertAPISuccess($contribution, 0, 'In line ' . __LINE__);
$values = $contribution['values'][$contribution['id']];
$params['receive_date'] = date('Y-m-d H:i:s', strtotime($params['receive_date']));
// this is not returned in id format
$params['contribution_source'] = $params['source'];
unset($params['source']);
foreach ($params as $key => $value) {
- if ($key == 'version') {
- continue;
- }
$this->assertEquals($value, $values[$key], $key . " value: $value doesn't match " . print_r($values, TRUE) . 'in line' . __LINE__);
}
}
'value' => '6',
'weight' => '6',
'is_active' => 1,
- 'version' => 3,
);
- $optionValue = civicrm_api('option_value', 'create', $optionParams);
+ $optionValue = $this->callAPISuccess('option_value', 'create', $optionParams);
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
$financialParams = array(
'entity_table' => 'civicrm_option_value',