webtest fixes 4.6
[civicrm-core.git] / tests / phpunit / WebTest / Contact / AddTest.php
index 58ac49475c8bd63680734d5994cd10a497013962..2774d45fe291303cced1d077c6d199308cdf6560 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
 */
 
 require_once 'CiviTest/CiviSeleniumTestCase.php';
+
+/**
+ * Class WebTest_Contact_AddTest
+ */
 class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
 
   protected function setUp() {
@@ -100,7 +104,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->click("address_1_country_id");
     $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
 
-    if ($this->assertElementContainsText('address_1', "Latitude")) {
+    if ($this->assertElementContainsText('address_table_1', "Latitude")) {
       $this->type("address_1_geo_code_1", "1234");
       $this->type("address_1_geo_code_2", "5678");
     }
@@ -115,7 +119,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->click("address_2_country_id");
     $this->select("address_2_country_id", "value=" . $this->webtestGetValidCountryID());
 
-    if ($this->assertElementContainsText('address_2', "Latitude")) {
+    if ($this->assertElementContainsText('address_table_2', "Latitude")) {
       $this->type("address_2_geo_code_1", "1234");
       $this->type("address_2_geo_code_2", "5678");
     }
@@ -199,7 +203,9 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->select("phone_1_phone_type_id", "value=" . $this->webtestGetFirstValueForOptionGroup('phone_type'));
 
     //fill in IM
-    $this->assertElementContainsText('im_1_provider_id', "Yahoo MSN AIM GTalk Jabber Skype");
+    foreach (array('Yahoo', 'MSN', 'AIM', 'GTalk', 'Jabber', 'Skype') as $option) {
+      $this->assertSelectHasOption('im_1_provider_id', $option);
+    }
     $this->type("im_1_name", "testSkype");
     $this->select("im_1_location_type_id", "value=3");
     $this->select("im_1_provider_id", "value=6");
@@ -231,7 +237,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->click("address_1_country_id");
     $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
 
-    if ($this->assertElementContainsText('address_1', "Latitude")) {
+    if ($this->assertElementContainsText('address_table_1', "Latitude")) {
       $this->type("address_1_geo_code_1", "1234");
       $this->type("address_1_geo_code_2", "5678");
     }
@@ -340,7 +346,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->click("address_1_country_id");
     $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID());
 
-    if ($this->assertElementContainsText('address_1', "Latitude")) {
+    if ($this->assertElementContainsText('address_table_1', "Latitude")) {
       $this->type("address_1_geo_code_1", "1234");
       $this->type("address_1_geo_code_2", "5678");
     }
@@ -403,7 +409,6 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     //create new current employer
     $currentEmployer = substr(sha1(rand()), 0, 7) . "Web Access";
 
-    $this->type('current_employer', $currentEmployer);
 
     //fill in email
     $this->type("email_1_email", substr(sha1(rand()), 0, 7) . "john@gmail.com");
@@ -423,10 +428,11 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->click('address[1][use_shared_address]');
 
     // create new organization with dialog
-    $this->select("profiles_1", "label=New Organization");
+    $this->clickAt("xpath=//div[@id='s2id_address_1_master_contact_id']/a");
+    $this->click("xpath=//li[@class='select2-no-results']//a[contains(text(),' New Organization')]");
 
     // create new contact using dialog
-    $this->waitForElementPresent("css=div#contact-dialog-1");
+    $this->waitForElementPresent("css=div#crm-profile-block");
     $this->waitForElementPresent("_qf_Edit_next");
 
     $this->type('organization_name', $currentEmployer);
@@ -434,11 +440,13 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->type("email-Primary", "john@gmail.com" . substr(sha1(rand()), 0, 7));
     $this->type('city-1', 'Dumfries');
     $this->type('postal_code-1', '1234');
+    $this->select('state_province-1', 'value=1001');
 
     $this->click("_qf_Edit_next");
 
     // Is new contact created?
-    $this->waitForText('crm-notification-container', "$currentEmployer has been created.");
+    $this->waitForText("css=div.crm-status-box-msg", "$currentEmployer Created");
+    $this->select2('employer_id', $currentEmployer);
 
     //make sure shared address is selected
     $this->waitForElementPresent('selected_shared_address-1');
@@ -452,10 +460,11 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->click('address[2][use_shared_address]');
 
     // create new household with dialog
-    $this->select('profiles_2', "label=New Household");
+    $this->clickAt("xpath=//div[@id='s2id_address_2_master_contact_id']/a");
+    $this->click("xpath=//li[@class='select2-no-results']//a[contains(text(),' New Household')]");
 
     // create new contact using dialog
-    $this->waitForElementPresent("css=div#contact-dialog-2");
+    $this->waitForElementPresent("css=div#crm-profile-block");
     $this->waitForElementPresent("_qf_Edit_next");
 
     $sharedHousehold = substr(sha1(rand()), 0, 7) . 'Smith Household';
@@ -464,11 +473,12 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->type("email-Primary", substr(sha1(rand()), 0, 7) . "john@gmail.com");
     $this->type('city-1', 'Birmingham');
     $this->type('postal_code-1', '3456');
+    $this->select('state_province-1', 'value=1001');
 
     $this->click("_qf_Edit_next");
 
     // Is new contact created?
-    $this->waitForText('crm-notification-container', "$sharedHousehold has been created.");
+    $this->waitForText("css=div.crm-status-box-msg", "$sharedHousehold Created");
 
     //make sure shared address is selected
     $this->waitForElementPresent('selected_shared_address-2');
@@ -490,8 +500,8 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     // make sure relationships are created
     $this->click("xpath=id('tab_rel')/a");
     $this->waitForElementPresent('permission-legend');
-    $this->assertElementContainsText('option11', 'Employee of');
-    $this->assertElementContainsText('option11', 'Household Member of');
+    $this->assertElementContainsText('DataTables_Table_0', 'Employee of');
+    $this->assertElementContainsText('DataTables_Table_0', 'Household Member of');
   }
 }