From 5e4f7f7473c2f23f2bc2197a9808e3fe138f91ed Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 3 Feb 2015 12:11:51 +1300 Subject: [PATCH] More comment fixes --- CRM/Contribute/Form/Contribution/Confirm.php | 44 +++++++++++++------- api/v3/Membership.php | 11 +++-- tests/phpunit/api/v3/LocBlockTest.php | 35 +++++++++------- 3 files changed, 56 insertions(+), 34 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 2fc620b187..20812df92b 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -661,9 +661,10 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } /** - * Set default values for the form. Note that in edit/view mode - * the default values are retrieved from the database + * Set default values for the form. * + * Note that in edit/view mode + * the default values are retrieved from the database * * @return void */ @@ -1058,10 +1059,13 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } /** + * Wrangle financial type ID. + * * This wrangling of the financialType ID was happening in a shared function rather than in the form it relates to & hence has been moved to that form * Pledges are not relevant to the membership code so that portion will not go onto the membership form. * - * Comments from previous refactor indicate doubt as to what was going on + * Comments from previous refactor indicate doubt as to what was going on. + * * @param int $contributionTypeId * * @return null|string @@ -1080,12 +1084,10 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } /** - * Process the form + * Process the form. * * @param array $premiumParams * @param $contribution - * - * @return void */ public function postProcessPremium($premiumParams, $contribution) { $hour = $minute = $second = 0; @@ -1204,7 +1206,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } /** - * Process the contribution + * Process the contribution. * * @param CRM_Core_Form $form * @param array $params @@ -1773,7 +1775,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr * @param object $contributionSoft * Contribution object. */ - public static function pcpNotifyOwner($contribution, $contributionSoft) { $params = array('id' => $contributionSoft->pcp_id); CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo); @@ -1825,8 +1826,9 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } /** - * Function used to se pcp related defaults / params - * This is used by contribution and also event pcps + * Function used to se pcp related defaults / params. + * + * This is used by contribution and also event PCPs * * @param CRM_Core_Form $page * Form object. @@ -1859,6 +1861,8 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } /** + * Process membership. + * * @param array $membershipParams * @param int $contactID * @param array $customFieldsFormatted @@ -1906,10 +1910,11 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } /** - * Are we going to do 2 financial transactions? - * ie the membership block supports a separate transactions AND the contribution form has been configured for a contribution - * transaction AND a membership transaction AND the payment processor supports double financial transactions (ie. NOT doTransferPayment style) + * Are we going to do 2 financial transactions. * + * Ie the membership block supports a separate transactions AND the contribution form has been configured for a + * contribution + * transaction AND a membership transaction AND the payment processor supports double financial transactions (ie. NOT doTransferPayment style) * * @param int $formID * @param bool $amountBlockActiveOnForm @@ -1925,7 +1930,8 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } /** - * This function sets the fields + * This function sets the fields. + * * - $this->_params['amount_level'] * - $this->_params['selectMembership'] * And under certain circumstances sets @@ -1954,7 +1960,9 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $this->_params['selectMembership'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $this->_params["price_{$priceField->id}"], 'membership_type_id'); } - } // if separate payment we set contribution amount to be null, so that it will not show contribution amount same as membership amount. + } + // If separate payment we set contribution amount to be null, so that it will not show contribution amount same + // as membership amount. // @todo - this needs more documentation - it appears the setting to null is tied up with separate membership payments // but the circumstances are very confusing. Many of these conditions are repeated in the next conditional // so we should merge them together @@ -1986,6 +1994,8 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } /** + * Submit function. + * * @param array $params * * @throws CiviCRM_API3_Exception @@ -2029,7 +2039,9 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } /** - * Helper function for static submit function - set relevant params - help us to build up an array that we can pass in + * Helper function for static submit function - set relevant params - help us to build up an array that we can pass + * in. + * * @param int $id * @param array $params * diff --git a/api/v3/Membership.php b/api/v3/Membership.php index 7abd85e6ad..9e99405acd 100644 --- a/api/v3/Membership.php +++ b/api/v3/Membership.php @@ -64,8 +64,8 @@ function civicrm_api3_membership_delete($params) { function civicrm_api3_membership_create($params) { // check params for membership id during update if (!empty($params['id']) && !isset($params['skipStatusCal'])) { - //don't calculate status on exisiting membership - expect API use to pass them in - // or leave unchanged + // Don't calculate status on existing membership - expect API use to pass them in + // or leave unchanged. $params['skipStatusCal'] = 1; } else { @@ -161,6 +161,7 @@ function _civicrm_api3_membership_create_spec(&$params) { 'type' => CRM_Utils_Type::T_INT, ); } + /** * Adjust Metadata for Get action. * @@ -171,6 +172,10 @@ function _civicrm_api3_membership_create_spec(&$params) { */ function _civicrm_api3_membership_get_spec(&$params) { $params['membership_type_id']['api.aliases'] = array('membership_type'); + $params['active_only'] = array( + 'title' => 'Only retrieve active memberships', + 'type' => CRM_Utils_Type::T_BOOLEAN, + ); } /** @@ -284,7 +289,7 @@ function _civicrm_api3_membership_relationsship_get_customv2behaviour(&$params, $members = $membershipValues; - // populating contacts in members array based on their relationship with direct members. + // Populating contacts in members array based on their relationship with direct members. if (!empty($relationships)) { foreach ($relationships as $relTypeId => $membershipId) { // As members are not direct members, there should not be diff --git a/tests/phpunit/api/v3/LocBlockTest.php b/tests/phpunit/api/v3/LocBlockTest.php index e4be275731..3d83a910a1 100644 --- a/tests/phpunit/api/v3/LocBlockTest.php +++ b/tests/phpunit/api/v3/LocBlockTest.php @@ -39,10 +39,12 @@ class api_v3_LocBlockTest extends CiviUnitTestCase { $this->useTransaction(TRUE); } + /** + * Test creating location block. + */ public function testCreateLocBlock() { $email = $this->callAPISuccess('email', 'create', array( 'contact_id' => 'null', - 'location_type_id' => 1, 'email' => 'test@loc.block', )); $phone = $this->callAPISuccess('phone', 'create', array( @@ -63,11 +65,14 @@ class api_v3_LocBlockTest extends CiviUnitTestCase { $description = 'Create locBlock with existing entities'; $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, 'simpleCreate'); $id = $result['id']; - $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); - $this->assertNotNull($result['values'][$id]['id'], 'In line ' . __LINE__); + $this->assertEquals(1, $result['count']); + $this->assertNotNull($result['values'][$id]['id']); $this->getAndCheck($params, $id, $this->_entity); } + /** + * Test creating location block entities. + */ public function testCreateLocBlockEntities() { $params = array( 'email' => array( @@ -90,25 +95,25 @@ class api_v3_LocBlockTest extends CiviUnitTestCase { $description = "Create entities and locBlock in 1 api call"; $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, 'createEntities'); $id = $result['id']; - $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); + $this->assertEquals(1, $result['count']); - // Now check our results using the return param 'all' + // Now check our results using the return param 'all'. $getParams = array( 'id' => $id, 'return' => 'all', ); - // Can't use callAPISuccess with getsingle + // Can't use callAPISuccess with getsingle. $result = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__, 'Get entities and location block in 1 api call', 'getEntities', 'get'); $result = array_pop($result['values']); - $this->assertNotNull($result['email_id'], 'In line ' . __LINE__); - $this->assertNotNull($result['phone_id'], 'In line ' . __LINE__); - $this->assertNotNull($result['phone_2_id'], 'In line ' . __LINE__); - $this->assertNotNull($result['address_id'], 'In line ' . __LINE__); - $this->assertEquals($params['email']['email'], $result['email']['email'], 'In line ' . __LINE__); - $this->assertEquals($params['phone_2']['phone'], $result['phone_2']['phone'], 'In line ' . __LINE__); - $this->assertEquals($params['address']['street_address'], $result['address']['street_address'], 'In line ' . __LINE__); - // Delete block - $result = $this->callAPISuccess($this->_entity, 'delete', array('id' => $id)); + $this->assertNotNull($result['email_id']); + $this->assertNotNull($result['phone_id']); + $this->assertNotNull($result['phone_2_id']); + $this->assertNotNull($result['address_id']); + $this->assertEquals($params['email']['email'], $result['email']['email']); + $this->assertEquals($params['phone_2']['phone'], $result['phone_2']['phone']); + $this->assertEquals($params['address']['street_address'], $result['address']['street_address']); + + $this->callAPISuccess($this->_entity, 'delete', array('id' => $id)); } } -- 2.25.1