missing semicolon, other cleanup, add test
authordemeritcowboy <demeritcowboy@hotmail.com>
Fri, 15 May 2020 21:47:42 +0000 (17:47 -0400)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Fri, 15 May 2020 23:19:49 +0000 (19:19 -0400)
CRM/Activity/Page/AJAX.php
templates/CRM/Admin/Form/Setting/Smtp.tpl
templates/CRM/Case/Form/ActivityToCase.tpl
templates/CRM/Report/Form/Actions.tpl
tests/phpunit/CRM/Activity/Page/AJAXTest.php [new file with mode: 0644]

index e652726a608d756508da8738964649b15401f588..c7fe505bc48a3fce3b4d7af2e075b87c2a799e79 100644 (file)
@@ -353,7 +353,7 @@ class CRM_Activity_Page_AJAX {
     if (!empty($params['assigneeContactIds'])) {
       $assigneeContacts = array_unique(explode(',', $params['assigneeContactIds']));
     }
-    foreach ($assigneeContacts as $key => $value) {
+    foreach ($assigneeContacts as $value) {
       $assigneeParams = [
         'activity_id' => $mainActivityId,
         'contact_id' => $value,
index bde961cb5a93597df711a38cc0e3be48eb522cc4..789a85bd570be41cb68fc7d137be15f45de09090 100644 (file)
@@ -93,7 +93,7 @@
     CRM.$(function($) {
       var mailSetting = $("input[name='outBound_option']:checked").val( );
 
-      var archiveWarning = "{/literal}{ts escape='js'}WARNING: You are switching from a testing mode (Redirect to Database) to a live mode. Check Mailings > Archived Mailings, and delete any test mailings that are not in Completed status prior to running the mailing cron job for the first time. This will ensure that test mailings are not actually sent out.{/ts}{literal}"
+      var archiveWarning = "{/literal}{ts escape='js'}WARNING: You are switching from a testing mode (Redirect to Database) to a live mode. Check Mailings > Archived Mailings, and delete any test mailings that are not in Completed status prior to running the mailing cron job for the first time. This will ensure that test mailings are not actually sent out.{/ts}{literal}";
 
         showHideMailOptions( $("input[name='outBound_option']:checked").val( ) ) ;
 
index 0bc1ad634b2079ef8b4a20aae2639796e27051fa..8d9b69525263d0d31157b7c6e3de8ba78470e1de 100644 (file)
@@ -73,7 +73,7 @@
             var caseUrl = destUrl + selectedCaseId + '&cid=' + contactId + context;
 
             var statusMsg = {/literal}'{ts escape='js' 1='%1'}Activity has been filed to %1 case.{/ts}'{literal};
-            CRM.alert(ts(statusMsg, {1: '<a href="' + caseUrl + '">' + caseTitle + '</a>'}), '{/literal}{ts escape="js"}Saved{/ts}{literal}', 'success');
+            CRM.alert(ts(statusMsg, {1: '<a href="' + caseUrl + '">' + CRM._.escape(caseTitle) + '</a>'}), '{/literal}{ts escape="js"}Saved{/ts}{literal}', 'success');
             CRM.refreshParent(a);
           }
         }
index 3e44fef13e1ac132ae3a1cdeb8c1dd25bd1340e6..7b00728147f94fb5c137b760080d7c203753e976 100644 (file)
@@ -42,7 +42,7 @@
                       (function($) {
                         $('#groups').val('').change(function() {
                           CRM.confirm({
-                            message: ts({/literal}'{ts escape='js' 1='<em>%1</em>'}Add all contacts to %1 group?{/ts}'{literal}, {1: $('option:selected', '#groups').text()})
+                            message: ts({/literal}'{ts escape='js' 1='<em>%1</em>'}Add all contacts to %1 group?{/ts}'{literal}, {1: CRM._.escape($('option:selected', '#groups').text())})
                           })
                             .on({
                               'crmConfirm:yes': function() {
diff --git a/tests/phpunit/CRM/Activity/Page/AJAXTest.php b/tests/phpunit/CRM/Activity/Page/AJAXTest.php
new file mode 100644 (file)
index 0000000..f9e9f75
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * @group headless
+ */
+class CRM_Activity_Page_AJAXTest extends CiviUnitTestCase {
+
+  public function setUp() {
+    parent::setUp();
+
+    $this->loadAllFixtures();
+
+    CRM_Core_BAO_ConfigSetting::enableComponent('CiviCase');
+
+    $this->loggedInUser = $this->createLoggedInUser();
+    $this->target = $this->individualCreate();
+  }
+
+  /**
+   * Test the underlying function that implements file-on-case.
+   *
+   * The UI is a quickform but it's only realized as a popup ajax form that
+   * doesn't have its own postProcess. Instead the values are ultimately
+   * passed to the function this test is testing. So there's no form or ajax
+   * being tested here, just the final act of filing the activity.
+   */
+  public function testConvertToCaseActivity() {
+    $activity = $this->callAPISuccess('Activity', 'create', [
+      'source_contact_id' => $this->loggedInUser,
+      'activity_type_id' => 'Meeting',
+      'subject' => 'test file on case',
+      'status_id' => 'Completed',
+      'target_id' => $this->target,
+    ]);
+
+    $case = $this->callAPISuccess('Case', 'create', [
+      'contact_id' => $this->target,
+      'case_type_id' => 'housing_support',
+      'subject' => 'Needs housing',
+    ]);
+
+    $params = [
+      'activityID' => $activity['id'],
+      'caseID' => $case['id'],
+      'mode' => 'file',
+      'targetContactIds' => $this->target,
+    ];
+    $result = CRM_Activity_Page_AJAX::_convertToCaseActivity($params);
+
+    $this->assertEmpty($result['error_msg']);
+    $newActivityId = $result['newId'];
+
+    $caseActivities = $this->callAPISuccess('Activity', 'get', [
+      'case_id' => $case['id'],
+    ])['values'];
+    $this->assertEquals('test file on case', $caseActivities[$newActivityId]['subject']);
+    // This should be a different physical activity, not the same db record as the original.
+    $this->assertNotEquals($activity['id'], $caseActivities[$newActivityId]['id']);
+  }
+
+}