From e3ae42f39bac09adecdf3a761a9fd991ab4742a1 Mon Sep 17 00:00:00 2001 From: Ravish Nair Date: Mon, 18 Mar 2013 20:17:48 +0530 Subject: [PATCH] -- webtest fixes and improvement --- .../WebTest/Import/AddressImportTest.php | 18 ++++++++--------- .../WebTest/Import/MatchExternalIdTest.php | 8 +++----- .../WebTest/Import/ParticipantTest.php | 11 ++++------ .../Report/RolePermissionReportTest.php | 20 +++++++++---------- 4 files changed, 26 insertions(+), 31 deletions(-) diff --git a/tests/phpunit/WebTest/Import/AddressImportTest.php b/tests/phpunit/WebTest/Import/AddressImportTest.php index dc92be3973..cc2e8d33e8 100644 --- a/tests/phpunit/WebTest/Import/AddressImportTest.php +++ b/tests/phpunit/WebTest/Import/AddressImportTest.php @@ -68,7 +68,7 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { foreach($customDataParams['customFields'] as $key => $value){ $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-summary-row']/div[@class='crm-label'][contains(text(), '$key')]")); - $this->assertTrue($this->isTextPresent("$value")); + $this->assertElementContainsText('address-block-1', "$value"); } } @@ -110,7 +110,7 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { function _addCustomData() { // Go directly to the URL of the screen that you will be testing (New Custom Group). - $this->open($this->sboxPath . "civicrm/admin/custom/group?reset=1"); + $this->openCiviPage('admin/custom/group', 'reset=1'); //add new custom data $this->click("//a[@id='newCustomDataGroup']/span"); @@ -129,7 +129,7 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { $this->waitForElementPresent('_qf_Field_cancel-bottom'); //Is custom group created? - $this->assertTrue($this->isTextPresent("Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.")); + $this->assertElementContainsText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now."); $url = explode('gid=', $this->getLocation()); $gid = $url[1]; @@ -141,7 +141,7 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { $this->click('_qf_Field_next-bottom'); $this->waitForElementPresent('newCustomField'); - $this->assertTrue($this->isTextPresent("Your custom field '{$customField}' has been saved.")); + $this->assertElementContainsText('crm-notification-container',"Your custom field '{$customField}' has been saved."); $customFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField']/../../td[8]/span/a@href")); $customFieldId = $customFieldId[1]; @@ -155,7 +155,7 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { // clicking save $this->click('_qf_Field_next-bottom'); $this->waitForElementPresent('newCustomField'); - $this->assertTrue($this->isTextPresent("Your custom field '{$customField1}' has been saved.")); + $this->assertElementContainsText('crm-notification-container', "Your custom field '{$customField1}' has been saved."); $customFieldId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField1']/../../td[8]/span/a@href")); $customFieldId1 = $customFieldId1[1]; @@ -170,7 +170,7 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { // clicking save $this->click('_qf_Field_next-bottom'); $this->waitForElementPresent('newCustomField'); - $this->assertTrue($this->isTextPresent("Your custom field '{$customField2}' has been saved.")); + $this->assertElementContainsText('crm-notification-container', "Your custom field '{$customField2}' has been saved."); $customFieldId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField2']/../../td[8]/span/a@href")); $customFieldId2 = $customFieldId2[1]; @@ -220,7 +220,7 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { // clicking save $this->click('_qf_Field_next-bottom'); $this->waitForElementPresent('newCustomField'); - $this->assertTrue($this->isTextPresent("Your custom field '{$customField9}' has been saved.")); + $this->assertElementContainsText('crm-notification-container', "Your custom field '{$customField9}' has been saved."); $customFieldId9 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField9']/../../td[8]/span/a@href")); $customFieldId9 = $customFieldId9[1]; @@ -235,7 +235,7 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { // clicking save $this->click('_qf_Field_next-bottom'); $this->waitForElementPresent('newCustomField'); - $this->assertTrue($this->isTextPresent("Your custom field '{$customField10}' has been saved.")); + $this->assertElementContainsText('crm-notification-container', "Your custom field '{$customField10}' has been saved."); $customFieldId10 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customField10']/../../td[8]/span/a@href")); $customFieldId10 = $customFieldId10[1]; @@ -294,7 +294,7 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { // clicking save $this->click('_qf_Field_next-bottom'); $this->waitForElementPresent('newCustomField'); - $this->assertTrue($this->isTextPresent("Your custom field '{$customFieldName}' has been saved.")); + $this->assertElementContainsText('crm-notification-container', "Your custom field '{$customFieldName}' has been saved."); $customFieldId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr/td/span[text()='$customFieldName']/../../td[8]/span/a@href")); $customFieldId = $customFieldId[1]; return $customFieldId; diff --git a/tests/phpunit/WebTest/Import/MatchExternalIdTest.php b/tests/phpunit/WebTest/Import/MatchExternalIdTest.php index d4faa7d348..2fbb6ccf50 100644 --- a/tests/phpunit/WebTest/Import/MatchExternalIdTest.php +++ b/tests/phpunit/WebTest/Import/MatchExternalIdTest.php @@ -246,7 +246,7 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase { * @return int external id */ function _addContact($firstName, $lastName, $externalId) { - $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual"); + $this->openCiviPage('contact/add', 'reset=1&ct=Individual'); //fill in first name $this->type("first_name", $firstName); @@ -294,9 +294,7 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase { ); } - $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); - - $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); + $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom'); // Let's start filling the form with values. $this->select("event_type_id", "value={$params['event_type_id']}"); @@ -358,7 +356,7 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase { // verify event input on info page // start at Manage Events listing - $this->open($this->sboxPath . "civicrm/event/manage?reset=1"); + $this->openCiviPage('event/manage', 'reset=1'); $this->type("xpath=//div[@class='crm-block crm-form-block crm-event-searchevent-form-block']/table/tbody/tr/td/input",$params['title']); $this->click("_qf_SearchEvent_refresh"); $this->waitForPageToLoad($this->getTimeoutMsec()); diff --git a/tests/phpunit/WebTest/Import/ParticipantTest.php b/tests/phpunit/WebTest/Import/ParticipantTest.php index a55a3b9b9b..a3d144fa5b 100644 --- a/tests/phpunit/WebTest/Import/ParticipantTest.php +++ b/tests/phpunit/WebTest/Import/ParticipantTest.php @@ -271,9 +271,7 @@ class WebTest_Import_ParticipantTest extends ImportCiviSeleniumTestCase { ); } - $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); - - $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); + $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom'); // Let's start filling the form with values. $this->select("event_type_id", "value={$params['event_type_id']}"); @@ -305,10 +303,9 @@ class WebTest_Import_ParticipantTest extends ImportCiviSeleniumTestCase { // select newly created processor $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]"; - $this->assertTrue($this->isTextPresent($processorName)); + $this->assertElementContainsText('paymentProcessor', $processorName); $this->check($xpath); - - $this->select("financial_type_id", "value=4"); + $this->select("financial_type_id", "value=4"); $counter = 1; foreach ($params['fee_level'] as $label => $amount) { @@ -340,7 +337,7 @@ class WebTest_Import_ParticipantTest extends ImportCiviSeleniumTestCase { // verify event input on info page // start at Manage Events listing - $this->open($this->sboxPath . "civicrm/event/manage?reset=1"); + $this->openCiviPage('event/manage', 'reset=1'); $this->click("link=" . $params['title']); $this->waitForPageToLoad($this->getTimeoutMsec()); diff --git a/tests/phpunit/WebTest/Report/RolePermissionReportTest.php b/tests/phpunit/WebTest/Report/RolePermissionReportTest.php index 6f70183cef..17b36d3d71 100644 --- a/tests/phpunit/WebTest/Report/RolePermissionReportTest.php +++ b/tests/phpunit/WebTest/Report/RolePermissionReportTest.php @@ -92,7 +92,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { $this->click("add"); $this->click("_qf_Summary_submit_save"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->openCiviPage('logout','reset=1'); + $this->openCiviPage('logout', 'reset=1', NULL); $this->open($this->sboxPath); $this->waitForElementPresent('edit-submit'); $this->type('edit-name', $user2); @@ -102,7 +102,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { $this->openCiviPage('report/instance/1', 'reset=1'); $this->assertElementContainsText('crm-container', 'You do not have permission to access this report.'); $this->openCiviPage('report/list', 'reset=1'); - $this->openCiviPage('logout', 'reset=1'); + $this->openCiviPage('logout', 'reset=1', NULL); //delete roles $this->webtestLogin(TRUE); @@ -155,7 +155,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { ); $this->changePermissions($permissions); - $this->openCiviPage('logout', 'reset=1'); + $this->openCiviPage('logout', 'reset=1', NULL); $this->open($this->sboxPath); $this->waitForElementPresent('edit-submit'); $this->type('edit-name', $user); @@ -167,7 +167,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { //check if the reserved report field is frozen $this->assertTrue($this->isElementPresent("xpath=//div[@id='instanceForm']//table[3]/tbody//tr/td[2]/tt[text()='[ ]']")); - $this->openCiviPage('logout', 'reset=1'); + $this->openCiviPage('logout', 'reset=1', NULL); $this->open($this->sboxPath); $this->webtestLogin(TRUE); // let's give full CiviReport permissions. @@ -187,7 +187,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { $this->click("_qf_Summary_submit_save"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->openCiviPage('logout', 'reset=1'); + $this->openCiviPage('logout', 'reset=1', NULL); $this->open($this->sboxPath); $this->waitForElementPresent('edit-submit'); $this->type('edit-name', $user); @@ -201,7 +201,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { $this->assertTrue($this->isElementPresent("xpath=//form[@id='Summary']//div[@id='instanceForm']/table//input[@id='title']")); //login as admin and remove reserved permission - $this->openCiviPage('logout', 'reset=1'); + $this->openCiviPage('logout', 'reset=1', NULL); $this->open($this->sboxPath); $this->webtestLogin(TRUE); $this->open($this->sboxPath . "admin/people/permissions"); @@ -216,7 +216,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //login as user and check for absence of report criteria and settings - $this->openCiviPage('logout', 'reset=1'); + $this->openCiviPage('logout', 'reset=1', NULL); $this->open($this->sboxPath); $this->waitForElementPresent('edit-submit'); $this->type('edit-name', $user); @@ -235,7 +235,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { $this->assertFalse($this->isElementPresent("xpath=//form[@id='Summary']//div[@id='instanceForm']//input[@id='title']")); //login as admin and turn the is_reserved flag off for the instance - $this->openCiviPage('logout', 'reset=1'); + $this->openCiviPage('logout', 'reset=1', NULL); $this->open($this->sboxPath); $this->webtestLogin(TRUE); $this->openCiviPage('report/instance/1', 'reset=1'); @@ -243,7 +243,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { $this->click("_qf_Summary_submit_save"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->openCiviPage('logout', 'reset=1'); + $this->openCiviPage('logout', 'reset=1', NULL); $this->open($this->sboxPath); $this->waitForElementPresent('edit-submit'); $this->type('edit-name', $user); @@ -256,7 +256,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { $this->assertTrue($this->isElementPresent("xpath=//form[@id='Summary']//div[@id='instanceForm']//input[@id='title']")); //login as admin and delete the role - $this->openCiviPage('logout', 'reset=1'); + $this->openCiviPage('logout', 'reset=1', NULL); $this->open($this->sboxPath); $this->webtestLogin(TRUE); $this->open($this->sboxPath . "admin/people/permissions/roles"); -- 2.25.1