From 6e3a56254c760782a799bf3dc09634cb89d97e3f Mon Sep 17 00:00:00 2001 From: Muhammad Shahrukh <> Date: Thu, 8 Aug 2024 17:50:08 +0500 Subject: [PATCH] COMCL-706: Fix linter issues --- .github/workflows/unit-test.yml | 4 ++++ .../Hook/BuildForm/EnableCaseCategoryIconField.php | 2 +- CRM/Civicase/Hook/CaseCategoryFormHookBase.php | 4 +--- .../Hook/PostProcess/CaseCategoryPostProcessor.php | 3 +-- CRM/Civicase/Hook/ValidateForm/SendBulkEmail.php | 7 +++++++ .../CRM/Civicase/Hook/ValidateForm/SendBulkEmailTest.php | 4 ++-- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index b1a16b736..ba0806ba3 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -56,6 +56,7 @@ jobs: run: | FILE_PATH="$GITHUB_WORKSPACE/site/web/sites/default/civicrm.settings.php" INSERT_LINE="\$GLOBALS['_CV']['TEST_DB_DSN'] = 'mysql://root:root@mysql:3306/civicrm_test?new_link=true';" + INSERT_LINE_SECOND="\define('CIVICRM_TEMPLATE_COMPILE_CHECK', TRUE);" TMP_FILE=$(mktemp) while IFS= read -r line do @@ -63,6 +64,9 @@ jobs: if [ "$line" = "> "$TMP_FILE" fi + if [ "$line" = "define('CIVICRM_TEMPLATE_COMPILE_CHECK', false);" ]; then + echo "$INSERT_LINE_SECOND" >> "$TMP_FILE" + fi done < "$FILE_PATH" mv "$TMP_FILE" "$FILE_PATH" echo "File modified successfully." diff --git a/CRM/Civicase/Hook/BuildForm/EnableCaseCategoryIconField.php b/CRM/Civicase/Hook/BuildForm/EnableCaseCategoryIconField.php index 375a50372..c08ab703b 100644 --- a/CRM/Civicase/Hook/BuildForm/EnableCaseCategoryIconField.php +++ b/CRM/Civicase/Hook/BuildForm/EnableCaseCategoryIconField.php @@ -1,7 +1,7 @@ getVar('_gName'); - return $formName == CRM_Admin_Form_Options::class - && $optionGroupName == 'case_type_categories'; + && $form->getVar('_gName') == 'case_type_categories'; } /** diff --git a/CRM/Civicase/Hook/PostProcess/CaseCategoryPostProcessor.php b/CRM/Civicase/Hook/PostProcess/CaseCategoryPostProcessor.php index 5906eee18..7f65a8d05 100644 --- a/CRM/Civicase/Hook/PostProcess/CaseCategoryPostProcessor.php +++ b/CRM/Civicase/Hook/PostProcess/CaseCategoryPostProcessor.php @@ -66,8 +66,7 @@ public function run($formName, CRM_Core_Form &$form) { * returns TRUE or FALSE. */ private function shouldRun(CRM_Core_Form $form, $formName) { - $optionGroupName = $form->getVar('_gName'); - return $formName == 'CRM_Admin_Form_Options' && $optionGroupName == 'case_type_categories'; + return $formName == 'CRM_Admin_Form_Options' && $form->getVar('_gName') == 'case_type_categories'; } } diff --git a/CRM/Civicase/Hook/ValidateForm/SendBulkEmail.php b/CRM/Civicase/Hook/ValidateForm/SendBulkEmail.php index 5f6ffbeaf..d055b4490 100644 --- a/CRM/Civicase/Hook/ValidateForm/SendBulkEmail.php +++ b/CRM/Civicase/Hook/ValidateForm/SendBulkEmail.php @@ -248,6 +248,13 @@ private function sendEmailForCase(CRM_Case_Form_Task_Email $form, int $caseId, a $data['values']['Email']['to'] = implode(',', $toContactEmails); + $allEmails = explode(',', $data['values']['Email']['to']); + foreach ($allEmails as $value) { + $values = explode('::', $value); + print_r($values); + } + print_r($form->exportValues()); + $form->submit($form->exportValues()); } diff --git a/tests/phpunit/CRM/Civicase/Hook/ValidateForm/SendBulkEmailTest.php b/tests/phpunit/CRM/Civicase/Hook/ValidateForm/SendBulkEmailTest.php index 1c8f5f2c5..5e300e5ae 100644 --- a/tests/phpunit/CRM/Civicase/Hook/ValidateForm/SendBulkEmailTest.php +++ b/tests/phpunit/CRM/Civicase/Hook/ValidateForm/SendBulkEmailTest.php @@ -329,13 +329,13 @@ private function runHook(string $subject, string $body, array $cases, array $con $this->form->_contactDetails = []; foreach ($contacts as $k => $contact) { $this->form->_contactIds[] = $contact['id']; - $this->form->_toContactEmails[] = $k . '::' . $contact['email']; + $this->form->_toContactEmails[] = $contact['email']; $this->form->_contactDetails[$contact['id']] = [ 'email' => $contact['email'], 'contact_id' => $contact['id'], 'preferred_mail_format' => 'HTML', ]; - $formValues['to'][$contact['id']] = $contact['id'] . '::' . $contact['email']; + $formValues['to'][$contact['id'] ?? $k] = ($contact['id'] ?? $k) . '::' . $contact['email']; } $formValues['to'] = implode(',', $formValues['to']);