From a471a3b61f59b7be7667ae37780e8436cde891dc Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 20 Mar 2013 17:02:06 -0700 Subject: [PATCH] Refactor ad-hoc url parsing to use the new urlArg() method --- .../WebTest/Admin/MoveCustomDataTest.php | 6 +- .../Campaign/SurveyUsageScenarioTest.php | 9 +-- .../WebTest/Case/CaseCustomFieldsTest.php | 3 +- .../AdvancedSearchedRelatedContactTest.php | 4 +- .../Contact/ContactReferenceFieldTest.php | 12 +--- .../Contact/CreateCmsUserFromContactTest.php | 4 +- .../Contact/MultipleContactSubTypes.php | 3 +- .../WebTest/Contact/ProfileChecksumTest.php | 7 +- .../phpunit/WebTest/Contact/SignatureTest.php | 4 +- .../WebTest/Contact/TagSetSearchTest.php | 10 +-- .../Contact/TaskActionAddToGroupTest.php | 3 +- .../WebTest/Contact/UpdateProfileTest.php | 1 + .../WebTest/Contribute/AddPricesetTest.php | 15 ++-- .../Contribute/ContactContextAddTest.php | 2 +- .../Contribute/OfflineContributionTest.php | 1 + .../OfflineRecurContributionTest.php | 1 + .../Contribute/OnBehalfOfOrganization.php | 22 ++---- .../Contribute/UpdateContributionTest.php | 21 ++---- tests/phpunit/WebTest/Event/AddEventTest.php | 3 +- .../phpunit/WebTest/Event/AddPricesetTest.php | 12 ++-- .../WebTest/Event/MultiprofileEventTest.php | 16 ++--- tests/phpunit/WebTest/Event/PCPAddTest.php | 6 +- .../WebTest/Event/PricesetMaxCountTest.php | 70 +++++-------------- .../Financial/FinancialBatchExport.php | 3 +- tests/phpunit/WebTest/Import/ActivityTest.php | 6 +- .../WebTest/Import/AddressImportTest.php | 3 +- .../WebTest/Import/ContactCustomDataTest.php | 5 +- .../phpunit/WebTest/Import/CustomDataTest.php | 8 +-- .../Import/ImportCiviSeleniumTestCase.php | 7 +- .../WebTest/Import/MatchExternalIdTest.php | 8 +-- .../WebTest/Import/ParticipantTest.php | 8 +-- tests/phpunit/WebTest/Mailing/MailingTest.php | 8 +-- tests/phpunit/WebTest/Mailing/SpoolTest.php | 4 +- .../Member/DefaultMembershipPricesetTest.php | 3 +- .../Member/InheritedMembershipTest.php | 4 +- .../Member/OfflineAutoRenewMembershipTest.php | 1 + .../OfflineMembershipAddPricesetTest.php | 6 +- .../OnlineMembershipAddPricesetTest.php | 6 +- .../Member/OnlineMembershipRenewTest.php | 8 +-- .../Member/SeperateMembershipPaymentTest.php | 3 +- .../Profile/MultiRecordProfileAddTest.php | 3 +- tests/phpunit/WebTest/Profile/SearchTest.php | 3 +- .../WebTest/Report/LoggingReportTest.php | 2 +- 43 files changed, 99 insertions(+), 235 deletions(-) diff --git a/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php b/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php index 3af6fa56f2..4e0b46d95c 100644 --- a/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php +++ b/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php @@ -212,11 +212,7 @@ class WebTest_Admin_MoveCustomDataTest extends CiviSeleniumTestCase { //Is custom group created? $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now."); - $url = $this->parseURL(); - $group_id = $url['queryString']['gid']; - $this->assertType('numeric', $group_id); - - return $group_id; + return $this->urlArg('gid'); } //Adds a new custom field to a specfied custom field group, using the given diff --git a/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php b/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php index 72d2bc4e00..63c1e470b6 100644 --- a/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php +++ b/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php @@ -244,8 +244,7 @@ class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase { // add a contact to the group to test release respondents $firstName3 = substr(sha1(rand()), 0, 7); $this->webtestAddContact($firstName3, "James", "$firstName3.james@example.org"); - $url = $this->getLocation(); - $id = explode('cid=', $url); + $id = $this->urlArg('cid'); $sortName3 = "James, $firstName3"; // add contact to group @@ -320,8 +319,7 @@ class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase { // Adding contact $firstName1 = substr(sha1(rand()), 0, 7); $this->webtestAddContact($firstName1, "Smith", "$firstName1.smith@example.org"); - $url1 = explode('cid=', $this->getLocation()); - $id1 = $url1[1]; + $id1 = $this->urlArg('cid'); // add contact to group // visit group tab @@ -335,8 +333,7 @@ class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase { $firstName2 = substr(sha1(rand()), 0, 7); $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org"); - $url2 = explode('cid=', $this->getLocation()); - $id2 = $url2[1]; + $id2 = $this->urlArg('cid'); // add contact to group // visit group tab diff --git a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php index b4d20cad7b..4ec08bf485 100644 --- a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php +++ b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php @@ -54,8 +54,7 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); // get custom group id - $elements = $this->parseURL(); - $customGrpId1 = $elements['queryString']['gid']; + $customGrpId1 = $this->urlArg('gid'); $customId = $this->_testGetCustomFieldId($customGrpId1); $cusId_1 = 'custom_' . $customId[0] . '_-1'; diff --git a/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php b/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php index a780e84285..0136f7e31c 100644 --- a/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php +++ b/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php @@ -289,9 +289,7 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes $firstNameSoft = "John_".substr(sha1(rand()), 0, 5); $lastNameSoft = "Doe_".substr(sha1(rand()), 0, 5); $this->webtestAddContact( $firstNameSoft, $lastNameSoft ); - $url = $this->parseURL( ); - $cid = $url['queryString']['cid']; - $this->assertType('numeric', $cid); + $cid = $this->urlArg('cid'); //advance search for created contacts $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh'); diff --git a/tests/phpunit/WebTest/Contact/ContactReferenceFieldTest.php b/tests/phpunit/WebTest/Contact/ContactReferenceFieldTest.php index 9929cecf2a..a089521fb4 100644 --- a/tests/phpunit/WebTest/Contact/ContactReferenceFieldTest.php +++ b/tests/phpunit/WebTest/Contact/ContactReferenceFieldTest.php @@ -94,9 +94,7 @@ class WebTest_Contact_ContactReferenceFieldTest extends CiviSeleniumTestCase { //Is custom group created? $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now."); - $matches = array(); - preg_match('/gid=([0-9]+)/', $this->getLocation(), $matches); - $customGroupId = $matches[1]; + $customGroupId = $this->urlArg('gid'); // Add contact reference fields $contactRefFieldLabel1 = 'contact_ref_' . substr(sha1(rand()), 0, 4); @@ -138,18 +136,14 @@ class WebTest_Contact_ContactReferenceFieldTest extends CiviSeleniumTestCase { $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[8]/span[1]/a[text()='Edit Field']"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $matches = array(); - preg_match('/&id=([0-9]+)/', $this->getLocation(), $matches); - $contactRefFieldID1 = $matches[1]; + $contactRefFieldID1 = $this->urlArg('id'); $this->openCiviPage('admin/custom/group/field', "reset=1&action=browse&gid={$customGroupId}"); $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/span[1]/a[text()='Edit Field']"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $matches = array(); - preg_match('/&id=([0-9]+)/', $this->getLocation(), $matches); - $contactRefFieldID2 = $matches[1]; + $contactRefFieldID2 = $this->urlArg('id'); // Visit custom group preview page $this->openCiviPage('admin/custom/group', "action=preview&reset=1&id={$customGroupId}"); diff --git a/tests/phpunit/WebTest/Contact/CreateCmsUserFromContactTest.php b/tests/phpunit/WebTest/Contact/CreateCmsUserFromContactTest.php index 78b611f94e..569d51be0a 100644 --- a/tests/phpunit/WebTest/Contact/CreateCmsUserFromContactTest.php +++ b/tests/phpunit/WebTest/Contact/CreateCmsUserFromContactTest.php @@ -212,9 +212,7 @@ class WebTest_Contact_CreateCmsUserFromContactTest extends CiviSeleniumTestCase $email = $this->webtestAddContact($firstName, $lastName, TRUE); // Get the contact id of the new contact - $contactUrl = $this->parseURL(); - $cid = $contactUrl['queryString']['cid']; - $this->assertType('numeric', $cid); + $cid = $this->urlArg('cid'); //got to the new cms user form $this->openCiviPage('contact/view/useradd', "reset=1&action=add&cid={$cid}"); diff --git a/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php b/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php index 0f727a945c..e1189771d2 100644 --- a/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php +++ b/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php @@ -237,8 +237,7 @@ class WebTest_Contact_MultipleContactSubTypes extends CiviSeleniumTestCase { //Is custom group created? $this->assertTrue($this->isTextPresent("Your custom field set '{$customGroupTitle}' has been added.")); - $url = explode('gid=', $this->getLocation()); - $gid = $url[1]; + $gid = $this->urlArg('gid'); $fieldLabel = "custom_field_for_{$contactSubType}" . substr(sha1(rand()), 0, 4); $this->type('label', $fieldLabel); diff --git a/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php b/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php index f1e33f6ad8..85df61c816 100644 --- a/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php +++ b/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php @@ -92,9 +92,7 @@ class WebTest_Contact_ProfileChecksumTest extends CiviSeleniumTestCase { $this->webtestAddContact($fields['first_name']['default_value'], $fields['last_name']['default_value'], $fields['email']['default_value']); // Get contact id from url. - $matches = array(); - preg_match('/cid=([0-9]+)/', $this->getLocation(), $matches); - $contactId = $matches[1]; + $contactId = $this->urlArg('cid'); // Create profile for contact $profileName = "Profile_" . substr(sha1(rand()), 0, 7); @@ -149,8 +147,7 @@ class WebTest_Contact_ProfileChecksumTest extends CiviSeleniumTestCase { $this->type('title', $profileName); $this->click('_qf_Group_next-top'); $this->waitForPageToLoad($this->getTimeoutMsec()); - $elements = $this->parseURL(); - $profileId = $elements['queryString']['gid']; + $profileId = $this->urlArg('gid'); // Add field to the profile. foreach ($fields as $key => $values) { diff --git a/tests/phpunit/WebTest/Contact/SignatureTest.php b/tests/phpunit/WebTest/Contact/SignatureTest.php index f0704b70b2..b0b1969489 100644 --- a/tests/phpunit/WebTest/Contact/SignatureTest.php +++ b/tests/phpunit/WebTest/Contact/SignatureTest.php @@ -98,9 +98,7 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { $name = $this->getText("xpath=//div[@class='crm-summary-display_name']"); // Get contact id from url. - $matches = array(); - preg_match('/cid=([0-9]+)/', $this->getLocation(), $matches); - $contactId = $matches[1]; + $contactId = $this->urlArg('cid'); // Select Your Editor $this->_selectEditor('CKEditor'); diff --git a/tests/phpunit/WebTest/Contact/TagSetSearchTest.php b/tests/phpunit/WebTest/Contact/TagSetSearchTest.php index 3ea97bbb7c..98f9ebc6ea 100644 --- a/tests/phpunit/WebTest/Contact/TagSetSearchTest.php +++ b/tests/phpunit/WebTest/Contact/TagSetSearchTest.php @@ -163,15 +163,9 @@ class WebTest_Contact_TagSetSearchTest extends CiviSeleniumTestCase { // verify text $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']"); - $this->click("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[7]/span/a[text()= 'Edit']"); + $this->clickLink("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[7]/span/a[text()= 'Edit']"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - - // Get contact id from url. - $matches = array(); - preg_match('/id=([0-9]+)/', $this->getLocation(), $matches); - - return $matches[1]; + return $this->urlArg('id'); } } diff --git a/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php b/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php index 7f744157fa..5577a4506c 100644 --- a/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php +++ b/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php @@ -45,8 +45,7 @@ class WebTest_Contact_TaskActionAddToGroupTest extends CiviSeleniumTestCase { $this->webtestAddContact(); // get cid of new contact - $queryParams = $this->parseURL(); - $cids[] = $queryParams['queryString']['cid']; + $cids[] = $this->urlArg('cid'); // update email of new contact $this->click("//ul[@id='actions']/li/a/span[text()='Edit']"); diff --git a/tests/phpunit/WebTest/Contact/UpdateProfileTest.php b/tests/phpunit/WebTest/Contact/UpdateProfileTest.php index 920d7f4977..f3609bca88 100644 --- a/tests/phpunit/WebTest/Contact/UpdateProfileTest.php +++ b/tests/phpunit/WebTest/Contact/UpdateProfileTest.php @@ -40,6 +40,7 @@ class WebTest_Contact_UpdateProfileTest extends CiviSeleniumTestCase { $locationUrl = $this->getLocation(); $editUrl = str_replace('/view?', '/edit?', $locationUrl); $this->open($editUrl); + $this->waitForPageToLoad($this->getTimeoutMsec()); // Modify profile field values // contact details section diff --git a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php index 7887c98833..3b29dd659b 100644 --- a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php +++ b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php @@ -46,8 +46,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form // which is where we are after adding Price Set. - $elements = $this->parseURL(); - $sid = $elements['queryString']['sid']; + $sid = $this->urlArg('sid'); $this->assertType('numeric', $sid); $validStrings = array(); @@ -244,8 +243,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form // which is where we are after adding Price Set. - $elements = $this->parseURL(); - $sid = $elements['queryString']['sid']; + $sid = $this->urlArg('sid'); $this->assertType('numeric', $sid); $validStrings = array(); @@ -346,8 +344,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form // which is where we are after adding Price Set. - $elements = $this->parseURL(); - $sid = $elements['queryString']['sid']; + $sid = $this->urlArg('sid'); $this->assertType('numeric', $sid); $validStrings = array(); @@ -469,8 +466,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form // which is where we are after adding Price Set. - $elements = $this->parseURL(); - $sid = $elements['queryString']['sid']; + $sid = $this->urlArg('sid'); $this->assertType('numeric', $sid); $validStrings = array(); @@ -592,8 +588,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form // which is where we are after adding Price Set. - $elements = $this->parseURL(); - $sid = $elements['queryString']['sid']; + $sid = $this->urlArg('sid'); $this->assertType('numeric', $sid); $validStrings = array(); diff --git a/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php b/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php index 46b1fbe7a5..b187b2e503 100644 --- a/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php +++ b/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php @@ -72,7 +72,7 @@ class WebTest_Contribute_ContactContextAddTest extends CiviSeleniumTestCase { $isDefault ); - $this->webtestAddContact( $firstName, "Anderson", true ); + $this->webtestAddContact($firstName, "Anderson", true); // Get the contact id of the new contact $contactUrl = $this->parseURL(); diff --git a/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php b/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php index 406c39e29e..0e177fb7c7 100644 --- a/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php @@ -301,6 +301,7 @@ class WebTest_Contribute_OfflineContributionTest extends CiviSeleniumTestCase { $url = $this->getLocation(); $url = str_replace('mode=live', 'mode=test', $url); $this->open($url); + $this->waitForPageToLoad($this->getTimeoutMsec()); // start filling out contribution form $this->waitForElementPresent('payment_processor_id'); diff --git a/tests/phpunit/WebTest/Contribute/OfflineRecurContributionTest.php b/tests/phpunit/WebTest/Contribute/OfflineRecurContributionTest.php index e5ad064449..c00efef365 100644 --- a/tests/phpunit/WebTest/Contribute/OfflineRecurContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/OfflineRecurContributionTest.php @@ -55,6 +55,7 @@ class WebTest_Contribute_OfflineRecurContributionTest extends CiviSeleniumTestCa $url = $this->getLocation(); $url = str_replace('mode=live', 'mode=test', $url); $this->open($url); + $this->waitForPageToLoad($this->getTimeoutMsec()); // start filling out contribution form $this->waitForElementPresent('payment_processor_id'); diff --git a/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php b/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php index a7a42b2fde..1e7a06897b 100644 --- a/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php +++ b/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php @@ -47,10 +47,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { //adding contact for membership sign up $this->webtestAddContact($firstName, $lastName, $email); - $urlElements = $this->parseURL(); - print_r($urlElements); - $cid = $urlElements['queryString']['cid']; - $this->assertType('numeric', $cid); + $cid = $this->urlArg('cid'); // We need a payment processor $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); @@ -452,10 +449,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->type("last_name", $lastName); $this->clickLink("_qf_Edit_next", "profilewrap4"); - $urlElements = $this->parseURL(); - print_r($urlElements); - $cid = $urlElements['queryString']['id']; - $this->assertType('numeric', $cid); + $cid = $this->urlArg('id'); // Is status message correct? $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!"); @@ -715,8 +709,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $this->assertTrue($this->isTextPresent("Your custom field '$fieldTitle' has been saved.")); - $url = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']/div[2]/table/tbody//tr/td[1][text()='$fieldTitle']/../td[8]/span/a@href")); - $fieldId = $url[1]; + $fieldId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='field_page']/div[2]/table/tbody//tr/td[1][text()='$fieldTitle']/../td[8]/span/a@href")); // Enable CiviCampaign module if necessary $this->enableComponents("CiviCampaign"); @@ -961,8 +954,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $this->assertTrue($this->isTextPresent("Your custom field '$fieldTitle' has been saved.")); - $url = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']/div[2]/table/tbody//tr/td[1]/span[text()='$fieldTitle']/../td[8]/span/a@href")); - $fieldId = $url[1]; + $fieldId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='field_page']/div[2]/table/tbody//tr/td[1]/span[text()='$fieldTitle']/../td[8]/span/a@href")); // Enable CiviCampaign module if necessary $this->enableComponents("CiviCampaign"); @@ -1119,8 +1111,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->click('_qf_MembershipType_upload-bottom'); $this->waitForElementPresent('link=Add Membership Type'); $this->assertTrue($this->isTextPresent("The membership type '$title1' has been saved.")); - $typeUrl = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[1][text()='{$title1}']/../td[10]/span/a[3]@href")); - $typeId = $typeUrl[1]; + $typeId = $this->urlArg('id', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[1][text()='{$title1}']/../td[10]/span/a[3]@href")); // open contact $this->openCiviPage("contact/view/rel", "cid={$cid}&action=add&reset=1"); @@ -1288,8 +1279,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->type("last_name", $lastName); $this->clickLink("_qf_Edit_next", "profilewrap4"); - $urlElements = $this->parseURL(); - $cid = $urlElements['queryString']['id']; + $cid = $this->urlArg('id'); $this->assertType('numeric', $cid); // Is status message correct? $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!"); diff --git a/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php b/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php index 6818bf2333..5038e657cf 100644 --- a/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php @@ -97,8 +97,7 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $this->_testOfflineContribution($firstName, $lastName, $email, $amount, "Pending"); $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $elements = $this->parseURL(); - $contId = $elements['queryString']['id']; + $contId = $this->urlArg('id'); $this->select("contribution_status_id", "label=Completed"); $this->click("_qf_Contribution_upload"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -178,8 +177,7 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { //click through to the Contribution edit screen $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']"); $this->waitForElementPresent("_qf_Contribution_upload-bottom"); - $elements = $this->parseURL(); - $contId = $elements['queryString']['id']; + $contId = $this->urlArg('id'); $this->waitForElementPresent("product_name_0"); $this->select('product_name_0', "label=$premiumName2 ( $sku2 )"); // Clicking save. @@ -246,8 +244,7 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { //click through to the Contribution edit screen $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']"); $this->waitForElementPresent("_qf_Contribution_upload-bottom"); - $elements = $this->parseURL(); - $contId = $elements['queryString']['id']; + $contId = $this->urlArg('id'); $this->waitForElementPresent("product_name_0"); $this->select('product_name_0', "value=0"); // Clicking save. @@ -273,8 +270,7 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $this->_testOfflineContribution($firstName, $lastName, $email, $amount); $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $elements = $this->parseURL(); - $contId = $elements['queryString']['id']; + $contId = $this->urlArg('id'); //change payment processor to newly created value $this->select("payment_instrument_id", "label=$label"); $this->click("_qf_Contribution_upload"); @@ -296,8 +292,7 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //Contribution status $this->select("contribution_status_id", "label=Refunded"); - $elements = $this->parseURL(); - $contId = $elements['queryString']['id']; + $contId = $this->urlArg('id'); $this->click("_qf_Contribution_upload"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -325,8 +320,7 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //Contribution status $this->select("contribution_status_id", "label=Cancelled"); - $elements = $this->parseURL(); - $contId = $elements['queryString']['id']; + $contId = $this->urlArg('id'); $this->click("_qf_Contribution_upload"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -360,8 +354,7 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //Contribution status $this->select("financial_type_id", "value=3"); - $elements = $this->parseURL(); - $contId = $elements['queryString']['id']; + $contId = $this->urlArg('id'); $this->click("_qf_Contribution_upload"); $this->waitForPageToLoad($this->getTimeoutMsec()); diff --git a/tests/phpunit/WebTest/Event/AddEventTest.php b/tests/phpunit/WebTest/Event/AddEventTest.php index 00108118ba..6ee243ad60 100644 --- a/tests/phpunit/WebTest/Event/AddEventTest.php +++ b/tests/phpunit/WebTest/Event/AddEventTest.php @@ -497,8 +497,7 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { $this->assertStringsPresent($eventFees); } - $elements = $this->parseURL(); - return $elements['queryString']['id']; + return $this->urlArg('id'); } function _testVerifyRegisterPage($registerStrings) { diff --git a/tests/phpunit/WebTest/Event/AddPricesetTest.php b/tests/phpunit/WebTest/Event/AddPricesetTest.php index 12af2d58c0..2957905da6 100644 --- a/tests/phpunit/WebTest/Event/AddPricesetTest.php +++ b/tests/phpunit/WebTest/Event/AddPricesetTest.php @@ -43,8 +43,7 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form // which is where we are after adding Price Set. - $elements = $this->parseURL(); - $sid = $elements['queryString']['sid']; + $sid = $this->urlArg('sid'); $this->assertType('numeric', $sid); $validStrings = array(); @@ -188,8 +187,7 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form // which is where we are after adding Price Set. - $elements = $this->parseURL(); - $sid = $elements['queryString']['sid']; + $sid = $this->urlArg('sid'); $this->assertType('numeric', $sid); $validStrings = array(); @@ -346,8 +344,7 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form // which is where we are after adding Price Set. - $elements = $this->parseURL(); - $sid = $elements['queryString']['sid']; + $sid = $this->urlArg('sid'); $this->assertType('numeric', $sid); $validStrings = array(); @@ -502,8 +499,7 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form // which is where we are after adding Price Set. - $elements = $this->parseURL(); - $sid = $elements['queryString']['sid']; + $sid = $this->urlArg('sid'); $this->assertType('numeric', $sid); $validStrings = array(); diff --git a/tests/phpunit/WebTest/Event/MultiprofileEventTest.php b/tests/phpunit/WebTest/Event/MultiprofileEventTest.php index 7a1541d745..f5419f965d 100644 --- a/tests/phpunit/WebTest/Event/MultiprofileEventTest.php +++ b/tests/phpunit/WebTest/Event/MultiprofileEventTest.php @@ -60,8 +60,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); // get custom group id - $elements = $this->parseURL(); - $customGrpId1 = $elements['queryString']['gid']; + $customGrpId1 = $this->urlArg('gid'); $customId = $this->_testGetCustomFieldId($customGrpId1); @@ -161,8 +160,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); // get custom group id - $elements = $this->parseURL(); - $customGrpId1 = $elements['queryString']['gid']; + $customGrpId1 = $this->urlArg('gid'); $customId = $this->_testGetCustomFieldId($customGrpId1); @@ -417,8 +415,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { $this->type('title', $profilename); $this->click('_qf_Group_next-top'); $this->waitForPageToLoad($this->getTimeoutMsec()); - $elements = $this->parseURL(); - $profileId = $elements['queryString']['gid']; + $profileId = $this->urlArg('gid'); //Add field to profile_testCreateProfile foreach ($profilefield as $key => $value) { @@ -581,12 +578,9 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { // Wait for "saved" status msg $this->waitForPageToLoad($this->getTimeoutMsec()); - $elements = $this->parseURL(); - $eventPageId = $elements['queryString']['id']; + $this->waitForText('crm-notification-container', "'Registration' information has been saved."); - $this->waitForTextPresent("'Registration' information has been saved."); - - return $eventPageId; + return $this->urlArg('id'); } function _testEventRegistration($eventPageId, $customId, $firstName, $lastName, diff --git a/tests/phpunit/WebTest/Event/PCPAddTest.php b/tests/phpunit/WebTest/Event/PCPAddTest.php index 793edfcf5f..5c4299a708 100644 --- a/tests/phpunit/WebTest/Event/PCPAddTest.php +++ b/tests/phpunit/WebTest/Event/PCPAddTest.php @@ -416,12 +416,10 @@ class WebTest_Event_PCPAddTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_Event_upload-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); $text = "'Event' information has been saved."; - $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); + $this->waitForText('crm-notification-container', $text); // parse URL to grab the contribution page id - $elements = $this->parseURL(); - $pageId = $elements['queryString']['id']; - return $pageId; + return $this->urlArg('id'); } function _testParticipantSearchEventName($eventName, $lastNameDonar, $firstNameDonar, $firstNameCreator, $lastNameCreator, $amount) { diff --git a/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php b/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php index 42201444cb..75cd6e456c 100644 --- a/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php +++ b/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php @@ -111,9 +111,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { // get text field Id. $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $matches = array(); - preg_match('/fid=([0-9]+)/', $this->getLocation(), $matches); - $textFieldId = $matches[1]; + $textFieldId = $this->urlArg('fid'); $this->open($pricesetLoc); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -122,17 +120,13 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a"); $this->waitForPageToLoad($this->getTimeoutMsec()); $selectFieldLoc = $this->getLocation(); - $matches = array(); - preg_match('/fid=([0-9]+)/', $this->getLocation(), $matches); - $selectFieldId = $matches[1]; + $selectFieldId = $this->urlArg('fid'); // get select field ids // get select field option1 $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $matches = array(); - preg_match('/oid=([0-9]+)/', $this->getLocation(), $matches); - $selectFieldOp1 = $matches[1]; + $selectFieldOp1 = $this->urlArg('oid'); $this->open($selectFieldLoc); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -140,9 +134,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { // get select field option2 $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $matches = array(); - preg_match('/oid=([0-9]+)/', $this->getLocation(), $matches); - $selectFieldOp2 = $matches[1]; + $selectFieldOp2 = $this->urlArg('oid'); // create event. $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7); @@ -311,11 +303,8 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $pricesetLoc = $this->getLocation(); // get text field Id. - $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $matches = array(); - preg_match('/fid=([0-9]+)/', $this->getLocation(), $matches); - $textFieldId = $matches[1]; + $this->clickLink("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]"); + $textFieldId = $this->urlArg('fid'); $this->open($pricesetLoc); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -324,17 +313,13 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a"); $this->waitForPageToLoad($this->getTimeoutMsec()); $selectFieldLoc = $this->getLocation(); - $matches = array(); - preg_match('/fid=([0-9]+)/', $this->getLocation(), $matches); - $selectFieldId = $matches[1]; + $selectFieldId = $this->urlArg('fid'); // get select field ids // get select field option1 $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $matches = array(); - preg_match('/oid=([0-9]+)/', $this->getLocation(), $matches); - $selectFieldOp1 = $matches[1]; + $selectFieldOp1 = $this->urlArg('oid'); $this->open($selectFieldLoc); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -342,9 +327,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { // get select field option2 $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $matches = array(); - preg_match('/oid=([0-9]+)/', $this->getLocation(), $matches); - $selectFieldOp2 = $matches[1]; + $selectFieldOp2 = $this->urlArg('oid'); // create event. $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7); @@ -507,11 +490,8 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $pricesetLoc = $this->getLocation(); // get text field Id. - $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $matches = array(); - preg_match('/fid=([0-9]+)/', $this->getLocation(), $matches); - $textFieldId = $matches[1]; + $this->clickLink("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]"); + $textFieldId = $this->urlArg('fid'); $this->open($pricesetLoc); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -520,17 +500,13 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a"); $this->waitForPageToLoad($this->getTimeoutMsec()); $selectFieldLoc = $this->getLocation(); - $matches = array(); - preg_match('/fid=([0-9]+)/', $this->getLocation(), $matches); - $selectFieldId = $matches[1]; + $selectFieldId = $this->urlArg('fid'); // get select field ids // get select field option1 $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $matches = array(); - preg_match('/oid=([0-9]+)/', $this->getLocation(), $matches); - $selectFieldOp1 = $matches[1]; + $selectFieldOp1 = $this->urlArg('oid'); $this->open($selectFieldLoc); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -538,9 +514,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { // get select field option2 $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $matches = array(); - preg_match('/oid=([0-9]+)/', $this->getLocation(), $matches); - $selectFieldOp2 = $matches[1]; + $selectFieldOp2 = $this->urlArg('oid'); // create event. $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7); @@ -799,9 +773,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { // get text field Id. $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $matches = array(); - preg_match('/fid=([0-9]+)/', $this->getLocation(), $matches); - $textFieldId = $matches[1]; + $textFieldId = $this->urlArg('fid'); $this->open($pricesetLoc); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -810,17 +782,13 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a"); $this->waitForPageToLoad($this->getTimeoutMsec()); $selectFieldLoc = $this->getLocation(); - $matches = array(); - preg_match('/fid=([0-9]+)/', $this->getLocation(), $matches); - $selectFieldId = $matches[1]; + $selectFieldId = $this->urlArg('fid'); // get select field ids // get select field option1 $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $matches = array(); - preg_match('/oid=([0-9]+)/', $this->getLocation(), $matches); - $selectFieldOp1 = $matches[1]; + $selectFieldOp1 = $this->urlArg('oid'); $this->open($selectFieldLoc); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -828,9 +796,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { // get select field option2 $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $matches = array(); - preg_match('/oid=([0-9]+)/', $this->getLocation(), $matches); - $selectFieldOp2 = $matches[1]; + $selectFieldOp2 = $this->urlArg('oid'); // create event. $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7); diff --git a/tests/phpunit/WebTest/Financial/FinancialBatchExport.php b/tests/phpunit/WebTest/Financial/FinancialBatchExport.php index d323a3d94a..565f4197c4 100644 --- a/tests/phpunit/WebTest/Financial/FinancialBatchExport.php +++ b/tests/phpunit/WebTest/Financial/FinancialBatchExport.php @@ -79,8 +79,7 @@ class WebTest_Financial_FinancialBatchExport extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); // parse URL to grab the batch ID - $elements = $this->parseURL(); - $batchId = $elements['queryString']['bid']; + $batchId = $this->urlArg('bid'); return $batchId; } diff --git a/tests/phpunit/WebTest/Import/ActivityTest.php b/tests/phpunit/WebTest/Import/ActivityTest.php index 333504cc47..8ac0c9e7e0 100644 --- a/tests/phpunit/WebTest/Import/ActivityTest.php +++ b/tests/phpunit/WebTest/Import/ActivityTest.php @@ -51,14 +51,12 @@ class WebTest_Import_ActivityTest extends ImportCiviSeleniumTestCase { $firstName1 = substr(sha1(rand()), 0, 7); $email1 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com'; $this->webtestAddContact($firstName1, 'Anderson', $email1); - $url = explode('&cid=', $this->getLocation()); - $id1 = $url[1]; + $id1 = $this->urlArg('cid'); $firstName2 = substr(sha1(rand()), 0, 7); $email2 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com'; $this->webtestAddContact($firstName2, 'Anderson', $email2); - $url = explode('&cid=', $this->getLocation()); - $id2 = $url[1]; + $id2 = $this->urlArg('cid'); $headers = array( 'target_contact_id' => 'Contact ID', diff --git a/tests/phpunit/WebTest/Import/AddressImportTest.php b/tests/phpunit/WebTest/Import/AddressImportTest.php index 92d089649f..645c2566de 100644 --- a/tests/phpunit/WebTest/Import/AddressImportTest.php +++ b/tests/phpunit/WebTest/Import/AddressImportTest.php @@ -119,8 +119,7 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { //Is custom group created? $this->waitForText('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]; + $gid = $this->urlArg('gid'); // create custom field "alphanumeric text" $customField = 'Custom field ' . substr(sha1(rand()), 0, 4); diff --git a/tests/phpunit/WebTest/Import/ContactCustomDataTest.php b/tests/phpunit/WebTest/Import/ContactCustomDataTest.php index bfc8380b02..6aa005e69e 100644 --- a/tests/phpunit/WebTest/Import/ContactCustomDataTest.php +++ b/tests/phpunit/WebTest/Import/ContactCustomDataTest.php @@ -147,9 +147,8 @@ class WebTest_Import_ContactCustomDataTest 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.")); - $url = explode('gid=', $this->getLocation()); - $gid = $url[1]; + $this->waitForText('crm-notification-container', $customGroupTitle); + $gid = $this->urlArg('gid'); // create another custom field - Date $customField = 'Custom field ' . substr(sha1(rand()), 0, 4); diff --git a/tests/phpunit/WebTest/Import/CustomDataTest.php b/tests/phpunit/WebTest/Import/CustomDataTest.php index 3c9e0dcec2..002c343edc 100644 --- a/tests/phpunit/WebTest/Import/CustomDataTest.php +++ b/tests/phpunit/WebTest/Import/CustomDataTest.php @@ -41,16 +41,12 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase { $firstName3 = 'Ma' . substr(sha1(rand()), 0, 4); $this->webtestAddContact($firstName3, "Anderson", TRUE); $sortName3 = "$firstName3 Anderson"; - $this->waitForPageToLoad($this->getTimeoutMsec()); - $url1 = explode('&cid=', $this->getLocation()); - $id1 = $url1[1]; + $id1 = $this->urlArg('cid'); $firstName4 = 'Ma' . substr(sha1(rand()), 0, 4); $this->webtestAddContact($firstName4, "Anderson", TRUE); $sortName4 = "$firstName4 Anderson"; - $this->waitForPageToLoad($this->getTimeoutMsec()); - $url2 = explode('&cid=', $this->getLocation()); - $id2 = $url2[1]; + $id2 = $this->urlArg('cid'); // Get sample import data. list($headers, $rows, $customDataVerify) = $this->_individualCustomCSVData($customGroupTitle, $firstName1, $firstName2, diff --git a/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php b/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php index db33d6073f..9bb20e0e28 100644 --- a/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php +++ b/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php @@ -553,13 +553,10 @@ class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase { $this->waitForElementPresent("css=div.ac_results-inner li"); // Visit contact summary page. - $this->click("css=div.ac_results-inner li"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink("css=div.ac_results-inner li"); // Get contact id from url. - $matches = array(); - preg_match('/cid=([0-9]+)/', $this->getLocation(), $matches); - $contactIds[] = $matches[1]; + $contactIds[] = $this->urlArg('cid'); } return $contactIds; diff --git a/tests/phpunit/WebTest/Import/MatchExternalIdTest.php b/tests/phpunit/WebTest/Import/MatchExternalIdTest.php index 3f0d105f4e..e5e07e39ef 100644 --- a/tests/phpunit/WebTest/Import/MatchExternalIdTest.php +++ b/tests/phpunit/WebTest/Import/MatchExternalIdTest.php @@ -343,13 +343,9 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase { $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()); - $this->click("link=" . $params['title']); + $this->clickLink("link=" . $params['title']); - $this->waitForPageToLoad($this->getTimeoutMsec()); - - $matches = array(); - preg_match('/id=([0-9]+)/', $this->getLocation(), $matches); - $params['event_id'] = $matches[1]; + $params['event_id'] = $this->urlArg('id'); return $params; } diff --git a/tests/phpunit/WebTest/Import/ParticipantTest.php b/tests/phpunit/WebTest/Import/ParticipantTest.php index de21912bae..47f31c22d1 100644 --- a/tests/phpunit/WebTest/Import/ParticipantTest.php +++ b/tests/phpunit/WebTest/Import/ParticipantTest.php @@ -321,13 +321,9 @@ class WebTest_Import_ParticipantTest extends ImportCiviSeleniumTestCase { // verify event input on info page // start at Manage Events listing $this->openCiviPage('event/manage', 'reset=1'); - $this->click("link=" . $params['title']); + $this->clickLink("link=" . $params['title']); - $this->waitForPageToLoad($this->getTimeoutMsec()); - - $matches = array(); - preg_match('/id=([0-9]+)/', $this->getLocation(), $matches); - $params['event_id'] = $matches[1]; + $params['event_id'] = $this->urlArg('id');; return $params; } diff --git a/tests/phpunit/WebTest/Mailing/MailingTest.php b/tests/phpunit/WebTest/Mailing/MailingTest.php index 8e15984fc7..daea8e9c70 100644 --- a/tests/phpunit/WebTest/Mailing/MailingTest.php +++ b/tests/phpunit/WebTest/Mailing/MailingTest.php @@ -65,9 +65,7 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in"); // Get contact id from url. - $matches = array(); - preg_match('/cid=([0-9]+)/', $this->getLocation(), $matches); - $contactId = $matches[1]; + $contactId = $this->urlArg('cid'); // go to group tab and add to mailing group $this->click("css=li#tab_group a"); @@ -330,9 +328,7 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in"); // Get contact id from url. - $matches = array(); - preg_match('/cid=([0-9]+)/', $this->getLocation(), $matches); - $contactId = $matches[1]; + $contactId = $this->urlArg('cid'); // go to group tab and add to mailing group $this->click("css=li#tab_group a"); diff --git a/tests/phpunit/WebTest/Mailing/SpoolTest.php b/tests/phpunit/WebTest/Mailing/SpoolTest.php index cdec9a33f0..a84bb422e3 100644 --- a/tests/phpunit/WebTest/Mailing/SpoolTest.php +++ b/tests/phpunit/WebTest/Mailing/SpoolTest.php @@ -47,9 +47,7 @@ class WebTest_Mailing_SpoolTest extends CiviSeleniumTestCase { $email = $this->webtestAddContact($fname, $lname, TRUE); // Get the contact id of the newly added contact - $urlElements = $this->parseURL(); - $cid = $urlElements['queryString']['cid']; - $this->assertNotEmpty($cid, 'Could not find cid after adding contact'); + $cid = $this->urlArg('cid'); // Send an email to the added contact $this->openCiviPage("activity/email/add", "action=add&reset=1&cid={$cid}&selectedChild=activity&atype=3"); diff --git a/tests/phpunit/WebTest/Member/DefaultMembershipPricesetTest.php b/tests/phpunit/WebTest/Member/DefaultMembershipPricesetTest.php index 8f0fd40fad..bbc65ad938 100755 --- a/tests/phpunit/WebTest/Member/DefaultMembershipPricesetTest.php +++ b/tests/phpunit/WebTest/Member/DefaultMembershipPricesetTest.php @@ -44,8 +44,7 @@ class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form // which is where we are after adding Price Set. - $elements = $this->parseURL(); - $sid = $elements['queryString']['sid']; + $sid = $this->urlArg('sid'); $this->assertType('numeric', $sid); $fields = array("National Membership $title" => 'Radio'); diff --git a/tests/phpunit/WebTest/Member/InheritedMembershipTest.php b/tests/phpunit/WebTest/Member/InheritedMembershipTest.php index 91f7cb39a2..eb04eda595 100644 --- a/tests/phpunit/WebTest/Member/InheritedMembershipTest.php +++ b/tests/phpunit/WebTest/Member/InheritedMembershipTest.php @@ -187,9 +187,7 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { $this->click("//li[@id='tab_rel']/a"); $this->waitForElementPresent("xpath=//div[@id='current-relationships']//div//table/tbody//tr/td[9]/span/a[text()='Edit']"); $this->click("xpath=//div[@id='current-relationships']//div//table/tbody//tr/td[9]/span/a[text()='Edit']"); - $matches = array(); - preg_match('/cid=([0-9]+)/', $this->getLocation(), $matches); - $id = $matches[1]; + $id = $this->urlArg('cid'); $this->waitForElementPresent('is_active'); //disable relationship diff --git a/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php b/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php index 7227dc2afb..e72a555ae7 100644 --- a/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php +++ b/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php @@ -62,6 +62,7 @@ class WebTest_Member_OfflineAutoRenewMembershipTest extends CiviSeleniumTestCase $url = $this->getLocation(); $url = str_replace('mode=live', 'mode=test', $url); $this->open($url); + $this->waitForPageToLoad($this->getTimeoutMsec()); // start filling membership form $this->waitForElementPresent('payment_processor_id'); diff --git a/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php b/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php index 4a28ad2c5b..ed939348ab 100644 --- a/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php +++ b/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php @@ -44,8 +44,7 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form // which is where we are after adding Price Set. - $elements = $this->parseURL(); - $sid = $elements['queryString']['sid']; + $sid = $this->urlArg('sid'); $this->assertType('numeric', $sid); $fields = array( @@ -94,8 +93,7 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form // which is where we are after adding Price Set. - $elements = $this->parseURL(); - $sid = $elements['queryString']['sid']; + $sid = $this->urlArg('sid'); $this->assertType('numeric', $sid); $fields = array("National Membership $title", "Radio"); diff --git a/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php b/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php index 675c5e5436..02176df890 100644 --- a/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php +++ b/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php @@ -48,8 +48,7 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form // which is where we are after adding Price Set. - $elements = $this->parseURL(); - $sid = $elements['queryString']['sid']; + $sid = $this->urlArg('sid'); $this->assertType('numeric', $sid); $fields = array( @@ -106,8 +105,7 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form // which is where we are after adding Price Set. - $elements = $this->parseURL(); - $sid = $elements['queryString']['sid']; + $sid = $this->urlArg('sid'); $this->assertType('numeric', $sid); $fields = array("National Membership $title", "Radio"); diff --git a/tests/phpunit/WebTest/Member/OnlineMembershipRenewTest.php b/tests/phpunit/WebTest/Member/OnlineMembershipRenewTest.php index 4f42e76144..22f417dad6 100644 --- a/tests/phpunit/WebTest/Member/OnlineMembershipRenewTest.php +++ b/tests/phpunit/WebTest/Member/OnlineMembershipRenewTest.php @@ -301,9 +301,7 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { $this->click('css=#memberSearch table tbody tr td span a.action-item-first'); $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); - $matches = array(); - preg_match('/id=([0-9]+)/', $this->getLocation(), $matches); - $membershipCreatedId = $matches[1]; + $membershipCreatedId = $this->urlArg('id'); $memberSince = date('F jS, Y'); @@ -341,9 +339,7 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { $this->click('css=#memberSearch table tbody tr td span a.action-item-first'); $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); - $matches = array(); - preg_match('/id=([0-9]+)/', $this->getLocation(), $matches); - $membershipRenewedId = $matches[1]; + $membershipRenewedId = $this->urlArg('id'); //View Membership Record $verifyMembershipData = array( diff --git a/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php b/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php index 3960a2d76f..32c963fcbe 100644 --- a/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php +++ b/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php @@ -42,8 +42,7 @@ class WebTest_Member_SeperateMembershipPaymentTest extends CiviSeleniumTestCase $lastName1 = 'An_' . substr(sha1(rand()), 0, 7); $this->webtestAddContact($firstName1, $lastName1, TRUE); $this->waitForText('crm-notification-container', "$firstName1 $lastName1 has been created."); - $url = explode('&cid=', $this->getLocation()); - $cid = $url[1]; + $cid = $this->urlArg('cid'); // create contribution page with randomized title and default params $amountSection = TRUE; diff --git a/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php b/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php index 0f9cc89099..a28b65c236 100644 --- a/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php +++ b/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php @@ -181,8 +181,7 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->click('link=Use (create mode)'); $recordNew = $this->_addRecords('Create'); $this->waitForPageToLoad($this->getTimeoutMsec()); - $elements = $this->parseURL( ); - + $elements = $this->parseURL(); $gid = $elements['queryString']['gid']; $id = $elements['queryString']['id']; diff --git a/tests/phpunit/WebTest/Profile/SearchTest.php b/tests/phpunit/WebTest/Profile/SearchTest.php index e22c193173..3d8d355da7 100644 --- a/tests/phpunit/WebTest/Profile/SearchTest.php +++ b/tests/phpunit/WebTest/Profile/SearchTest.php @@ -53,8 +53,7 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase { $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."); // Get profile id (gid) from URL - $elements = $this->parseURL(); - $profileId = $elements['queryString']['gid']; + $profileId = $this->urlArg('gid'); // Add Last Name field. $this->click('field_name[0]'); diff --git a/tests/phpunit/WebTest/Report/LoggingReportTest.php b/tests/phpunit/WebTest/Report/LoggingReportTest.php index 7cf44a57d0..1dabdea1c8 100644 --- a/tests/phpunit/WebTest/Report/LoggingReportTest.php +++ b/tests/phpunit/WebTest/Report/LoggingReportTest.php @@ -48,7 +48,7 @@ class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase { $lastName = 'Anderson' . substr(sha1(rand()), 0, 7); $this->webtestAddContact($firstName, $lastName); - $cid = explode('&cid=', $this->getLocation()); + $cid = $this->urlArg('cid'); //add contact to group $this->waitForElementPresent("xpath=//li[@id='tab_group']/a"); -- 2.25.1