Merge pull request #2975 from atif-shaikh/WebTextFix
[civicrm-core.git] / tests / phpunit / WebTest / Import / DuplicateMatchingTest.php
index b76c18e40d147272dc32dae360d81173f59321ad..a5c4f6aba9395bc007db00fb2f79a4de8bf2ecb1 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -24,7 +24,6 @@
  +--------------------------------------------------------------------+
 */
 
-
 require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
 class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase {
 
@@ -36,21 +35,9 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase {
    *  Test contact import for Individuals Duplicate Matching.
    */
   function testIndividualDuplicateMatchingImport() {
-    // This is the path where our testing install resides.
-    // The rest of URL is defined in CiviSeleniumTestCase base class, in
-    // class attributes.
-    $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();
 
-    // Go directly to the URL of New Individual.
-    $this->open($this->sboxPath . 'civicrm/contact/add?reset=1&ct=Individual');
-    $this->waitForElementPresent('first_name');
+    $this->openCiviPage("contact/add", "reset=1&ct=Individual", 'first_name');
 
     $email = substr(sha1(rand()), 0, 7) . '@example.com';
 
@@ -68,7 +55,7 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase {
     // Clicking save.
     $this->click('_qf_Contact_upload_view');
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->assertElementContainsText('crm-notification-container', "Contact Saved");
+    $this->waitForText('crm-notification-container', "Contact Saved");
 
     $existingContact = array(
       'first_name' => $firstName,
@@ -132,8 +119,7 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase {
     $this->importContacts($fillHeaders, $fillRows, 'Individual', 'Fill');
 
     foreach ($importedContactIds as $cid) {
-      $this->open($this->sboxPath . "civicrm/contact/view?reset=1&cid={$cid}");
-      $this->waitForPageToLoad($this->getTimeoutMsec());
+      $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
 
       // Check old display name.
       $displayName = "{$updateRows[$cid]['first_name']} {$updateRows[$cid]['last_name']}";
@@ -150,21 +136,10 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase {
    *  Test contact import for Organization Duplicate Matching.
    */
   function testOrganizationDuplicateMatchingImport() {
-    // This is the path where our testing install resides.
-    // The rest of URL is defined in CiviSeleniumTestCase base class, in
-    // class attributes.
-    $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 oranization
-    $this->open($this->sboxPath . 'civicrm/contact/add?reset=1&ct=Organization');
-    $this->waitForElementPresent('organization_name');
+    $this->openCiviPage("contact/add", "reset=1&ct=Organization", 'organization_name');
 
     // get value for organization contact
     $organizationName = 'org_' . substr(sha1(rand()), 0, 7);
@@ -200,7 +175,6 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase {
     // Get imported contact Ids
     $importedContactIds = $this->_getImportedContactIds($rows, 'Organization');
 
-
     // Build update mode import headers
     $updateHeaders = array(
       'email' => 'Email',
@@ -241,8 +215,7 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase {
     $this->importContacts($fillHeaders, $fillRows, 'Organization', 'Fill');
 
     foreach ($importedContactIds as $cid) {
-      $this->open($this->sboxPath . "civicrm/contact/view?reset=1&cid={$cid}");
-      $this->waitForPageToLoad($this->getTimeoutMsec());
+      $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
 
       // Check old Organization name.
       $organizationName = $updateRows[$cid]['organization_name'];
@@ -258,21 +231,10 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase {
    *  Test contact import for Household Duplicate Matching.
    */
   function testHouseholdDuplicateMatchingImport() {
-    // This is the path where our testing install resides.
-    // The rest of URL is defined in CiviSeleniumTestCase base class, in
-    // class attributes.
-    $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 household
-    $this->open($this->sboxPath . 'civicrm/contact/add?reset=1&ct=Household');
-    $this->waitForElementPresent('household_name');
+    $this->openCiviPage("contact/add", "reset=1&ct=Household", 'household_name');
 
     // get values for household contact
     $householdName = 'household_' . substr(sha1(rand()), 0, 7);
@@ -349,8 +311,7 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase {
     $this->importContacts($fillHeaders, $fillRows, 'Household', 'Fill');
 
     foreach ($importedContactIds as $cid) {
-      $this->open($this->sboxPath . "civicrm/contact/view?reset=1&cid={$cid}");
-      $this->waitForPageToLoad($this->getTimeoutMsec());
+      $this->openCiviPage("contact/view", "reset=1&cid={$cid}");
 
       // Check old Household name.
       $householdName = $updateRows[$cid]['household_name'];