-- webtest fixes and improvement
authorRavish Nair <ravish@ravish.(none)>
Tue, 5 Mar 2013 10:41:47 +0000 (16:11 +0530)
committerRavish Nair <ravish@ravish.(none)>
Tue, 5 Mar 2013 10:41:47 +0000 (16:11 +0530)
tests/phpunit/WebTest/Contact/AddTest.php
tests/phpunit/WebTest/Contact/SignatureTest.php
tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php
tests/phpunit/WebTest/Member/StandaloneAddTest.php

index 507085fd2686ff0c071bef3e724257ac1873c942..acb29300d369d01d6afb660be8e72da07af3437d 100644 (file)
@@ -39,7 +39,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->WebtestAddGroup();
 
     // go to display preferences to enable Open ID field
-    $this->openCiviPage('admin/setting/preferences/display'. "reset=1", "_qf_Display_next-bottom");
+    $this->openCiviPage('admin/setting/preferences/display', "reset=1", "_qf_Display_next-bottom");
     $this->check("xpath=//ul[@id='contactEditBlocks']//li/span[2]/label[text()='Open ID']/../input");
     $this->click("_qf_Display_next-bottom");
     $this->waitForPageToLoad($this->getTimeoutMsec());
@@ -378,7 +378,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase {
     $this->webtestLogin();
 
     // Go directly to the URL of the screen that you will be testing (New Individual).
-    $this->openCiviPage('civicrm/contact/add', "reset=1&ct=Individual");
+    $this->openCiviPage('contact/add', "reset=1&ct=Individual");
 
     //contact details section
     //select prefix
index 5adfe72142ee518b43f58206043e344df352e4f0..c2a567c76aad5ac77589b5e56f3989a8c5f3d5ea 100644 (file)
@@ -107,9 +107,7 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase {
     // Select Your Editor
     $this->_selectEditor('CKEditor');
 
-    $this->open($this->sboxPath . "civicrm/contact/add?reset=1&action=update&cid={$contactId}");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-
+    $this->openCiviPage("contact/add", "reset=1&action=update&cid={$contactId}");
     $this->click("//tr[@id='Email_Block_1']/td[1]/div[2]/div[1]");
     
     // HTML format message
@@ -123,7 +121,7 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // Is status message correct?
-    $this->assertTrue($this->isTextPresent("{$name} has been updated."));
+    $this->assertElementContainsText("crm-notification-container", "{$name} has been updated.");
 
     // Go for Ckeck Your Editor, Click on Send Mail
     $this->click("//a[@id='crm-contact-actions-link']/span");
@@ -150,8 +148,7 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase {
    */
   function _selectEditor($editor) {
     // Go directly to the URL of Set Default Editor.
-    $this->open($this->sboxPath . 'civicrm/admin/setting/preferences/display?reset=1');
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->openCiviPage('admin/setting/preferences/display', 'reset=1');
 
     // Select your Editor
     $this->click('editor_id');
index 667d740a801d409b54f8cfce4863d23714040b3d..76b2447daf5a610580d8c4359897606c1c9ff86a 100644 (file)
@@ -34,7 +34,7 @@ class WebTest_Contact_TaskActionAddToGroupTest extends CiviSeleniumTestCase {
 
   function testAddContactsToGroup() {
 
-    // Create a new group with a random name; included test provides login
+    $this->webtestLogin();
     $newGroupName = 'Group_' . substr(sha1(rand()), 0, 7);
     $this->WebtestAddGroup($newGroupName);
 
@@ -81,8 +81,8 @@ class WebTest_Contact_TaskActionAddToGroupTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // Check status messages are as expected
-    $this->assertTrue($this->isTextPresent("Added Contacts to {$newGroupName}"));
-    $this->assertTrue($this->isTextPresent("2 contacts added to group "));
+    $this->assertElementContainsText('crm-notification-container', "Added Contacts to {$newGroupName}");
+    $this->assertElementContainsText('crm-notification-container', "2 contacts added to group");
 
     // Search by group membership in newly created group
     $this->openCiviPage('contact/search/advanced', 'reset=1');
@@ -103,6 +103,7 @@ class WebTest_Contact_TaskActionAddToGroupTest extends CiviSeleniumTestCase {
   }
 
   function testMultiplePageContactSearchAddContactsToGroup() {
+    $this->webtestLogin();
     $newGroupName = 'Group_' . substr(sha1(rand()), 0, 7);
     $this->WebtestAddGroup($newGroupName);
 
@@ -127,8 +128,8 @@ class WebTest_Contact_TaskActionAddToGroupTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // Check status messages are as expected
-    $this->assertTrue($this->isTextPresent("Added Contacts to {$newGroupName}"));
-    $this->assertTrue($this->isTextPresent("50 contacts added to group"));
+    $this->assertElementContainsText('crm-notification-container', "Added Contacts to {$newGroupName}");
+    $this->assertElementContainsText('crm-notification-container', "50 contacts added to group");
 
     $this->openCiviPage('contact/search/advanced', 'reset=1');
     $this->select("crmasmSelect1", "label=" . $newGroupName);
index 70f188a53fd7bfba5d5278996d49c67e3466fde7..eb399f5025c1cf7e93a1d5b4ad741000ca5d1c89 100644 (file)
@@ -34,7 +34,6 @@ class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase {
 
   function testStandaloneMemberAdd() {
 
-    $this->open($this->sboxPath);
     $this->webtestLogin();
 
     // create contact
@@ -46,9 +45,7 @@ class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase {
     $membershipTypes = $this->webtestAddMembershipType();
 
     // now add membership
-    $this->open($this->sboxPath . "civicrm/member/add?reset=1&action=add&context=standalone");
-
-    $this->waitForElementPresent("_qf_Membership_upload");
+    $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
 
     // select contact
     $this->webtestFillAutocomplete($firstName);
@@ -78,19 +75,17 @@ class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase {
     $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
     $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']");
     $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
+
     $expected = array(
-      2 => $membershipTypes['membership_type'],
-      3 => 'New',
-      4 => 'Membership StandaloneAddTest Webtest',
+      'Membership Type' => $membershipTypes['membership_type'],
+      'Status' => 'New',
+      'Source' => 'Membership StandaloneAddTest Webtest',
     );
-    foreach ($expected as $label => $value) {
-      $this->verifyText("xpath=id('MembershipView')/div[2]/div/table[1]/tbody/tr[$label]/td[2]", preg_quote($value));
-    }
+    $this->webtestVerifyTabularData($expected);
   }
 
   function testStandaloneMemberOverrideAdd() {
 
-    $this->open($this->sboxPath);
     $this->webtestLogin();
 
     // add contact
@@ -102,9 +97,7 @@ class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase {
     $membershipTypes = $this->webtestAddMembershipType();
 
     // add membership
-    $this->open($this->sboxPath . "civicrm/member/add?reset=1&action=add&context=standalone");
-
-    $this->waitForElementPresent("_qf_Membership_upload");
+    $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
 
     // select contact
     $this->webtestFillAutocomplete($firstName);
@@ -163,13 +156,11 @@ class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase {
     $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
 
     $expected = array(
-      2 => $membershipTypes['membership_type'],
-      3 => 'Grace',
-      4 => 'Membership StandaloneAddTest Webtest',
+      'Membership Type' => $membershipTypes['membership_type'],
+      'Status' => 'Grace',
+      'Source' => 'Membership StandaloneAddTest Webtest',
     );
-    foreach ($expected as $label => $value) {
-      $this->verifyText("xpath=id('MembershipView')/div[2]/div/table[1]/tbody/tr[$label]/td[2]", preg_quote($value));
-    }
+    $this->webtestVerifyTabularData($expected);
   }
 }