Skip to content

Commit

Permalink
Preliminary cleanup - use CRM_Core_Exception, fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Aug 4, 2019
1 parent 38d6407 commit 3aee717
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 6 deletions.
5 changes: 3 additions & 2 deletions CRM/Core/BAO/UFGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ public static function getListingFields(
*
* @return array
* The fields that belong to this ufgroup(s)
* @throws \Exception
*
* @throws \CRM_Core_Exception
*/
public static function getFields(
$id,
Expand Down Expand Up @@ -360,7 +361,7 @@ public static function getFields(
}

if (empty($fields) && !$validGroup) {
CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) is disabled OR it is not configured to be used for \'Profile\' listings in its Settings OR there is no Profile with that ID OR you do not have permission to access this profile. Please contact the site administrator if you need assistance.',
throw new CRM_Core_Exception(ts('The requested Profile (gid=%1) is disabled OR it is not configured to be used for \'Profile\' listings in its Settings OR there is no Profile with that ID OR you do not have permission to access this profile. Please contact the site administrator if you need assistance.',
array(1 => implode(',', $profileIds))
));
}
Expand Down
4 changes: 4 additions & 0 deletions CRM/Event/BAO/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,10 @@ public static function buildCustomDisplay(
* Formatted array of key value.
*
* @param array $profileFields
*
* @throws \CRM_Core_Exception
* @throws \API_Exception
* @throws \CiviCRM_API3_Exception
*/
public static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$profileFields = []) {
if ($gid) {
Expand Down
10 changes: 6 additions & 4 deletions CRM/Event/Form/Registration/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -1218,11 +1218,13 @@ public static function updateContactFields($contactID, $params, $fields, &$form)
}

/**
* Assign Profiles.
* Assign Profiles to the template.
*
* @param CRM_Core_Form $form
* @param CRM_Event_Form_Registration_Confirm $form
*
* @throws \Exception
*/
public static function assignProfiles(&$form) {
public static function assignProfiles($form) {
$participantParams = $form->_params;
$formattedValues = $profileFields = [];
$count = 1;
Expand All @@ -1235,7 +1237,7 @@ public static function assignProfiles(&$form) {
$prefix1 = '';
$prefix2 = '';
}
if ($participantValue != 'skip') {
if ($participantValue !== 'skip') {
//get the customPre profile info
if (!empty($form->_values[$prefix2 . 'custom_pre_id'])) {
$values = $groupName = [];
Expand Down
1 change: 1 addition & 0 deletions api/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function civicrm_api($entity, $action, $params, $extra = NULL) {
* Array to be passed to function.
*
* @throws CiviCRM_API3_Exception
*
* @return array
*/
function civicrm_api3($entity, $action, $params = []) {
Expand Down
64 changes: 64 additions & 0 deletions tests/phpunit/CRMTraits/Profile/ProfileTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
* Trait PriceSetTrait
*
* Trait for working with Price Sets in tests
*/
trait CRMTraits_Financial_PriceSetTrait {

/**
* Create a contribution with 2 line items.
*
* This also involves creating t
*
* @param $params
* @param array $lineItemFinancialTypes
* Financial Types, if an override is intended.
*/
protected function createContributionWithTwoLineItemsAgainstPriceSet($params, $lineItemFinancialTypes = []) {
$params = array_merge(['total_amount' => 300, 'financial_type_id' => 'Donation'], $params);
$priceFields = $this->createPriceSet('contribution');
foreach ($priceFields['values'] as $key => $priceField) {
$financialTypeID = (!empty($lineItemFinancialTypes) ? array_shift($lineItemFinancialTypes) : $priceField['financial_type_id']);
$params['line_items'][]['line_item'][$key] = [
'price_field_id' => $priceField['price_field_id'],
'price_field_value_id' => $priceField['id'],
'label' => $priceField['label'],
'field_title' => $priceField['label'],
'qty' => 1,
'unit_price' => $priceField['amount'],
'line_total' => $priceField['amount'],
'financial_type_id' => $financialTypeID,
'entity_table' => 'civicrm_contribution',
];
}
$this->callAPISuccess('order', 'create', $params);
}

}

0 comments on commit 3aee717

Please sign in to comment.