Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(NFC) Update various files to pass current phpcs #13978

Merged
merged 5 commits into from
Apr 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions CRM/Contact/BAO/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -2398,12 +2398,12 @@ public static function formatProfileContactParams(
'prefix_id',
'suffix_id',
)) &&
($value == '' || !isset($value)) &&
($session->get('authSrc') & (CRM_Core_Permission::AUTH_SRC_CHECKSUM + CRM_Core_Permission::AUTH_SRC_LOGIN)) == 0 ||
($key == 'current_employer' && empty($params['current_employer']))) {
// CRM-10128: if auth source is not checksum / login && $value is blank, do not fill $data with empty value
// to avoid update with empty values
continue;
($value == '' || !isset($value)) &&
($session->get('authSrc') & (CRM_Core_Permission::AUTH_SRC_CHECKSUM + CRM_Core_Permission::AUTH_SRC_LOGIN)) == 0 ||
($key == 'current_employer' && empty($params['current_employer']))) {
// CRM-10128: if auth source is not checksum / login && $value is blank, do not fill $data with empty value
// to avoid update with empty values
continue;
}
else {
$data[$key] = $value;
Expand Down
5 changes: 1 addition & 4 deletions CRM/Contact/Page/View/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,7 @@ public function getTabs() {
}
elseif ($accessCiviCRM && !empty($this->_viewOptions[$tab['id']])) {
$allTabs[] = $tab + [
'url' => CRM_Utils_System::url(
"civicrm/contact/view/{$tab['id']}",
"reset=1&cid={$this->_contactId}"
),
'url' => CRM_Utils_System::url("civicrm/contact/view/{$tab['id']}", "reset=1&cid={$this->_contactId}"),
'count' => CRM_Contact_BAO_Contact::getCountComponent($tab['id'], $this->_contactId),
];
$weight = $tab['weight'] + 10;
Expand Down
26 changes: 13 additions & 13 deletions CRM/Contribute/Exception/CheckLineItemsException.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
/**
* Class CRM_Contribute_Exception_CheckLineItemsException
*/
class CRM_Contribute_Exception_CheckLineItemsException extends API_Exception {
const LINE_ITEM_DIFFERRING_TOTAL_EXCEPTON_MSG = "Line item total doesn't match with total amount.";
public function __construct($message = self::LINE_ITEM_DIFFERRING_TOTAL_EXCEPTON_MSG, $error_code = 0, array $extraParams = [], $previous = NULL) {
parent::__construct($message, $error_code, $extraParams, $previous);
}
}
<?php

/**
* Class CRM_Contribute_Exception_CheckLineItemsException
*/
class CRM_Contribute_Exception_CheckLineItemsException extends API_Exception {
const LINE_ITEM_DIFFERRING_TOTAL_EXCEPTON_MSG = "Line item total doesn't match with total amount.";

public function __construct($message = self::LINE_ITEM_DIFFERRING_TOTAL_EXCEPTON_MSG, $error_code = 0, array $extraParams = [], $previous = NULL) {
parent::__construct($message, $error_code, $extraParams, $previous);
}

}
10 changes: 5 additions & 5 deletions CRM/Core/I18n/SchemaStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
*/

/**
*
Expand All @@ -42,7 +42,7 @@ class CRM_Core_I18n_SchemaStructure {
* A table-indexed array of translatable columns.
*/
public static function &columns() {
static $result = null;
static $result = NULL;
if (!$result) {
$result = [
'civicrm_location_type' => [
Expand Down Expand Up @@ -211,7 +211,7 @@ public static function &columns() {
* Indices for translatable fields.
*/
public static function &indices() {
static $result = null;
static $result = NULL;
if (!$result) {
$result = [
'civicrm_custom_group' => [
Expand Down Expand Up @@ -255,7 +255,7 @@ public static function &indices() {
* Array of names of tables with fields that can be translated.
*/
static function &tables() {
static $result = null;
static $result = NULL;
if (!$result) {
$result = array_keys(self::columns());
}
Expand All @@ -269,7 +269,7 @@ static function &tables() {
* Array of the widgets for editing translatable fields.
*/
static function &widgets() {
static $result = null;
static $result = NULL;
if (!$result) {
$result = [
'civicrm_location_type' => [
Expand Down
3 changes: 2 additions & 1 deletion CRM/Dedupe/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ public static function removeContactBelongings($otherID, $tables) {
"return" => "id",
]
)
));
)
);

if (!empty($membershipIDs)) {
civicrm_api3("Membership", "get", [
Expand Down
1 change: 1 addition & 0 deletions Civi/Core/DAO/Event/PostDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ public function __construct($object, $result) {
$this->object = $object;
$this->result = $result;
}

}
1 change: 1 addition & 0 deletions Civi/Core/DAO/Event/PostUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ class PostUpdate extends \Symfony\Component\EventDispatcher\Event {
public function __construct($object) {
$this->object = $object;
}

}
1 change: 1 addition & 0 deletions Civi/Core/DAO/Event/PreDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ class PreDelete extends \Symfony\Component\EventDispatcher\Event {
public function __construct($object) {
$this->object = $object;
}

}
4 changes: 2 additions & 2 deletions api/v3/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,8 @@ function _ipn_process_transaction(&$params, $contribution, $input, $ids, $firstC
$input['card_type_id'] = CRM_Utils_Array::value('card_type_id', $params);
$input['pan_truncation'] = CRM_Utils_Array::value('pan_truncation', $params);
$transaction = new CRM_Core_Transaction();
return CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects, $transaction, !empty
($contribution->contribution_recur_id), $contribution);
return CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects, $transaction,
!empty($contribution->contribution_recur_id), $contribution);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion api/v3/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function civicrm_api3_domain_get($params) {
'phone',
$values['location']['phone'][1]
),
];
];
}

if (!empty($values['location']['address'])) {
Expand Down
6 changes: 1 addition & 5 deletions api/v3/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,7 @@ function _civicrm_api3_event_getlist_output($result, $request) {
'id' => $row[$request['id_field']],
'label' => $row[$request['label_field']],
'description' => [
CRM_Core_Pseudoconstant::getLabel(
'CRM_Event_BAO_Event',
'event_type_id',
$row['event_type_id']
),
CRM_Core_Pseudoconstant::getLabel('CRM_Event_BAO_Event', 'event_type_id', $row['event_type_id']),
],
];
if (!empty($row['start_date'])) {
Expand Down
6 changes: 1 addition & 5 deletions api/v3/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,7 @@ function civicrm_api3_system_get($params) {
'version' => CRM_Utils_System::version(),
'dev' => (bool) CRM_Utils_System::isDevelopment(),
'components' => array_keys(CRM_Core_Component::getEnabledComponents()),
'extensions' => preg_grep(
'/^uninstalled$/',
CRM_Extension_System::singleton()->getManager()->getStatuses(),
PREG_GREP_INVERT
),
'extensions' => preg_grep('/^uninstalled$/', CRM_Extension_System::singleton()->getManager()->getStatuses(), PREG_GREP_INVERT),
'multidomain' => CRM_Core_DAO::singleValueQuery('SELECT count(*) FROM civicrm_domain') > 1,
'settings' => _civicrm_api3_system_get_redacted_settings(),
'exampleUrl' => CRM_Utils_System::url('civicrm/example', NULL, TRUE, NULL, FALSE),
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testHook() {
/**
* Implements hook_civicrm_entityTypes().
*
* @param array $entityTypes
* @see CRM_Utils_Hook::entityTypes()
*/
public function _hook_civicrm_entityTypes(&$entityTypes) {
$entityTypes['CRM_Core_DAO_Email']['fields_callback'][] = function ($class, &$fields) {
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/CRM/Export/BAO/ExportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1724,14 +1724,14 @@ public function textExportParticipantSpecifyFieldsNoPayment() {
$selectedFields = $this->getAllSpecifiableParticipantReturnFields();
foreach ($selectedFields as $index => $field) {
if (substr($field[1], 0, 22) === 'componentPaymentField_') {
unset ($selectedFields[$index]);
unset($selectedFields[$index]);
}
}

$expected = $this->getAllSpecifiableParticipantReturnFields();
foreach ($expected as $index => $field) {
if (substr($index, 0, 22) === 'componentPaymentField_') {
unset ($expected[$index]);
unset($expected[$index]);
}
}

Expand Down
170 changes: 85 additions & 85 deletions tests/phpunit/CRM/Price/Form/FieldTest.php
Original file line number Diff line number Diff line change
@@ -1,85 +1,85 @@
<?php
class CRM_Price_Form_FieldTest extends CiviUnitTestCase {
protected $priceFieldValues;
protected $visibilityOptionsKeys;
protected $visibilityOptions;
protected $publicFieldParams;
protected $adminFieldParams;
public function setUp() {
parent::setUp();
$this->visibilityOptionsKeys = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, array(
'labelColumn' => 'name',
'flip' => TRUE,
));
$this->publicFieldParams = $this->initializeFieldParameters(array(
'label' => 'Public Price Field',
'name' => 'public_price',
'visibility_id' => $this->visibilityOptionsKeys['public'],
));
$this->adminFieldParams = $this->initializeFieldParameters(array(
'label' => 'Public Price Field',
'name' => 'public_price',
'visibility_id' => $this->visibilityOptionsKeys['admin'],
));
}
public function testPublicFieldWithOnlyAdminOptionsIsNotAllowed() {
$this->publicFieldParams['option_label'][1] = 'Admin Price';
$this->publicFieldParams['option_amount'][1] = 10;
$this->publicFieldParams['option_visibility_id'][1] = $this->visibilityOptionsKeys['admin'];
$form = new CRM_Price_Form_Field();
$form->_action = CRM_Core_Action::ADD;
$files = array();
$validationResult = $form->formRule($this->publicFieldParams, $files, $form);
$this->assertType('array', $validationResult);
$this->assertTrue(array_key_exists('visibility_id', $validationResult));
}
public function testAdminFieldDoesNotAllowPublicOptions() {
$this->adminFieldParams['option_label'][1] = 'Admin Price';
$this->adminFieldParams['option_amount'][1] = 10;
$this->adminFieldParams['option_visibility_id'][1] = $this->visibilityOptionsKeys['public'];
$form = new CRM_Price_Form_Field();
$form->_action = CRM_Core_Action::ADD;
$files = array();
$validationResult = $form->formRule($this->adminFieldParams, $files, $form);
$this->assertType('array', $validationResult);
$this->assertTrue(array_key_exists('visibility_id', $validationResult));
}
private function initializeFieldParameters($params) {
$defaultParams = array(
'label' => 'Price Field',
'name' => CRM_Utils_String::titleToVar('Price Field'),
'html_type' => 'Select',
'is_display_amounts' => 1,
'weight' => 1,
'options_per_line' => 1,
'is_enter_qty' => 1,
'financial_type_id' => $this->getFinancialTypeId('Event Fee'),
'visibility_id' => $this->visibilityOptionsKeys['public'],
);
for ($index = 1; $index <= CRM_Price_Form_Field::NUM_OPTION; $index++) {
$defaultParams['option_label'][$index] = NULL;
$defaultParams['option_value'][$index] = NULL;
$defaultParams['option_name'][$index] = NULL;
$defaultParams['option_weight'][$index] = NULL;
$defaultParams['option_amount'][$index] = NULL;
$defaultParams['option_visibility_id'][$index] = NULL;
}
return array_merge($defaultParams, $params);
}
}
<?php

class CRM_Price_Form_FieldTest extends CiviUnitTestCase {

protected $priceFieldValues;
protected $visibilityOptionsKeys;
protected $visibilityOptions;
protected $publicFieldParams;
protected $adminFieldParams;

public function setUp() {
parent::setUp();

$this->visibilityOptionsKeys = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, array(
'labelColumn' => 'name',
'flip' => TRUE,
));

$this->publicFieldParams = $this->initializeFieldParameters(array(
'label' => 'Public Price Field',
'name' => 'public_price',
'visibility_id' => $this->visibilityOptionsKeys['public'],
));

$this->adminFieldParams = $this->initializeFieldParameters(array(
'label' => 'Public Price Field',
'name' => 'public_price',
'visibility_id' => $this->visibilityOptionsKeys['admin'],
));
}

public function testPublicFieldWithOnlyAdminOptionsIsNotAllowed() {
$this->publicFieldParams['option_label'][1] = 'Admin Price';
$this->publicFieldParams['option_amount'][1] = 10;
$this->publicFieldParams['option_visibility_id'][1] = $this->visibilityOptionsKeys['admin'];

$form = new CRM_Price_Form_Field();
$form->_action = CRM_Core_Action::ADD;
$files = array();

$validationResult = $form->formRule($this->publicFieldParams, $files, $form);
$this->assertType('array', $validationResult);
$this->assertTrue(array_key_exists('visibility_id', $validationResult));
}

public function testAdminFieldDoesNotAllowPublicOptions() {
$this->adminFieldParams['option_label'][1] = 'Admin Price';
$this->adminFieldParams['option_amount'][1] = 10;
$this->adminFieldParams['option_visibility_id'][1] = $this->visibilityOptionsKeys['public'];

$form = new CRM_Price_Form_Field();
$form->_action = CRM_Core_Action::ADD;
$files = array();

$validationResult = $form->formRule($this->adminFieldParams, $files, $form);
$this->assertType('array', $validationResult);
$this->assertTrue(array_key_exists('visibility_id', $validationResult));
}

private function initializeFieldParameters($params) {
$defaultParams = array(
'label' => 'Price Field',
'name' => CRM_Utils_String::titleToVar('Price Field'),
'html_type' => 'Select',
'is_display_amounts' => 1,
'weight' => 1,
'options_per_line' => 1,
'is_enter_qty' => 1,
'financial_type_id' => $this->getFinancialTypeId('Event Fee'),
'visibility_id' => $this->visibilityOptionsKeys['public'],
);

for ($index = 1; $index <= CRM_Price_Form_Field::NUM_OPTION; $index++) {
$defaultParams['option_label'][$index] = NULL;
$defaultParams['option_value'][$index] = NULL;
$defaultParams['option_name'][$index] = NULL;
$defaultParams['option_weight'][$index] = NULL;
$defaultParams['option_amount'][$index] = NULL;
$defaultParams['option_visibility_id'][$index] = NULL;
}

return array_merge($defaultParams, $params);
}

}
Loading