Webtest for CRM-14952
authoratif-shaikh <shaikh388@gmail.com>
Thu, 24 Jul 2014 13:07:46 +0000 (18:37 +0530)
committeratif-shaikh <shaikh388@gmail.com>
Thu, 24 Jul 2014 13:07:46 +0000 (18:37 +0530)
----------------------------------------
* CRM-14952: Sorting on state in search throws FATAL error: Database Error Code: Unknown column 'civicrm_state_province.name' in 'field list'
  https://issues.civicrm.org/jira/browse/CRM-14952

tests/phpunit/CiviTest/CiviSeleniumTestCase.php
tests/phpunit/WebTest/Contact/AdvancedSearchTest.php

index 1c1a6cd2d6b49ab4e066c309d8aaf034c24b3fd7..f5a68ad68f70b2f03072f86fe1008e8e0524c396 100644 (file)
@@ -2095,10 +2095,10 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
    */
   function select2($fieldName,$label, $multiple = FALSE, $xpath=FALSE) {
     if ($multiple) {
-      $this->clickAt("//*[@id='$fieldName']/../div/ul/li[1]");
-      $this->keyDown("//*[@id='$fieldName']/../div/ul/li[1]/input", " ");
-      $this->type("//*[@id='$fieldName']/../div/ul/li[1]/input", $label);
-      $this->typeKeys("//*[@id='$fieldName']/../div/ul/li[1]/input", $label);
+      $this->clickAt("//*[@id='$fieldName']/../div/ul/li");
+      $this->keyDown("//*[@id='$fieldName']/../div/ul/li//input", " ");
+      $this->type("//*[@id='$fieldName']/../div/ul/li//input", $label);
+      $this->typeKeys("//*[@id='$fieldName']/../div/ul/li//input", $label);
       $this->waitForElementPresent("//*[@class='select2-result-label']");
       $this->clickAt("//*[@class='select2-results']/li[1]/div");
     }
index cf59ce2ab4dbca532b13503bd1ed037b7fb3dd8f..3a1bb9339f3a5f9367feae9040e493e03b508862 100644 (file)
@@ -260,6 +260,44 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase {
     );
   }
 
+  /*
+   * Check for CRM-14952
+   */
+  function testStateSorting() {
+    $this->webtestLogin();
+    $this->openCiviPage('contact/search/advanced', 'reset=1');
+    $this->waitForElementPresent('group');
+    $this->select2("group", "Newsletter", TRUE);
+    $this->select2("group", "Advisory", TRUE);
+    $this->click("location");
+    $this->waitForElementPresent('country');
+    $this->select2("country", "United States", False);
+    $this->click("_qf_Advanced_refresh");
+    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $stateBeforeSort = $this->getText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]");
+    $this->click("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(),'State')]");
+    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->assertElementNotContainsText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]", $stateBeforeSort);
+    $this->click("xpath=//form[@id='Advanced']//div//div[contains(text(),'Edit Search Criteria')]/../div");
+    $this->waitForElementPresent('group');
+    $this->select2("group", "Summer", TRUE);
+    $this->waitForElementPresent('state_province');
+    $this->select2("state_province", "Ohio", TRUE);
+    $this->select2("state_province", "New York", TRUE);
+    $this->select2("state_province", "New Mexico", TRUE);
+    $this->select2("state_province", "Mississippi", TRUE);
+    $this->select2("state_province", "Connecticut", TRUE);
+    $this->select2("state_province", "Georgia", TRUE);
+    $this->select2("state_province", "New Jersey", TRUE);
+    $this->select2("state_province", "Texas", TRUE);
+    $this->click("_qf_Advanced_refresh");
+    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $stateBeforeSort = $this->getText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]");
+    $this->click("xpath=//div[@class='crm-search-results']//table/thead/tr//th/a[contains(text(),'State')]");
+    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->assertElementNotContainsText("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[6]", $stateBeforeSort);
+  }
+
   // function to fill basic search detail
   /**
    * @param $firstName