From b0e06ce44f9d5588b2986843214034e9ce3614bc Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Tue, 8 Jun 2021 00:54:20 +0000 Subject: [PATCH] [php8-compat] Partial Fix of hook tests for php8 --- CRM/Contact/Page/DedupeMerge.php | 2 +- CRM/Event/Page/ManageEvent.php | 2 +- templates/CRM/Admin/Form/ContactType.tpl | 2 +- templates/CRM/Admin/Form/OptionGroup.tpl | 19 ++++++++++++------- templates/CRM/Admin/Form/Options.tpl | 24 +++++++++++++----------- tests/phpunit/CRM/Core/Page/HookTest.php | 3 +++ 6 files changed, 31 insertions(+), 21 deletions(-) diff --git a/CRM/Contact/Page/DedupeMerge.php b/CRM/Contact/Page/DedupeMerge.php index b4bf18bafa..25d38f803a 100644 --- a/CRM/Contact/Page/DedupeMerge.php +++ b/CRM/Contact/Page/DedupeMerge.php @@ -124,7 +124,7 @@ class CRM_Contact_Page_DedupeMerge extends CRM_Core_Page { * @throws \CiviCRM_API3_Exception * @throws \API_Exception */ - public static function callBatchMerge(CRM_Queue_TaskContext $ctx, $rgid, $gid, $mode = 'safe', $batchLimit, $isSelected, $criteria, $searchLimit) { + public static function callBatchMerge(CRM_Queue_TaskContext $ctx, $rgid, $gid, $mode, $batchLimit, $isSelected, $criteria, $searchLimit) { CRM_Dedupe_Merger::batchMerge($rgid, $gid, $mode, $batchLimit, $isSelected, $criteria, TRUE, FALSE, $searchLimit); return CRM_Queue_Task::TASK_SUCCESS; } diff --git a/CRM/Event/Page/ManageEvent.php b/CRM/Event/Page/ManageEvent.php index 53a8f9415d..6c45eb732d 100644 --- a/CRM/Event/Page/ManageEvent.php +++ b/CRM/Event/Page/ManageEvent.php @@ -480,7 +480,7 @@ ORDER BY start_date desc * * @return string */ - public function whereClause(&$params, $sortBy = TRUE, $force) { + public function whereClause(&$params, $sortBy, $force) { $values = []; $clauses = []; $title = $this->get('title'); diff --git a/templates/CRM/Admin/Form/ContactType.tpl b/templates/CRM/Admin/Form/ContactType.tpl index 90c1962d33..4ecf601650 100644 --- a/templates/CRM/Admin/Form/ContactType.tpl +++ b/templates/CRM/Admin/Form/ContactType.tpl @@ -29,7 +29,7 @@ {$form.parent_id.label} - {if $is_parent OR $action EQ 1} + {if !empty($is_parent) OR $action EQ 1} {$form.parent_id.html} {else} {ts}{$contactTypeName}{/ts} {ts}(built-in){/ts} diff --git a/templates/CRM/Admin/Form/OptionGroup.tpl b/templates/CRM/Admin/Form/OptionGroup.tpl index 13f6ddee5b..ae96f23def 100644 --- a/templates/CRM/Admin/Form/OptionGroup.tpl +++ b/templates/CRM/Admin/Form/OptionGroup.tpl @@ -17,7 +17,6 @@ {else} - @@ -26,8 +25,12 @@ - - + {if !empty($form.name)} + + + + + {/if} @@ -36,10 +39,12 @@ - - - - + {if !empty($form.is_reserved)} + + + + + {/if}
{$form.title.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_option_group' field='title' id=$id}{/if}{$form.title.html}{$form.description.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_option_group' field='description' id=$id}{/if}{$form.description.html}
{$form.name.label}{$form.name.html}
{$form.name.label}{$form.name.html}
{$form.data_type.label} {$form.data_type.html}{$form.is_active.label} {$form.is_active.html}
{$form.is_reserved.label}{$form.is_reserved.html}
{$form.is_reserved.label}{$form.is_reserved.html}
{/if}
{include file="CRM/common/formButtons.tpl" location="bottom"}
diff --git a/templates/CRM/Admin/Form/Options.tpl b/templates/CRM/Admin/Form/Options.tpl index fa435bd63e..35a857db87 100644 --- a/templates/CRM/Admin/Form/Options.tpl +++ b/templates/CRM/Admin/Form/Options.tpl @@ -38,14 +38,14 @@ {ts}A "string value" or regular expression to be redacted (replaced).{/ts} - {else} + {elseif !empty($form.label)} {$form.label.label} {if $action == 2}{include file='CRM/Core/I18n/Dialog.tpl' table='civicrm_option_value' field='label' id=$id}{/if} {$form.label.html}
{ts}The option label is displayed to users.{/ts} - {if $form.financial_account_id.html} + {if !empty($form.financial_account_id.html)} {$form.financial_account_id.label} {$form.financial_account_id.html} @@ -53,7 +53,7 @@ {/if} {/if} - {if $form.value.html && $gName neq 'redaction_rule'} + {if !empty($form.value.html) && $gName neq 'redaction_rule'} {$form.value.label} {$form.value.html}
@@ -80,7 +80,7 @@ {/if} - {if $form.name.html} {* Get the name value also *} + {if !empty($form.name.html)} {* Get the name value also *} {$form.name.label} {$form.name.html}
@@ -88,7 +88,7 @@ {/if} - {if $form.filter.html} {* Filter property is only exposed for some option groups. *} + {if !empty($form.filter.html)} {* Filter property is only exposed for some option groups. *} {$form.filter.label} {$form.filter.html} @@ -109,29 +109,31 @@ {$form.visibility_id.html} {/if} - {if $form.grouping.html} + {if !empty($form.grouping.html)} {$form.grouping.label} {$form.grouping.html} {/if} + {if !empty($form.weight)} {$form.weight.label} {$form.weight.html} - {if $form.icon.html} + {/if} + {if !empty($form.icon.html)} {$form.icon.label} {$form.icon.html} {/if} - {if $form.color.html} + {if !empty($form.color.html)} {$form.color.label} {$form.color.html} {/if} - {if $form.component_id.html} {* Component ID is exposed for activity types if CiviCase is enabled. *} + {if !empty($form.component_id.html)} {* Component ID is exposed for activity types if CiviCase is enabled. *} {$form.component_id.label} {$form.component_id.html} @@ -141,13 +143,13 @@ {$form.is_active.label} {$form.is_active.html} - {if $showDefault} + {if !empty($showDefault)} {$form.is_default.label} {$form.is_default.html} {/if} - {if $showContactFilter}{* contactOptions is exposed for email/postal greeting and addressee types to set filter for contact types *} + {if !empty($showContactFilter)}{* contactOptions is exposed for email/postal greeting and addressee types to set filter for contact types *} {$form.contactOptions.label} {$form.contactOptions.html} diff --git a/tests/phpunit/CRM/Core/Page/HookTest.php b/tests/phpunit/CRM/Core/Page/HookTest.php index 5c0e548e4e..77d6a7e163 100644 --- a/tests/phpunit/CRM/Core/Page/HookTest.php +++ b/tests/phpunit/CRM/Core/Page/HookTest.php @@ -52,6 +52,9 @@ class CRM_Core_Page_HookTest extends CiviUnitTestCase { $items = CRM_Core_Menu::items(TRUE); // Check if they extend the class we care about; test if needed. foreach ($items as $item) { + if (!isset($item['page_callback'])) { + continue; + } $class = is_array($item['page_callback']) ? $item['page_callback'][0] : $item['page_callback']; if (in_array($class, $this->skip)) { continue; -- 2.25.1