Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFC] Add test for new case email url #21766

Merged
merged 1 commit into from
Oct 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions tests/phpunit/CRM/Case/Form/EmailTest.php
Original file line number Diff line number Diff line change
@@ -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);
}

}