Link Cases Webtest CRM-15002
authorJitendra Purohit <jitendra.purohit@webaccessglobal.com>
Mon, 11 Aug 2014 13:43:13 +0000 (19:13 +0530)
committerJitendra Purohit <jitendra.purohit@webaccessglobal.com>
Mon, 11 Aug 2014 13:43:13 +0000 (19:13 +0530)
tests/phpunit/WebTest/Case/ActivityToCaseTest.php

index 432da5c1be87d11fc7ac3487ebbe29ee656a71b7..b88c3c1b8e77960ef3f6f0af95841c8474caece8 100644 (file)
@@ -86,6 +86,109 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase {
     $this->_testAddNewActivity($firstName, $subject, $customGroupTitle, $contactName);
   }
 
+  function testLinkCases() {
+    $this->webtestLogin();
+
+    //Add Case 1
+    $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom');
+
+    // Adding contact with randomized first name (so we can then select that contact when creating case)
+    // We're using pop-up New Contact dialog
+    $firstName = substr(sha1(rand()), 0, 7);
+    $lastName = "Fraser";
+    $contactName = "{$lastName}, {$firstName}";
+    $displayName = "{$firstName} {$lastName}";
+    $email = "{$lastName}.{$firstName}@example.org";
+    $this->webtestNewDialogContact($firstName, $lastName, $email, $type = 4, "s2id_client_id");
+
+    // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files.
+    $caseTypeLabel = "Adult Day Care Referral";
+    $subject = "Safe daytime setting - senior female";
+    $this->select('medium_id', 'value=1');
+    $this->type('activity_location', 'Main offices');
+    $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented.";
+    $this->fillRichTextField("activity_details", $details, 'CKEditor');
+    $this->type('activity_subject', $subject);
+
+    $this->select('case_type_id', "label={$caseTypeLabel}");
+
+    // Choose Case Start Date.
+    // Using helper webtestFillDate function.
+    $this->webtestFillDate('start_date', 'now');
+    $today = date('F jS, Y', strtotime('now'));
+
+    $this->type('duration', "20");
+    $this->clickLink('_qf_Case_upload-bottom', '_qf_CaseView_cancel-bottom', FALSE);
+
+    // Is status message correct?
+    $this->waitForText('crm-notification-container', "Case opened successfully.");
+
+    //Add Case 2
+    $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom');
+
+    // Adding contact with randomized first name (so we can then select that contact when creating case)
+    // We're using pop-up New Contact dialog
+    $firstName2 = substr(sha1(rand()), 0, 7);
+    $lastName2 = "Fraser";
+    $contactName2 = "{$lastName}, {$firstName}";
+    $displayName2 = "{$firstName} {$lastName}";
+    $email2 = "{$lastName2}.{$firstName2}@example.org";
+    $this->webtestNewDialogContact($firstName2, $lastName2, $email2, $type = 4, "s2id_client_id");
+
+    // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files.
+    $caseTypeLabel2 = "Adult Day Care Referral";
+    $subject2 = "Subject For Case 2";
+    $this->select('medium_id', 'value=1');
+    $this->type('activity_location', 'Main offices');
+    $details2 = "Details For Case 2";
+    $this->fillRichTextField("activity_details", $details2, 'CKEditor');
+    $this->type('activity_subject', $subject2);
+
+    $this->select('case_type_id', "label={$caseTypeLabel2}");
+
+    // Choose Case Start Date.
+    // Using helper webtestFillDate function.
+    $this->webtestFillDate('start_date', 'now');
+    $today = date('F jS, Y', strtotime('now'));
+
+    $this->type('duration', "20");
+    $this->clickLink('_qf_Case_upload-bottom', '_qf_CaseView_cancel-bottom', FALSE);
+
+    // Is status message correct?
+    $this->waitForText('crm-notification-container', "Case opened successfully.");
+
+    //Add Link Case Activity
+    $this->select('add_activity_type_id', 'Link Cases');
+    $this->waitForElementPresent("_qf_Activity_cancel-bottom");
+    $this->select2('link_to_case_id', $firstName);
+    $activitydetails = 'Details of Link Case Activity';
+    $this->fillRichTextField("details", $activitydetails, 'CKEditor');
+    $this->click('activity-details');
+    $this->waitForElementPresent('subject');
+    $activitySubject = 'Link Case Activity between case 1 and case 2';
+    $activitylocation = 'Main Office Building';
+    $this->select2('source_contact_id', $firstName2);
+    $this->type('subject', $activitySubject);
+    $this->type('location', $activitylocation);
+    $this->click('_qf_Activity_upload-bottom');
+    $id = $this->urlArg('id');
+    $this->waitForText("case_id_$id", $activitySubject);
+    $this->click("xpath=//a[contains(text(),'$activitySubject')]");
+
+    $LinkCaseActivityData = array(
+      "Client" => $firstName2,
+      "Activity Type" => "Link Cases",
+      "Subject" => $activitySubject,
+      "Reported By" => "{$firstName2} {$lastName2}",
+      "Medium" => "Phone",
+      "Location" => $activitylocation,
+      "Date and Time" => $today,
+      "Details" => $activitydetails,
+      "Status" => "Scheduled",
+      "Priority" => "Normal",
+    );
+    $this->webtestVerifyTabularData($LinkCaseActivityData);
+  }
   /**
    * @param $firstName
    * @param $caseSubject