Merge remote-tracking branch 'upstream/4.3' into 4.3-master-2013-08-28-20-20-34
[civicrm-core.git] / tests / phpunit / WebTest / Export / ContactTest.php
index 268ae3070a8b8cec744ba4123b2857f5c136cdf1..2178788173ce7b49c0d26229ebd6a8c9d8be3705 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -24,7 +24,6 @@
  +--------------------------------------------------------------------+
 */
 
-
 require_once 'WebTest/Export/ExportCiviSeleniumTestCase.php';
 class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase {
 
@@ -36,13 +35,6 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase {
    *  Test Contact Export.
    */
   function testContactExport() {
-    $this->open($this->sboxPath);
-
-    // Logging in. Remember to wait for page to load. In most cases,
-    // you can rely on 30000 as the value that allows your test to pass, however,
-    // sometimes your test might fail because of this. In such cases, it's better to pick one element
-    // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
-    // page contents loaded and you can continue your test execution.
     $this->webtestLogin();
 
     // Create new  group
@@ -90,8 +82,7 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // Visit contact search page.
-    $this->open($this->sboxPath . "civicrm/contact/search?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage("contact/search", "reset=1");
 
     // Select contact type as Indiividual.
     $this->select("contact_type", "value=Individual");
@@ -104,10 +95,10 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // Is contact present in search result?
-    $this->assertTrue($this->isTextPresent("$sortName"), "Contact did not found in search result!");
+    $this->assertElementContainsText('css=div.crm-search-results', $sortName, "Contact did not found in search result!");
 
     // Is contact present in search result?
-    $this->assertTrue($this->isTextPresent("$childSortName"), "Contact did not found in search result!");
+    $this->assertElementContainsText('css=div.crm-search-results', $childSortName, "Contact did not found in search result!");
 
     // select to export all the contasct from search result.
     $this->click("CIVICRM_QFID_ts_all_4");
@@ -156,13 +147,6 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase {
   }
 
   function testMergeHousehold() {
-    $this->open($this->sboxPath);
-
-    // Logging in. Remember to wait for page to load. In most cases,
-    // you can rely on 30000 as the value that allows your test to pass, however,
-    // sometimes your test might fail because of this. In such cases, it's better to pick one element
-    // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
-    // page contents loaded and you can continue your test execution.
     $this->webtestLogin();
 
     // Create new  group
@@ -173,7 +157,7 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase {
     // We're using Quick Add block on the main page for this.
     $houseHold = 'H' . substr(sha1(rand()), 0, 5) . ' House';
 
-    $this->open($this->sboxPath . 'civicrm/contact/add?reset=1&ct=Household');
+    $this->openCiviPage("contact/add", "reset=1&ct=Household");
     $this->click('household_name');
     $this->type('household_name', $houseHold);
 
@@ -186,7 +170,7 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase {
     $this->type("address_1_street_address", "121A Sherman St. Apt. 12");
     $this->type("address_1_city", "Dumfries");
     $this->type("address_1_postal_code", "1234");
-    $this->assertTrue($this->isTextPresent("- select - United States"));
+    $this->assertElementContainsText('address_1', "- select - United States");
     $this->select("address_1_state_province_id", "value=1019");
 
     $this->click('_qf_Contact_upload_view');
@@ -202,7 +186,6 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase {
     $this->click("_qf_GroupContact_next");
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
-
     $firstName1 = 'aa' . substr(sha1(rand()), 0, 5);
     $this->webtestAddContact($firstName1, "Smith", "{$firstName1}.smith@example.org");
 
@@ -221,8 +204,7 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase {
 
     $firstName2 = 'bb' . substr(sha1(rand()), 0, 5);
 
-    $this->open($this->sboxPath . 'civicrm/contact/add?reset=1&ct=Individual');
-    $this->waitForElementPresent('_qf_Contact_upload_view-bottom');
+    $this->openCiviPage("contact/add", "reset=1&ct=Individual", "_qf_Contact_upload_view-bottom");
     $this->type('first_name', $firstName2);
     $this->type('last_name', "Smith");
     $this->type('email_1_email', "{$firstName2}.smith@example.org");
@@ -254,8 +236,7 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase {
     $this->click("_qf_GroupContact_next");
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
-    $this->open($this->sboxPath . "civicrm/contact/search?reset=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage("contact/search", "reset=1", NULL);
 
     // Select group.
     $this->select("group", "label=$groupName");
@@ -265,13 +246,13 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // Is contact present in search result?
-    $this->assertTrue($this->isTextPresent("$sortName1"), "Contact did not found in search result!");
+    $this->assertElementContainsText('css=div.crm-search-results', $sortName1, "Contact did not found in search result!");
 
     // Is contact present in search result?
-    $this->assertTrue($this->isTextPresent("$sortName2"), "Contact did not found in search result!");
+    $this->assertElementContainsText('css=div.crm-search-results', $sortName2, "Contact did not found in search result!");
 
     // Is contact present in search result?
-    $this->assertTrue($this->isTextPresent("$houseHold"), "Contact did not found in search result!");
+    $this->assertElementContainsText('css=div.crm-search-results', $houseHold, "Contact did not found in search result!");
 
     // select to export all the contasct from search result.
     $this->click("CIVICRM_QFID_ts_all_4");
@@ -319,11 +300,7 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase {
   }
 
   function addContactGroup($groupName = 'New Group', $parentGroupName = "- select -") {
-    $this->open($this->sboxPath . "civicrm/group/add?reset=1");
-
-    // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit
-    // button at the end of this page to show up, to make sure it's fully loaded.
-    $this->waitForElementPresent("_qf_Edit_upload");
+    $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
 
     // Fill group name.
     $this->type("title", $groupName);
@@ -348,7 +325,6 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // Is status message correct?
-    $this->assertTrue($this->isTextPresent("The Group '$groupName' has been saved."));
+    $this->waitForText('crm-notification-container', "The Group '$groupName' has been saved.");
   }
 }
-