From: Eileen McNaughton Date: Wed, 13 May 2015 05:51:41 +0000 (+1200) Subject: (backoffice Membership form) minor variable removal and fix to capitalisation on X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=41709813a0a8cffc9e879bc6da5fd3eac08aac89;p=civicrm-core.git (backoffice Membership form) minor variable removal and fix to capitalisation on phpcs fixes --- diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index de53af41c7..e29407f1d0 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1027,7 +1027,7 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; // get the submitted form values. $this->_params = $this->controller->exportValues($this->_name); - $createdMemberships = $this->submit($this->_params); + $this->submit($this->_params); $this->setUserContext(); } @@ -1211,9 +1211,9 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; $joinDate = $startDate = $endDate = NULL; $membershipTypes = $membership = $calcDate = array(); - $memType = $membershipType = NULL; + $membershipType = NULL; - $receiptSend = $mailSend = FALSE; + $mailSend = FALSE; $priceSetID = CRM_Utils_Array::value('price_set_id', $formValues); $params = $softParams = $ids = array(); @@ -1287,8 +1287,8 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; } $params['total_amount'] = CRM_Utils_Array::value('amount', $this->_params); $submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $formValues); - if (!empty($lineItem[$priceSetId])) { - foreach ($lineItem[$priceSetId] as &$li) { + if (!empty($lineItem[$priceSetID])) { + foreach ($lineItem[$priceSetID] as &$li) { if (!empty($li['membership_type_id'])) { if (!empty($li['membership_num_terms'])) { $termsByType[$li['membership_type_id']] = $li['membership_num_terms']; @@ -1378,17 +1378,6 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; // membership type custom data foreach ($this->_memTypeSelected as $memType) { - $customFields = CRM_Core_BAO_CustomField::getFields('Membership', FALSE, FALSE, - $memType - ); - - $customFields = CRM_Utils_Array::crmArrayMerge($customFields, - CRM_Core_BAO_CustomField::getFields('Membership', - FALSE, FALSE, - NULL, NULL, TRUE - ) - ); - $membershipTypeValues[$memType]['custom'] = CRM_Core_BAO_CustomField::postProcess($formValues, $this->_id, 'Membership' @@ -1468,7 +1457,7 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; } $createdMemberships = array(); if ($this->_mode) { - if (empty($formValues['total_amount']) && !$priceSetId) { + if (empty($formValues['total_amount']) && !$priceSetID) { // if total amount not provided minimum for membership type is used $params['total_amount'] = $formValues['total_amount'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $formValues['membership_type_id'][1], 'minimum_fee' @@ -1478,9 +1467,9 @@ WHERE id IN ( ' . implode(' , ', array_keys($membershipType)) . ' )'; $params['total_amount'] = CRM_Utils_Array::value('total_amount', $formValues, 0); } - if ($priceSetId && !$isQuickConfig) { + if ($priceSetID && !$isQuickConfig) { $params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', - $priceSetId, + $priceSetID, 'financial_type_id' ); } diff --git a/tests/phpunit/CRM/Member/Form/MembershipTest.php b/tests/phpunit/CRM/Member/Form/MembershipTest.php index f99ac7c751..f38e4e80cd 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipTest.php @@ -31,7 +31,6 @@ * (PHP 5) * * @author Walt Haas (801) 534-1262 - * */ /** @@ -82,19 +81,18 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { protected $paymentInstruments = array(); /** - * Test setup for every test. + * Test setup for every test. * - * Connect to the database, truncate the tables that will be used - * and redirect stdin to a temporary file + * Connect to the database, truncate the tables that will be used + * and redirect stdin to a temporary file. */ public function setUp() { $this->_apiversion = 3; - // Connect to the database parent::setUp(); $this->_individualId = $this->individualCreate(); $this->_paymentProcessorID = $this->processorCreate(); - // Insert test data + // Insert test data. $op = new PHPUnit_Extensions_Database_Operation_Insert(); $op->execute($this->_dbconn, $this->createFlatXMLDataSet( @@ -207,9 +205,7 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { } /** - * Test CRM_Member_Form_Membership::formRule() with a parameter - * that has an end date but no start date and a rolling - * membership type + * Test CRM_Member_Form_Membership::formRule() with end date but no start date and a rolling membership type. */ public function testFormRuleRollingEndNoStart() { $unixNow = time(); @@ -261,7 +257,6 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { */ public function testFormRuleOverrideNoStatus() { $unixNow = time(); - $unixYearFromNow = $unixNow + (365 * 24 * 60 * 60); $params = array( 'join_date' => date('m/d/Y', $unixNow), 'membership_type_id' => array('23', '25'), @@ -270,12 +265,8 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { $files = array(); $obj = new CRM_Member_Form_Membership(); $rc = $obj->formRule($params, $files, $obj); - $this->assertType('array', $rc, - 'In line ' . __LINE__ - ); - $this->assertTrue(array_key_exists('status_id', $rc), - 'In line ' . __LINE__ - ); + $this->assertType('array', $rc); + $this->assertTrue(array_key_exists('status_id', $rc)); } /** @@ -295,18 +286,13 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { $obj = new CRM_Member_Form_Membership(); $rc = $obj->formRule($params, $files, $obj); - // Should have found no valid membership status - $this->assertType('array', $rc, - 'In line ' . __LINE__ - ); - $this->assertTrue(array_key_exists('_qf_default', $rc), - 'In line ' . __LINE__ - ); + // Should have found no valid membership status. + $this->assertType('array', $rc); + $this->assertTrue(array_key_exists('_qf_default', $rc)); } /** - * Test CRM_Member_Form_Membership::formRule() with a join date - * of today and a rolling membership type + * Test CRM_Member_Form_Membership::formRule() with a join date of today and a rolling membership type. */ public function testFormRuleRollingJoinToday() { $unixNow = time(); @@ -341,13 +327,12 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { $obj = new CRM_Member_Form_Membership(); $rc = $obj->formRule($params, $files, $obj); - // Should have found New membership status - $this->assertTrue($rc, 'In line ' . __LINE__); + // Should have found New membership status. + $this->assertTrue($rc); } /** - * Test CRM_Member_Form_Membership::formRule() with a join date - * of six months ago and a rolling membership type + * Test CRM_Member_Form_Membership::formRule() with a join date of six months ago and a rolling membership type. */ public function testFormRuleRollingJoin6MonthsAgo() { $unixNow = time(); @@ -362,8 +347,8 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { $obj = new CRM_Member_Form_Membership(); $rc = $obj->formRule($params, $files, $obj); - // Should have found Current membership status - $this->assertTrue($rc, 'In line ' . __LINE__); + // Should have found Current membership status. + $this->assertTrue($rc); } /** @@ -457,15 +442,15 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { 'credit_card_exp_date' => array( 'M' => '9', 'Y' => '2019', // TODO: Future proof - ), - 'credit_card_type' => 'Visa', - 'billing_first_name' => 'Test', - 'billing_middlename' => 'Last', - 'billing_street_address-5' => '10 Test St', - 'billing_city-5' => 'Test', - 'billing_state_province_id-5' => '1003', - 'billing_postal_code-5' => '90210', - 'billing_country_id-5' => '1228', + ), + 'credit_card_type' => 'Visa', + 'billing_first_name' => 'Test', + 'billing_middlename' => 'Last', + 'billing_street_address-5' => '10 Test St', + 'billing_city-5' => 'Test', + 'billing_state_province_id-5' => '1003', + 'billing_postal_code-5' => '90210', + 'billing_country_id-5' => '1228', ); $form->submit($params); // TODO: This will still fail right now.