activity export fail
authordemeritcowboy <demeritcowboy@hotmail.com>
Mon, 13 Sep 2021 17:31:56 +0000 (13:31 -0400)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Mon, 13 Sep 2021 17:31:56 +0000 (13:31 -0400)
CRM/Activity/Task.php
tests/phpunit/CRM/Activity/Form/SearchTest.php

index a2305a2c55b5b0a5c09e103177b7c71274522d0d..d1689bdb7fcce53e2caf02b4788a9e3ec0d02b3d 100644 (file)
@@ -157,7 +157,7 @@ class CRM_Activity_Task extends CRM_Core_Task {
       $value = self::TASK_PRINT;
     }
     if (isset(self::$_tasks[$value])) {
-      return [[self::$_tasks[$value]['class']], self::$_tasks[$value]['result']];
+      return [(array) self::$_tasks[$value]['class'], self::$_tasks[$value]['result']];
     }
     return [[], NULL];
   }
index 324ce667d923183cba4481fbc7843e410d4fb17e..e2a4f956b83a9e6844e3022c81893612bc6f1ff4 100644 (file)
@@ -120,4 +120,45 @@ class CRM_Activity_Form_SearchTest extends CiviUnitTestCase {
     ];
   }
 
+  /**
+   * This just checks there's no errors. It doesn't perform any tasks.
+   * It's a little bit like choosing an action from the dropdown.
+   * @dataProvider taskControllerProvider
+   * @param int $task
+   */
+  public function testTaskController(int $task) {
+    // It gets the task from the POST var
+    $oldtask = $_POST['task'] ?? NULL;
+    $_POST['task'] = $task;
+
+    // yes it's the string 'null'
+    new CRM_Activity_Controller_Search('Find Activities', TRUE, 'null');
+
+    // clean up
+    if (is_null($oldtask)) {
+      unset($_POST['task']);
+    }
+    else {
+      $_POST['task'] = $oldtask;
+    }
+  }
+
+  /**
+   * dataprovider for testTaskController
+   * @return array
+   */
+  public function taskControllerProvider(): array {
+    return [
+      [CRM_Activity_Task::TASK_DELETE],
+      [CRM_Activity_Task::TASK_PRINT],
+      [CRM_Activity_Task::TASK_EXPORT],
+      [CRM_Activity_Task::BATCH_UPDATE],
+      [CRM_Activity_Task::TASK_EMAIL],
+      [CRM_Activity_Task::PDF_LETTER],
+      [CRM_Activity_Task::TASK_SMS],
+      [CRM_Activity_Task::TAG_ADD],
+      [CRM_Activity_Task::TAG_REMOVE],
+    ];
+  }
+
 }