From 6936953193436df55f88ac0500a43ef6afbde04f Mon Sep 17 00:00:00 2001 From: Ravish Nair Date: Tue, 5 Mar 2013 16:11:47 +0530 Subject: [PATCH] -- webtest fixes and improvement --- tests/phpunit/WebTest/Contact/AddTest.php | 4 +-- .../phpunit/WebTest/Contact/SignatureTest.php | 9 ++---- .../Contact/TaskActionAddToGroupTest.php | 11 ++++--- .../WebTest/Member/StandaloneAddTest.php | 31 +++++++------------ 4 files changed, 22 insertions(+), 33 deletions(-) diff --git a/tests/phpunit/WebTest/Contact/AddTest.php b/tests/phpunit/WebTest/Contact/AddTest.php index 507085fd26..acb29300d3 100644 --- a/tests/phpunit/WebTest/Contact/AddTest.php +++ b/tests/phpunit/WebTest/Contact/AddTest.php @@ -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 diff --git a/tests/phpunit/WebTest/Contact/SignatureTest.php b/tests/phpunit/WebTest/Contact/SignatureTest.php index 5adfe72142..c2a567c76a 100644 --- a/tests/phpunit/WebTest/Contact/SignatureTest.php +++ b/tests/phpunit/WebTest/Contact/SignatureTest.php @@ -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'); diff --git a/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php b/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php index 667d740a80..76b2447daf 100644 --- a/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php +++ b/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php @@ -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); diff --git a/tests/phpunit/WebTest/Member/StandaloneAddTest.php b/tests/phpunit/WebTest/Member/StandaloneAddTest.php index 70f188a53f..eb399f5025 100644 --- a/tests/phpunit/WebTest/Member/StandaloneAddTest.php +++ b/tests/phpunit/WebTest/Member/StandaloneAddTest.php @@ -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); } } -- 2.25.1