From: demeritcowboy Date: Mon, 13 Sep 2021 17:31:56 +0000 (-0400) Subject: activity export fail X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c8f3c0f5ce58f4ebf6192c875f75c8fcb9d36b2d;p=civicrm-core.git activity export fail --- diff --git a/CRM/Activity/Task.php b/CRM/Activity/Task.php index a2305a2c55..d1689bdb7f 100644 --- a/CRM/Activity/Task.php +++ b/CRM/Activity/Task.php @@ -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]; } diff --git a/tests/phpunit/CRM/Activity/Form/SearchTest.php b/tests/phpunit/CRM/Activity/Form/SearchTest.php index 324ce667d9..e2a4f956b8 100644 --- a/tests/phpunit/CRM/Activity/Form/SearchTest.php +++ b/tests/phpunit/CRM/Activity/Form/SearchTest.php @@ -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], + ]; + } + }