<?php
-
/*
+--------------------------------------------------------------------+
-| CiviCRM version 4.5 |
+| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
$this->_orgId = $this->organizationCreate(NULL);
$this->params = array(
- 'title' => "Test Contribution Page".substr(sha1(rand()), 0, 7),
+ 'title' => "Test Contribution Page" . substr(sha1(rand()), 0, 7),
'financial_type_id' => 1,
'payment_processor' => 1,
'currency' => 'NZD',
'pay_later_text' => 'I will pay later',
'pay_later_receipt' => "I will pay later",
'is_monetary' => TRUE,
- 'is_billing_required' => True
+ 'is_billing_required' => TRUE,
);
$this->_priceSetParams = array(
- 'name' => 'tax_contribution'.substr(sha1(rand()), 0, 7),
- 'title' => 'contributiontax'.substr(sha1(rand()), 0, 7),
+ 'name' => 'tax_contribution' . substr(sha1(rand()), 0, 7),
+ 'title' => 'contributiontax' . substr(sha1(rand()), 0, 7),
'is_active' => 1,
'help_pre' => "Where does your goat sleep",
'help_post' => "thank you for your time",
'extends' => 2,
'financial_type_id' => 3,
'is_quick_config' => 0,
- 'is_reserved' => 0
+ 'is_reserved' => 0,
);
- // Financial Account with 20% tax rate
+ // Financial Account with 20% tax rate
$financialAccountSetparams = array(
#[domain_id] =>
- 'name' => 'vat full taxrate account'.substr(sha1(rand()), 0, 7),
+ 'name' => 'vat full taxrate account' . substr(sha1(rand()), 0, 7),
'contact_id' => $this->_orgId,
'financial_account_type_id' => 2,
'is_tax' => 1,
// Financial type having 'Sales Tax Account is' with liability financail account
$financialType = array(
- 'name' => 'grassvariety1'.substr(sha1(rand()), 0, 7),
+ 'name' => 'grassvariety1' . substr(sha1(rand()), 0, 7),
'is_reserved' => 0,
'is_active' => 1,
);
- $priceField = $this->callAPISuccess('financial_type','create', $financialType);
+ $priceField = $this->callAPISuccess('financial_type', 'create', $financialType);
$this->financialtypeID = $priceField['id'];
$financialRelationParams = array(
'entity_table' => 'civicrm_financial_type',
'entity_id' => $this->financialtypeID,
'account_relationship' => 10,
- 'financial_account_id' => $this->financialAccountId
+ 'financial_account_id' => $this->financialAccountId,
);
$financialRelation = CRM_Financial_BAO_FinancialTypeAccount::add($financialRelationParams);
// Financial type with 5% tax rate
$financialAccHalftax = array(
- 'name' => 'vat half taxrate account'.substr(sha1(rand()), 0, 7),
+ 'name' => 'vat half taxrate account' . substr(sha1(rand()), 0, 7),
'contact_id' => $this->_orgId,
'financial_account_type_id' => 2,
'is_tax' => 1,
'tax_rate' => 5.00,
'is_reserved' => 0,
'is_active' => 1,
- 'is_default' => 0
+ 'is_default' => 0,
);
$halfFinancialAccount = CRM_Financial_BAO_FinancialAccount::add($financialAccHalftax);
$this->halfFinancialAccId = $halfFinancialAccount->id;
$halfFinancialtypeHalftax = array(
- 'name' => 'grassvariety2'.substr(sha1(rand()), 0, 7),
+ 'name' => 'grassvariety2' . substr(sha1(rand()), 0, 7),
'is_reserved' => 0,
'is_active' => 1,
);
$halfFinancialType = CRM_Financial_BAO_FinancialType::add($halfFinancialtypeHalftax);
- $this->halfFinancialTypeId = $halfFinancialType->id ;
+ $this->halfFinancialTypeId = $halfFinancialType->id;
$financialRelationHalftax = array(
'entity_table' => 'civicrm_financial_type',
'entity_id' => $this->halfFinancialTypeId,
'account_relationship' => 10,
- 'financial_account_id' => $this->halfFinancialAccId
+ 'financial_account_id' => $this->halfFinancialAccId,
);
$halfFinancialRelation = CRM_Financial_BAO_FinancialTypeAccount::add($financialRelationHalftax);
// Enable component contribute setting
- $contributeSetting = array (
+ $contributeSetting = array(
'invoicing' => 1,
'invoice_prefix' => 'INV_',
'credit_notes_prefix' => 'CN_',
// Payment Processor
$paymentProceParams = array(
'domain_id' => 1,
- 'name' => 'dummy'.substr(sha1(rand()), 0, 7),
+ 'name' => 'dummy' . substr(sha1(rand()), 0, 7),
'payment_processor_type_id' => 10,
'financial_account_id' => 12,
'is_active' => 1,
'is_default' => 1,
- 'is_default' => 1,
'user_name' => 'dummy',
'url_site' => 'http://dummy.com',
'url_recur' => 'http://dummyrecur.com',
'class_name' => 'Payment_Dummy',
'billing_mode' => 1,
'is_recur' => 1,
- 'payment_type' => 1
+ 'payment_type' => 1,
);
$result = $this->callAPISuccess('payment_processor', 'create', $paymentProceParams);
$this->_ids['paymentProcessID'] = $result['id'];
$this->assertAPISuccess($result);
}
- function tearDown() {
+ public function tearDown() {
$this->quickCleanup(array(
'civicrm_contribution',
'civicrm_contribution_soft',
'civicrm_contact',
'civicrm_membership',
'civicrm_membership_payment',
- 'civicrm_payment_processor'
+ 'civicrm_payment_processor',
));
CRM_Core_PseudoConstant::flush('taxRates');
}
- function setUpContributionPage() {
+ public function setUpContributionPage() {
$contributionPageResult = $this->callAPISuccess($this->_entity, 'create', $this->params);
if (empty($this->_ids['price_set'])) {
$priceSet = $this->callAPISuccess('price_set', 'create', $this->_priceSetParams);
$this->_ids['price_set'][] = $priceSet['id'];
}
$priceSetID = $this->_price = reset($this->_ids['price_set']);
- CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $contributionPageResult['id'], $priceSetID );
+ CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $contributionPageResult['id'], $priceSetID);
if (empty($this->_ids['price_field'])) {
$priceField = $this->callAPISuccess('price_field', 'create', array(
'price_field_id' => $priceField['id'],
'label' => 'Long Haired Goat',
'amount' => 100,
- 'financial_type_id' => $this->financialtypeID
+ 'financial_type_id' => $this->financialtypeID,
));
$priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array(
'price_set_id' => $priceSetID,
'price_field_id' => $priceField['id'],
'label' => 'Shoe-eating Goat',
'amount' => 300,
- 'financial_type_id' => $this->halfFinancialTypeId
+ 'financial_type_id' => $this->halfFinancialTypeId,
));
$this->_ids['price_field_value'] = array($priceFieldValue['id']);
}
/**
* Online and offline contrbution from above created contrbution page
*/
- function testCreateContributionOnline() {
+ public function testCreateContributionOnline() {
$this->setUpContributionPage();
$params = array(
'contact_id' => $this->_individualId,
'trxn_id' => 12345,
'invoice_id' => 67890,
'source' => 'SSF',
- 'contribution_status_id' => 1
+ 'contribution_status_id' => 1,
);
$contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__);
$this->_ids['contributionId'] = $contribution['id'];
$this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 120.00, 'In line ' . __LINE__);
- $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'],$this->financialtypeID, 'In line ' . __LINE__ );
+ $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], $this->financialtypeID, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['trxn_id'], 12345, '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->_checkFinancialRecords($contribution, 'online');
}
- function testCreateContributionChainedLineItems() {
+ public function testCreateContributionChainedLineItems() {
$this->setUpContributionPage();
$params = array(
'contact_id' => $this->_individualId,
$description = "Create Contribution with Nested Line Items";
$subfile = "CreateWithNestedLineItems";
- $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__,__FILE__, $description, $subfile);
+ $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
- $lineItems = $this->callAPISuccess('line_item','get',array(
+ $lineItems = $this->callAPISuccess('line_item', 'get', array(
'entity_id' => $contribution['id'],
'contribution_id' => $contribution['id'],
'entity_table' => 'civicrm_contribution',
$this->assertEquals(2, $lineItems['count']);
}
- function testCreateContributionPayLaterOnline() {
+ public function testCreateContributionPayLaterOnline() {
$this->setUpContributionPage();
$params = array(
'contact_id' => $this->_individualId,
$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'], 120.00, 'In line ' . __LINE__);
- $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'],$this->financialtypeID, 'In line ' . __LINE__ );
+ $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], $this->financialtypeID, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['trxn_id'], 12345, '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'], 2, 'In line ' . __LINE__);
$this->_checkFinancialRecords($contribution, 'payLater');
}
- function testCreateContributionPendingOnline() {
+
+ public function testCreateContributionPendingOnline() {
$this->setUpContributionPage();
$params = array(
'contact_id' => $this->_individualId,
$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'], 120.00, 'In line ' . __LINE__);
- $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'],$this->financialtypeID, 'In line ' . __LINE__ );
+ $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], $this->financialtypeID, 'In line ' . __LINE__);
$this->assertEquals($contribution['values'][$contribution['id']]['trxn_id'], 12345, '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__);
* Updation of contrbution
* Function tests that line items, financial records are updated when contribution amount is changed
*/
- function testCreateUpdateContributionChangeTotal() {
+ public function testCreateUpdateContributionChangeTotal() {
$this->setUpContributionPage();
$this->contributionParams = array(
'contact_id' => $this->_individualId,
'receive_date' => '20120511',
'total_amount' => 100.00,
- 'financial_type_id' => $this->financialtypeID,
+ 'financial_type_id' => $this->financialtypeID,
'source' => 'SSF',
'contribution_status_id' => 1,
);
$contribution = $this->callAPISuccess('contribution', 'create', $this->contributionParams);
- $lineItems = $this->callAPISuccess('line_item','getvalue', array(
+ $lineItems = $this->callAPISuccess('line_item', 'getvalue', array(
'entity_id' => $contribution['id'],
'entity_table' => 'civicrm_contribution',
'sequential' => 1,
$this->assertEquals('120.00', $trxnAmount);
$newParams = array(
'id' => $contribution['id'],
- 'financial_type_id' => 1, // without tax rate i.e Donation
- 'total_amount' => '300'
+ 'financial_type_id' => 1, // without tax rate i.e Donation
+ 'total_amount' => '300',
);
$contribution = $this->callAPISuccess('contribution', 'update', $newParams);
- $lineItems = $this->callAPISuccess('line_item','getvalue',array(
+ $lineItems = $this->callAPISuccess('line_item', 'getvalue', array(
'entity_id' => $contribution['id'],
'entity_table' => 'civicrm_contribution',
'sequential' => 1,
*
* @return null|string
*/
- function _getFinancialTrxnAmount($contId) {
+ public function _getFinancialTrxnAmount($contId) {
$query = "SELECT
SUM( ft.total_amount ) AS total
FROM civicrm_financial_trxn AS ft
*
* @return null|string
*/
- function _getFinancialItemAmount($contId) {
+ public function _getFinancialItemAmount($contId) {
$lineItem = key(CRM_Price_BAO_LineItem::getLineItems($contId, 'contribution'));
$query = "SELECT
SUM(amount)
* @param array $params
* @param $context
*/
- function _checkFinancialRecords($params, $context) {
+ public function _checkFinancialRecords($params, $context) {
$entityParams = array(
'entity_id' => $params['id'],
'entity_table' => 'civicrm_contribution',
}
/**
- * @param array $params
* @param int $financialTypeId
+ * @return int
*/
- function _getFinancialAccountId($financialTypeId) {
+ public function _getFinancialAccountId($financialTypeId) {
$accountRel = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
$searchParams = array(
- 'entity_table' => 'civicrm_financial_type',
- 'entity_id' => $financialTypeId,
+ 'entity_table' => 'civicrm_financial_type',
+ 'entity_id' => $financialTypeId,
'account_relationship' => $accountRel,
);
$result = array();
- CRM_Financial_BAO_FinancialTypeAccount::retrieve( $searchParams, $result );
- return CRM_Utils_Array::value( 'financial_account_id', $result );
+ CRM_Financial_BAO_FinancialTypeAccount::retrieve($searchParams, $result);
+ return CRM_Utils_Array::value('financial_account_id', $result);
}
- ///////////////// civicrm_contribution_delete methods
- function testDeleteContribution() {
+ /**
+ *
+ */
+ public function testDeleteContribution() {
$contributionID = $this->contributionCreate($this->_individualId, $this->financialtypeID, 'dfsdf', 12389);
$params = array(
'id' => $contributionID,