add test
authordemeritcowboy <demeritcowboy@hotmail.com>
Thu, 7 Oct 2021 18:37:33 +0000 (14:37 -0400)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Thu, 7 Oct 2021 23:24:46 +0000 (19:24 -0400)
tests/phpunit/CRM/Case/Form/EmailTest.php [new file with mode: 0644]

diff --git a/tests/phpunit/CRM/Case/Form/EmailTest.php b/tests/phpunit/CRM/Case/Form/EmailTest.php
new file mode 100644 (file)
index 0000000..20fdbf5
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * @group headless
+ */
+class CRM_Case_Form_EmailTest extends CiviCaseTestCase {
+
+  public function testOpeningEmailForm() {
+    $loggedInUserId = $this->createLoggedInUser();
+    $clientId = $this->individualCreate();
+    $caseObj = $this->createCase($clientId, $loggedInUserId);
+
+    $url = "civicrm/case/email/add?reset=1&action=add&atype=3&cid={$loggedInUserId}&caseid={$caseObj->id}";
+
+    $_SERVER['REQUEST_URI'] = $url;
+    $urlParts = explode('?', $url);
+    $_GET['q'] = $urlParts[0];
+
+    $parsed = [];
+    parse_str($urlParts[1], $parsed);
+    foreach ($parsed as $param => $value) {
+      $_REQUEST[$param] = $value;
+    }
+
+    $item = CRM_Core_Invoke::getItem([$_GET['q']]);
+    ob_start();
+    CRM_Core_Invoke::runItem($item);
+    $contents = ob_get_contents();
+    ob_end_clean();
+
+    foreach ($parsed as $param => $dontcare) {
+      unset($_REQUEST[$param]);
+    }
+
+    // Anything here could be subject to change. Just tried to pick a few that
+    // might be less likely to. Really just trying to see if it opens the
+    // right form and with no errors.
+    $this->assertStringContainsString('name="from_email_address"', $contents);
+    $this->assertStringContainsString('name="subject"', $contents);
+    $this->assertStringContainsString('name="_qf_Email_upload"', $contents);
+    $this->assertStringContainsString('anthony_anderson@civicrm.org', $contents);
+    $this->assertStringContainsString('CRM_Case_Form_Task_Email', $contents);
+  }
+
+}