From a380f4a00f7c7576a9475b0966012fc7cc199805 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 24 Jun 2015 19:06:10 +1200 Subject: [PATCH] test & comment fixes --- CRM/Contribute/BAO/Contribution.php | 11 +++-------- CRM/Contribute/Form/Contribution.php | 1 - tests/phpunit/CiviTest/CiviUnitTestCase.php | 3 +++ tests/phpunit/api/v3/ContributionPageTest.php | 19 +++++++++++++------ tests/phpunit/api/v3/ContributionTest.php | 1 - 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 0d2b995222..aaa4055afa 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -29,8 +29,6 @@ * * @package CRM * @copyright CiviCRM LLC (c) 2004-2015 - * $Id$ - * */ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution { @@ -228,7 +226,8 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution { * @param array $ids * The array that holds all the db ids. * - * @return CRM_Contribute_BAO_Contribution|null the found object or null + * @return CRM_Contribute_BAO_Contribution|null + * The found object or null */ public static function &getValues($params, &$values, &$ids) { if (empty($params)) { @@ -495,8 +494,6 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution { * (reference) the default values, some of which need to be resolved. * @param bool $reverse * True if we want to resolve the values in the reverse direction (value -> name). - * - * @return void */ public static function resolveDefaults(&$defaults, $reverse = FALSE) { self::lookupValue($defaults, 'financial_type', CRM_Contribute_PseudoConstant::financialType(), $reverse); @@ -1047,7 +1044,6 @@ GROUP BY p.id * * @return array * list of contribution fields - * */ public static function getHonorContacts($honorId) { $params = array(); @@ -1178,6 +1174,7 @@ WHERE civicrm_contribution.contact_id = civicrm_contact.id /** * Check if there is a contribution with the params passed in. + * * Used for trxn_id,invoice_id and contribution_id * * @param array $params @@ -1217,7 +1214,6 @@ WHERE civicrm_contribution.contact_id = civicrm_contact.id * * @return array * associated array - * */ public static function getContributionDetails($exportMode, $componentIds) { $paymentDetails = array(); @@ -1314,7 +1310,6 @@ LEFT JOIN civicrm_option_value contribution_status ON (civicrm_contribution.cont * * @param int $contributionId * @param int $contactId - * */ public static function deleteAddress($contributionId = NULL, $contactId = NULL) { $clauses = array(); diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 44d5ab9241..6bcb35fa5b 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -180,7 +180,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP */ public $_priceSetId; - /** * Price set as an array * @var array diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index f89e218e32..f3769dc96f 100755 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -2529,6 +2529,8 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) */ public function quickCleanUpFinancialEntities() { $tablesToTruncate = array( + 'civicrm_activity', + 'civicrm_activity_contact', 'civicrm_contribution', 'civicrm_contribution_soft', 'civicrm_contribution_product', @@ -2561,6 +2563,7 @@ AND ( TABLE_NAME LIKE 'civicrm_value_%' ) } public function restoreDefaultPriceSetConfig() { + CRM_Core_DAO::executeQuery('DELETE FROM civicrm_price_set WHERE id > 2'); CRM_Core_DAO::executeQuery("INSERT INTO `civicrm_price_field` (`id`, `price_set_id`, `name`, `label`, `html_type`, `is_enter_qty`, `help_pre`, `help_post`, `weight`, `is_display_amounts`, `options_per_line`, `is_active`, `is_required`, `active_on`, `expire_on`, `javascript`, `visibility_id`) VALUES (1, 1, 'contribution_amount', 'Contribution Amount', 'Text', 0, NULL, NULL, 1, 1, 1, 1, 1, NULL, NULL, NULL, 1)"); CRM_Core_DAO::executeQuery("INSERT INTO `civicrm_price_field_value` (`id`, `price_field_id`, `name`, `label`, `description`, `amount`, `count`, `max_value`, `weight`, `membership_type_id`, `membership_num_terms`, `is_default`, `is_active`, `financial_type_id`, `deductible_amount`) VALUES (1, 1, 'contribution_amount', 'Contribution Amount', NULL, '1', NULL, NULL, 1, NULL, NULL, 0, 1, 1, 0.00)"); } diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index 685364420b..d15ca4f53f 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -400,12 +400,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { */ public function setUpMembershipContributionPage($isSeparatePayment = FALSE) { $this->setUpMembershipBlockPriceSet(); - $this->params['payment_processor_id'] = $this->_ids['payment_processor'] = $this->paymentProcessorCreate(array( - 'payment_processor_type_id' => 'Dummy', - 'class_name' => 'Payment_Dummy', - 'billing_mode' => 1, - )); - $this->_paymentProcessor = $this->callAPISuccess('payment_processor', 'getsingle', array('id' => $this->params['payment_processor_id'])); + $this->setupPaymentProcessor(); $this->setUpContributionPage(); $this->callAPISuccess('membership_block', 'create', array( @@ -507,4 +502,16 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $unitTest->quickCleanup($tablesToTruncate); } + /** + * Create a payment processor instance. + */ + protected function setupPaymentProcessor() { + $this->params['payment_processor_id'] = $this->_ids['payment_processor'] = $this->paymentProcessorCreate(array( + 'payment_processor_type_id' => 'Dummy', + 'class_name' => 'Payment_Dummy', + 'billing_mode' => 1, + )); + $this->_paymentProcessor = $this->callAPISuccess('payment_processor', 'getsingle', array('id' => $this->params['payment_processor_id'])); + } + } diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 3d75bae1f4..37d2f9d92f 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -1556,7 +1556,6 @@ class api_v3_ContributionTest extends CiviUnitTestCase { public function cleanUpAfterPriceSets() { $this->quickCleanUpFinancialEntities(); $this->contactDelete($this->_ids['contact']); - $this->callAPISuccess('price_set', 'delete', array('id' => $this->_ids['price_set'])); } -- 2.25.1