Webtest for
authorRohan Katkar <rohan.katkar@webaccess.co.in>
Tue, 12 Aug 2014 06:28:18 +0000 (11:58 +0530)
committerRohan Katkar <rohan.katkar@webaccess.co.in>
Tue, 12 Aug 2014 06:28:18 +0000 (11:58 +0530)
tests/phpunit/WebTest/Case/AddCaseTest.php

index 98ddd48437428bbe906c17c336b2b5b9c3aa2ec9..bab7a97ec25356edb742dd45dc6e8dbf2dc734d6 100644 (file)
@@ -141,6 +141,7 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase {
     $this->_testSearchbyDate($firstName, $lastName, "this.quarter");
     $this->_testSearchbyDate($firstName, $lastName, "0");
     $this->_testSearchbyDate($firstName, $lastName, "this.year");
+    $this->_testAssignToClient($firstName, $lastName, $caseTypeLabel);
   }
 
   function testAjaxCustomGroupLoad() {
@@ -176,13 +177,14 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase {
    * @param $creatorName
    */
   function _testVerifyCaseRoles($caseRoles, $creatorName) {
-    $this->waitForElementPresent("xpath=//table[@id='caseRoles-selector']/tbody/tr[4]/td[2]/a");
+    $id = $this->urlArg('id');
+    $this->waitForElementPresent("xpath=//table[@id='caseRoles-selector-$id']/tbody/tr[4]/td[2]/a");
     // check that expected roles are listed in the Case Roles pane
     foreach ($caseRoles as $role) {
       $this->assertText("css=div.crm-case-roles-block", $role);
     }
     // check that case creator role has been assigned to logged in user
-    $this->verifyText("xpath=//table[@id='caseRoles-selector']/tbody/tr[4]/td[2]", $creatorName);
+    $this->verifyText("xpath=//table[@id='caseRoles-selector-$id']/tbody/tr[4]/td[2]", $creatorName);
   }
 
   /**
@@ -266,5 +268,28 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
     $this->assertElementContainsText('Advanced', "$lastName, $firstName");
   }
+  
+  /**
+   * @param $firstName
+   * @param $lastName
+   * @param $caseTypeLabel
+   * 
+   * test for assign case to another client 
+   */
+   function _testAssignToClient($firstName, $lastName, $caseTypeLabel) {
+    $this->openCiviPage('case/search', 'reset=1', '_qf_Search_refresh-bottom'); 
+    $this->type('sort_name', $firstName);
+    $this->click('_qf_Search_refresh-bottom');
+    $this->waitForElementPresent("xpath=//table[@class='caseSelector']/tbody//tr/td[3]/a[text()='{$lastName}, {$firstName}']");
+
+    $this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[3]/a[text()='{$lastName}, {$firstName}']/../../td[11]/span[2]/ul/li/a[contains(text(),'Assign to Another Client')]");
+    $clientFirstName = substr(sha1(rand()), 0, 7);
+    $clientLastName = "Fraser";
+    $clientEmail = "{$clientLastName}.{$clientFirstName}@example.org";
+    $this->waitForElementPresent('_qf_EditClient_done-bottom');
+    $this->webtestNewDialogContact($clientFirstName, $clientLastName, $clientEmail, $type = 4, "s2id_reassign_contact_id");
+    $this->clickLink('_qf_EditClient_done-bottom');
+    $this->assertElementContainsText('page-title', "$clientFirstName $clientLastName - $caseTypeLabel");
+  }
 }