Merge remote-tracking branch 'origin/abtest' into master-abtest
[civicrm-core.git] / tests / phpunit / WebTest / Import / ContactCustomDataTest.php
index ee6f87fd1f3860dd8de1ae1454f27092cc556adf..7f9c2e7e0d2184995326d2a1ae583ff9703e2bc9 100644 (file)
 */
 
 require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
+
+/**
+ * Class WebTest_Import_ContactCustomDataTest
+ */
 class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase {
 
   protected function setUp() {
@@ -45,13 +49,13 @@ class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase {
     $this->click("xpath=//div[@id='browseValues_Individual']/div[2]/a/span");
     $this->waitForElementPresent('_qf_DedupeRules_next-bottom');
     $this->type('title', $newRuleTitle);
-    $this->click("CIVICRM_QFID_1_used");
+    $this->click("CIVICRM_QFID_Supervised_used");
     $this->select("where_0", "label=$customDataParams[1]");
     $this->type('weight_0', '10');
     $this->type('threshold', '10');
     $this->click('_qf_DedupeRules_next-bottom');
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->assertTrue($this->isTextPresent("The rule '{$newRuleTitle}' has been saved."));
+    $this->waitForText("crm-notification-container", "The rule '{$newRuleTitle}' has been saved.");
 
     $rgId = explode('&rgid=', $this->getAttribute("xpath=//div[@id='browseValues_Individual']//table/tbody//tr/td[text()='{$newRuleTitle}']/../td[3]/span/a[text()='Use Rule']@href"));
     $rgId = explode('&', $rgId[1]);
@@ -59,7 +63,6 @@ class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase {
     // Add Contact
     $firstName2 = 'An_' . substr(sha1(rand()), 0, 7);
     $this->webtestAddContact($firstName2, "Summerson");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // Edit and expand all tabs
     $this->click('link=Edit');
@@ -94,10 +97,10 @@ class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase {
     $this->typeKeys('css=input#sort_name_navigation', $firstName1);
 
     // Wait for result list.
-    $this->waitForElementPresent("css=div.ac_results-inner li");
+    $this->waitForElementPresent("css=ul.ui-autocomplete li");
 
     // Visit contact summary page.
-    $this->click("css=div.ac_results-inner li");
+    $this->click("css=ul.ui-autocomplete li");
     $this->waitForPageToLoad($this->getTimeoutMsec());
     $this->assertTrue($this->isTextPresent('This is a test field'));
   }
@@ -105,6 +108,12 @@ class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase {
   /*
      *  Helper function to provide data for custom data import.
      */
+  /**
+   * @param $customDataParams
+   * @param $firstName1
+   *
+   * @return array
+   */
   function _individualCustomCSVData($customDataParams, $firstName1) {
     $headers = array(
       'first_name' => 'First Name',
@@ -122,10 +131,18 @@ class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase {
     return array($headers, $rows);
   }
 
+  /**
+   * @param $originalHeaders
+   * @param $originalRows
+   * @param $checkSummary
+   */
   function checkDuplicateContacts($originalHeaders, $originalRows, $checkSummary) {
     $this->assertTrue($this->isTextPresent('CiviCRM has detected one record which is a duplicate of existing CiviCRM contact record. These records have not been imported.'));
   }
 
+  /**
+   * @return array
+   */
   function _addCustomData() {
 
     $this->openCiviPage("admin/custom/group", "reset=1");
@@ -143,11 +160,11 @@ class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase {
     $this->click('extends[0]');
     $this->select('extends[0]', "value=Contact");
     $this->click("//option[@value='Contact']");
-    $this->click('_qf_Group_next-bottom');
-    $this->waitForElementPresent('_qf_Field_cancel-bottom');
+    $this->clickLink('_qf_Group_next-bottom');
 
     //Is custom group created?
     $this->waitForText('crm-notification-container', $customGroupTitle);
+    $this->waitForElementPresent('_qf_Field_cancel-bottom');
     $gid = $this->urlArg('gid');
 
     // create another custom field - Date
@@ -164,10 +181,10 @@ class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase {
     $this->click("is_searchable");
 
     // clicking save
-    $this->click('_qf_Field_next-bottom');
-    $this->waitForElementPresent('newCustomField');
+    $this->click('_qf_Field_done-bottom');
+    $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr/td");
 
-    $this->assertTrue($this->isTextPresent("Your custom field '{$customField}' has been saved."));
+    $this->waitForText('crm-notification-container', "Custom field '{$customField}' has been saved.");
     $customFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField']/../../td[8]/span/a@href"));
     $customFieldId = $customFieldId[1];