From b45c587ec9176a705db630a2b527fafb3b9c6f44 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 20 Mar 2013 13:55:03 -0700 Subject: [PATCH] Fixed some contribution pages --- .../phpunit/CiviTest/CiviSeleniumTestCase.php | 52 +++++++++++-------- .../Campaign/OnlineContributionTest.php | 49 +++++++---------- .../WebTest/Contact/ProfileChecksumTest.php | 6 +-- .../WebTest/Contribute/AddPricesetTest.php | 47 +++++------------ .../Contribute/ContributionPageAddTest.php | 24 ++++----- .../Contribute/OnBehalfOfOrganization.php | 5 +- .../OnlineMultiplePaymentProcessorTest.php | 8 +-- .../OnlineMembershipAddPricesetTest.php | 44 ++++------------ .../Member/OnlineMembershipRenewTest.php | 11 ++-- .../Member/SeperateMembershipPaymentTest.php | 14 ++--- 10 files changed, 105 insertions(+), 155 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 8ef7908e28..874a7badfa 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -161,6 +161,19 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { } } + /** + * Click on a link or button + * Wait for the page to load + * Wait for an element to be present + */ + function clickLink($element, $waitFor = 'civicrm-footer') { + $this->click($element); + $this->waitForPageToLoad($this->getTimeoutMsec()); + if ($waitFor) { + $this->waitForElementPresent($waitFor); + } + } + /** * Call the API on the local server * (kind of defeats the point of a webtest - see CRM-11889) @@ -293,7 +306,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { function webtestAddHousehold($householdName = "Smith's Home", $email = NULL) { - $this->open($this->sboxPath . 'civicrm/contact/add?reset=1&ct=Household'); + $this->openCiviPage("contact/add", "reset=1&ct=Household"); $this->click('household_name'); $this->type('household_name', $householdName); @@ -311,7 +324,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { function webtestAddOrganization($organizationName = "Organization XYZ", $email = NULL) { - $this->open($this->sboxPath . 'civicrm/contact/add?reset=1&ct=Organization'); + $this->openCiviPage("contact/add", "reset=1&ct=Organization"); $this->click('organization_name'); $this->type('organization_name', $organizationName); @@ -702,7 +715,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { * @return an array of saved params values. */ function webtestAddRelationshipType($params = array()) { - $this->open($this->sboxPath . 'civicrm/admin/reltype?reset=1&action=add'); + $this->openCiviPage("admin/reltype", "reset=1&action=add"); //build the params if not passed. if (!is_array($params) || empty($params)) { @@ -735,8 +748,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { "Status message didn't show up after saving!" ); - $this->open($this->sboxPath . 'civicrm/admin/reltype?reset=1'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage("admin/reltype", "reset=1"); //validate data on selector. $data = $params; @@ -750,6 +762,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { /** * Create new online contribution page w/ user specified params or defaults. + * FIXME: this function take an absurd number of params - very unwieldy :( * * @param User can define pageTitle, hash and rand values for later data verification * @@ -801,8 +814,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { } // go to the New Contribution Page page - $this->open($this->sboxPath . 'civicrm/admin/contribute?action=add&reset=1'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('admin/contribute', 'action=add&reset=1'); // fill in step 1 (Title and Settings) $this->type('title', $pageTitle); @@ -840,9 +852,11 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->click("id=is_confirm_enabled"); } - // go to step 2 - $this->click('_qf_Settings_next'); - $this->waitForElementPresent('_qf_Amount_next-bottom'); + // Submit form + $this->clickLink('_qf_Settings_next', "_qf_Amount_next-bottom"); + + // Get contribution page id + $pageId = $this->urlArg('id'); // fill in step 2 (Processor, Pay Later, Amounts) if (!empty($processor)) { @@ -1063,9 +1077,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); } - // parse URL to grab the contribution page id - // pass $pageId back to any other tests that call this class - return $this->urlArg('id'); + return $pageId; } /** @@ -1102,9 +1114,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { } } - $this->open($this->sboxPath . 'civicrm/contact/deduperules?action=update&id=' . $strictRuleId); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent('_qf_DedupeRules_next-bottom'); + $this->openCiviPage('contact/deduperules', "action=update&id=$strictRuleId", '_qf_DedupeRules_next-bottom'); $count = 0; foreach ($fields as $field => $weight) { @@ -1415,8 +1425,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $isDefault = FALSE ) { - $this->open($this->sboxPath . "civicrm/admin/financial/financialAccount?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage("admin/financial/financialAccount", "reset=1"); $this->click("link=Add Financial Account"); $this->waitForElementPresent('_qf_FinancialAccount_cancel-botttom'); @@ -1498,8 +1507,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $isDefault = FALSE ) { if ($firstName) { - $this->open($this->sboxPath . "civicrm/admin/financial/financialAccount?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage("admin/financial/financialAccount", "reset=1"); } $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$editfinancialAccount}']/../td[9]/span/a[text()='Edit']"); @@ -1609,7 +1617,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { } function addeditFinancialType($financialType, $option = 'new') { - $this->open($this->sboxPath . 'civicrm/admin/financial/financialType?reset=1'); + $this->openCiviPage("admin/financial/financialType", "reset=1"); if ($option == 'Delete') { $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[name]']/../td[7]/span[2]"); @@ -1660,7 +1668,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { /** * Give the specified permissions - * Note: this function logs in as 'admin' + * Note: this function logs in as 'admin' (logging out if necessary) */ function changePermissions($permission) { $this->webtestLogin('admin'); diff --git a/tests/phpunit/WebTest/Campaign/OnlineContributionTest.php b/tests/phpunit/WebTest/Campaign/OnlineContributionTest.php index 181925df00..7459e0237b 100644 --- a/tests/phpunit/WebTest/Campaign/OnlineContributionTest.php +++ b/tests/phpunit/WebTest/Campaign/OnlineContributionTest.php @@ -138,9 +138,11 @@ class WebTest_Campaign_OnlineContributionTest extends CiviSeleniumTestCase { $this->fillRichTextField('intro_text', 'This is Test Introductory Message', 'CKEditor'); $this->fillRichTextField('footer_text', 'This is Test Footer Message', 'CKEditor'); - // go to step 2 - $this->click('_qf_Settings_next'); - $this->waitForElementPresent("_qf_Amount_next-bottom"); + // Submit form + $this->clickLink('_qf_Settings_next', "_qf_Amount_next-bottom"); + + // Get contribution page id + $pageId = $this->urlArg('id'); //this contribution page for online contribution $this->check("payment_processor[{$paymentProcessorId}]"); @@ -240,22 +242,26 @@ class WebTest_Campaign_OnlineContributionTest extends CiviSeleniumTestCase { $this->click('_qf_Contribute_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - //get Url for Live Contribution Page - $registerUrl = $this->_testVerifyRegisterPage($contributionPageTitle); + // Make sure our page shows up in search results + $this->openCiviPage("admin/contribute", "reset=1", "_qf_SearchContribution_refresh"); + $this->type('title', $contributionPageTitle); + $this->click("_qf_SearchContribution_refresh"); + $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); + $url = $this->assertElementContainsText("//div[@id='configure_contribution_page']//table/tbody", $contributionPageTitle); //logout $this->webtestLogout(); //Open Live Contribution Page - $this->openCiviPage($registerUrl['url'], $registerUrl['args'], NULL); + $this->openCiviPage('contribute/transact', "reset=1&id=$pageId", '_qf_Main_upload-bottom'); + $firstName = 'Ma' . substr(sha1(rand()), 0, 4); $lastName = 'An' . substr(sha1(rand()), 0, 7); - - $this->type("email-5", $firstName . "@example.com"); - $this->type("first_name", $firstName); $this->type("last_name", $lastName); + $this->type("email-5", $firstName . "@example.com"); + $streetAddress = "100 Main Street"; $this->type("street_address-1", $streetAddress); $this->type("city-1", "San Francisco"); @@ -283,39 +289,20 @@ class WebTest_Campaign_OnlineContributionTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent("_qf_Confirm_next-bottom"); - $this->click("_qf_Confirm_next-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink("_qf_Confirm_next-bottom", NULL); //login to check contribution - - // Log in using webtestLogin() method $this->webtestLogin(); //Find Contribution $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); $this->type("sort_name", "$firstName $lastName"); - $this->click("_qf_Search_refresh"); - - $this->waitForPageToLoad($this->getTimeoutMsec()); - - $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); - $this->click("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("_qf_ContributionView_cancel-bottom"); + $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); + $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom"); //View Contribution Record $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[10]/td[2]", preg_quote($campaignTitle)); } - function _testVerifyRegisterPage($contributionPageTitle) { - $this->openCiviPage("admin/contribute", "reset=1", "_qf_SearchContribution_refresh"); - $this->type('title', $contributionPageTitle); - $this->click("_qf_SearchContribution_refresh"); - $this->waitForPageToLoad('50000'); - $id = $this->getAttribute("//div[@id='configure_contribution_page']//table/tbody/tr/td/strong[text()='$contributionPageTitle']/../../td[5]/div/span/ul/li/a[text()='Title and Settings']@href"); - $id = explode('id=', $id); - $registerUrl = array('url' => 'contribute/transact', 'args' => "reset=1&id=$id[1]"); - return $registerUrl; - } } diff --git a/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php b/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php index 0a52c52deb..23910827af 100644 --- a/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php +++ b/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php @@ -112,8 +112,8 @@ class WebTest_Contact_ProfileChecksumTest extends CiviSeleniumTestCase { $this->webtestLogout(); // Go to edit profile page of the created contact. - $this->openCiviPage("profile/edit", "id={$contactId}&gid={$profileId}&reset=1&cs={$cs}"); - $this->assertStringsPresent(array($profileName)); + $this->openCiviPage("profile/edit", "id={$contactId}&gid={$profileId}&reset=1&cs={$cs}", NULL); + $this->waitForTextPresent($profileName); // Check all profile fields, update their values. foreach ($fields as $field) { @@ -130,7 +130,7 @@ class WebTest_Contact_ProfileChecksumTest extends CiviSeleniumTestCase { $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); // Check profile view page. - $this->assertStringsPresent(array($profileName)); + $this->waitForTextPresent($profileName); // Check updated values of all fields. $checkFieldValues = array(); diff --git a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php index c57fea010e..88da4c392d 100644 --- a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php +++ b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php @@ -343,17 +343,6 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { } } - function _testVerifyRegisterPage($contributionPageTitle) { - $this->openCiviPage("admin/contribute", "reset=1", '_qf_SearchContribution_refresh'); - $this->type('title', $contributionPageTitle); - $this->click('_qf_SearchContribution_refresh'); - $this->waitForPageToLoad('50000'); - $id = $this->getAttribute("//div[@id='configure_contribution_page']//div[@class='dataTables_wrapper']/table/tbody/tr@id"); - $id = explode('_', $id); - $registerUrl = "civicrm/contribute/transact?reset=1&id=$id[1]"; - return $registerUrl; - } - function testContributeOnlineWithPriceSet() { $this->webtestLogin(); @@ -400,26 +389,24 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $this->fillRichTextField('footer_text', 'This is Test Footer Message', 'CKEditor'); $this->select('financial_type_id', "label={$financialType}"); - // go to step 2 - $this->click('_qf_Settings_next'); - $this->waitForElementPresent('_qf_Amount_next-bottom'); + + // Submit form + $this->clickLink('_qf_Settings_next', "_qf_Amount_next-bottom"); + + // Get contribution page id + $pageId = $this->urlArg('id'); //this contribution page for online contribution - //$this->select( 'payment_processor_id', 'label=' . $processorName ); $this->click("xpath=//tr[@class='crm-contribution-contributionpage-amount-form-block-payment_processor']/td/label[text()='$processorName']"); $this->select('price_set_id', 'label=' . $setTitle); $this->click('_qf_Amount_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - //get Url for Live Contribution Page - $registerUrl = $this->_testVerifyRegisterPage($contributionPageTitle); - //logout $this->webtestLogout(); //Open Live Contribution Page - $this->open($this->sboxPath . $registerUrl); - $this->waitForElementPresent('_qf_Main_upload-bottom'); + $this->openCiviPage('contribute/transact', "reset=1&id=$pageId", '_qf_Main_upload-bottom'); $firstName = 'Ma' . substr(sha1(rand()), 0, 4); $lastName = 'An' . substr(sha1(rand()), 0, 7); @@ -533,26 +520,22 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $this->fillRichTextField('intro_text', 'This is Test Introductory Message', 'CKEditor'); $this->fillRichTextField('footer_text', 'This is Test Footer Message', 'CKEditor'); - // go to step 2 - $this->click('_qf_Settings_next'); - $this->waitForElementPresent('_qf_Amount_next-bottom'); + // Submit form + $this->clickLink('_qf_Settings_next', "_qf_Amount_next-bottom"); + + // Get contribution page id + $pageId = $this->urlArg('id'); //this contribution page for online contribution - //$this->select( 'payment_processor_id', 'label=' . $processorName ); $this->click("xpath=//tr[@class='crm-contribution-contributionpage-amount-form-block-payment_processor']/td/label[text()='$processorName']"); $this->select('price_set_id', 'label=' . $setTitle); - $this->click('_qf_Amount_next-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); - - //get Url for Live Contribution Page - $registerUrl = $this->_testVerifyRegisterPage($contributionPageTitle); + $this->clickLink('_qf_Amount_next-bottom'); //logout $this->webtestLogout(); //Open Live Contribution Page - $this->open($this->sboxPath . $registerUrl); - $this->waitForElementPresent('_qf_Main_upload-bottom'); + $this->openCiviPage('contribute/transact', "reset=1&id=$pageId", '_qf_Main_upload-bottom'); $firstName = 'Ma' . substr(sha1(rand()), 0, 4); $lastName = 'An' . substr(sha1(rand()), 0, 7); @@ -592,8 +575,6 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //login to check contribution - - // Log in using webtestLogin() method $this->webtestLogin(); //Find Contribution diff --git a/tests/phpunit/WebTest/Contribute/ContributionPageAddTest.php b/tests/phpunit/WebTest/Contribute/ContributionPageAddTest.php index 9c28243523..130ce7798c 100644 --- a/tests/phpunit/WebTest/Contribute/ContributionPageAddTest.php +++ b/tests/phpunit/WebTest/Contribute/ContributionPageAddTest.php @@ -47,7 +47,7 @@ class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { // select testdrive mode $this->isTextPresent($pageTitle); - $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId"); + $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", '_qf_Main_upload-bottom'); // verify whatever’s possible to verify // FIXME: ideally should be expanded @@ -71,9 +71,9 @@ class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { } } - /* - * check CRM-7943 - */ + /** + * check CRM-7943 + */ function testContributionPageSeparatePayment() { // open browser, login $this->webtestLogin(); @@ -98,7 +98,7 @@ class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { // select testdrive mode $this->isTextPresent($pageTitle); - $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId"); + $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", '_qf_Main_upload-bottom'); $texts = array( "Title - New Membership $hash", @@ -119,9 +119,9 @@ class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { } } - /* - * check CRM-7949 - */ + /** + * check CRM-7949 + */ function testContributionPageSeparatePaymentPayLater() { // open browser, login $this->webtestLogin(); @@ -144,14 +144,11 @@ class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { $this->click('_qf_SearchContribution_refresh'); $this->waitForPageToLoad($this->getTimeoutMsec()); - //get Url for Live Contribution Page - $registerUrl = "civicrm/contribute/transact?reset=1&id=$pageId"; //logout $this->webtestLogout(); //Open Live Contribution Page - $this->open($this->sboxPath . $registerUrl); - $this->waitForElementPresent('_qf_Main_upload-bottom'); + $this->openCiviPage('contribute/transact', "reset=1&id=$pageId", '_qf_Main_upload-bottom'); $firstName = 'Ya' . substr(sha1(rand()), 0, 4); $lastName = 'Cha' . substr(sha1(rand()), 0, 7); @@ -159,8 +156,7 @@ class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { $this->type('email-5', $firstName . '@example.com'); $this->type('first_name', $firstName); $this->type('last_name', $lastName); - //$this->click( "xpath=id('Main')/x:div[2]/x:div[3]/x:div[2]/x:label[2]" ); - $this->waitForElementPresent('_qf_Main_upload-bottom'); + $this->click('_qf_Main_upload-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent('_qf_Confirm_next-bottom'); diff --git a/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php b/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php index eadf5f6daf..e2549418b5 100644 --- a/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php +++ b/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php @@ -1206,8 +1206,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //Open Live Membership Page - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id=" . $pageId . "&cid=" . $cid); - $this->waitForElementPresent("_qf_Main_upload-bottom"); + $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&cid=$cid", "_qf_Main_upload-bottom"); $this->click('CIVICRM_QFID_amount_other_radio_4'); $this->type('amount_other', 60); $this->click('onbehalf_organization_name'); @@ -1417,7 +1416,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { function _testOrganizationWithImageUpload($pageId, $cid, $pageTitle) { //Open Live Contribution Page - $this->openCiviPage("contribute/transact", "reset=1&id=$pageId"); + $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", '_qf_Main_upload-bottom'); $firstName = 'Ma' . substr(sha1(rand()), 0, 4); $lastName = 'An' . substr(sha1(rand()), 0, 7); diff --git a/tests/phpunit/WebTest/Contribute/OnlineMultiplePaymentProcessorTest.php b/tests/phpunit/WebTest/Contribute/OnlineMultiplePaymentProcessorTest.php index b6ab916c1c..74802aac0c 100644 --- a/tests/phpunit/WebTest/Contribute/OnlineMultiplePaymentProcessorTest.php +++ b/tests/phpunit/WebTest/Contribute/OnlineMultiplePaymentProcessorTest.php @@ -63,8 +63,8 @@ class WebTest_Contribute_OnlineMultiplePaymentProcessorTest extends CiviSelenium $allowOtherAmmount = TRUE ); - $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId"); - $this->assertTrue($this->isTextPresent($donationPageTitle)); + $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", NULL); + $this->waitForTextPresent($donationPageTitle); $firstName = 'Ma' . substr(sha1(rand()), 0, 4); $lastName = 'An' . substr(sha1(rand()), 0, 7); @@ -151,8 +151,8 @@ class WebTest_Contribute_OnlineMultiplePaymentProcessorTest extends CiviSelenium $allowOtherAmmount = TRUE ); - $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId"); - $this->assertTrue($this->isTextPresent($donationPageTitle)); + $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", NULL); + $this->waitForTextPresent($donationPageTitle); $firstName = 'Ma' . substr(sha1(rand()), 0, 4); $lastName = 'An' . substr(sha1(rand()), 0, 7); diff --git a/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php b/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php index 481583c92e..cd0dfd3be7 100644 --- a/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php +++ b/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php @@ -66,13 +66,11 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $contributionPageTitle = "Contribution Page $title"; $paymentProcessor = "Webtest Dummy $title"; - $this->webtestAddContributionPage(NULL, NULL, $contributionPageTitle, array($paymentProcessor => 'Dummy'), + $pageId = $this->webtestAddContributionPage(NULL, NULL, $contributionPageTitle, array($paymentProcessor => 'Dummy'), TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, $sid, FALSE, 1, NULL ); // Sign up for membership - $registerUrl = $this->_testVerifyRegisterPage($contributionPageTitle); - $firstName = 'John_' . substr(sha1(rand()), 0, 7); $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7); $email = "{$firstName}.{$lastName}@example.com"; @@ -82,10 +80,10 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas 'last_name' => $lastName, 'email-5' => $email, ); - $this->_testSignUpOrRenewMembership($registerUrl, $contactParams, $memTypeTitle1, $memTypeTitle2); + $this->_testSignUpOrRenewMembership($pageId, $contactParams, $memTypeTitle1, $memTypeTitle2); // Renew this membership - $this->_testSignUpOrRenewMembership($registerUrl, $contactParams, $memTypeTitle1, $memTypeTitle2, $renew = TRUE); + $this->_testSignUpOrRenewMembership($pageId, $contactParams, $memTypeTitle1, $memTypeTitle2, $renew = TRUE); } function testAddPriceSetWithMultipleTerms() { @@ -166,13 +164,11 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $contributionPageTitle = "Contribution Page $title"; $paymentProcessor = "Webtest Dummy $title"; - $this->webtestAddContributionPage(NULL, NULL, $contributionPageTitle, array($paymentProcessor => 'Dummy'), + $pageId = $this->webtestAddContributionPage(NULL, NULL, $contributionPageTitle, array($paymentProcessor => 'Dummy'), TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, $sid, FALSE, 1, NULL ); // Sign up for membership - $registerUrl = $this->_testVerifyRegisterPage($contributionPageTitle); - $firstName = 'John_' . substr(sha1(rand()), 0, 7); $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7); $email = "{$firstName}.{$lastName}@example.com"; @@ -183,9 +179,9 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas 'email-5' => $email, ); //membership with number of terms as 2 - $this->_testMultilpeTermsMembershipRegistration($registerUrl, $contactParams, $memTypeTitle1, 2); + $this->_testMultilpeTermsMembershipRegistration($pageId, $contactParams, $memTypeTitle1, 2); //membership with number of terms as 3 which will renew the above membership - $this->_testMultilpeTermsMembershipRegistration($registerUrl, $contactParams, $memTypeTitle1, 3, TRUE); + $this->_testMultilpeTermsMembershipRegistration($pageId, $contactParams, $memTypeTitle1, 3, TRUE); } @@ -294,26 +290,12 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $this->assertStringsPresent($validateStrings); } - function _testVerifyRegisterPage($contributionPageTitle) { - $this->openCiviPage('admin/contribute', 'reset=1', '_qf_SearchContribution_refresh'); - $this->type('title', $contributionPageTitle); - $this->click('_qf_SearchContribution_refresh'); - $this->waitForPageToLoad('50000'); - $id = $this->getAttribute("//div[@id='configure_contribution_page']//div[@class='dataTables_wrapper']/table/tbody/tr@id"); - $id = explode('_', $id); - $registerUrl = array('url' => 'contribute/transact', 'args' => "reset=1&id=$id[1]"); - return $registerUrl; - } - - function _testSignUpOrRenewMembership($registerUrl, $contactParams, $memTypeTitle1, $memTypeTitle2, $renew = FALSE) { + function _testSignUpOrRenewMembership($pageId, $contactParams, $memTypeTitle1, $memTypeTitle2, $renew = FALSE) { $this->webtestLogout(); - $this->openCiviPage($registerUrl['url'], $registerUrl['args'], '_qf_Main_upload-bottom'); + $this->openCiviPage('contribute/transact', "reset=1&id=$pageId", '_qf_Main_upload-bottom'); //build the membership dates. - require_once 'CRM/Core/Config.php'; - require_once 'CRM/Utils/Array.php'; - require_once 'CRM/Utils/Date.php'; $currentYear = date('Y'); $currentMonth = date('m'); $previousDay = date('d') - 1; @@ -395,8 +377,7 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas ); } - $this->click('_qf_MembershipView_cancel-bottom'); - $this->waitForElementPresent("xpath=//div[@id='memberSearch']/table/tbody/tr[2]"); + $this->clickLink('_qf_MembershipView_cancel-bottom', "xpath=//div[@id='memberSearch']/table/tbody/tr[2]"); $this->click("xpath=//div[@id='memberSearch']/table/tbody//tr/td[4][text()='{$memTypeTitle2}']/../td[11]/span/a[text()='View']"); $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); @@ -415,7 +396,7 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas } } - function _testMultilpeTermsMembershipRegistration($registerUrl, $contactParams, $memTypeTitle1, $term, $renew = FALSE){ + function _testMultilpeTermsMembershipRegistration($pageId, $contactParams, $memTypeTitle1, $term, $renew = FALSE){ if($renew){ $this->openCiviPage('member/search', 'reset=1', 'member_end_date_high'); $this->type("sort_name", "{$contactParams['first_name']} {$contactParams['last_name']}"); @@ -430,12 +411,9 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $this->webtestLogout(); - $this->openCiviPage($registerUrl['url'], $registerUrl['args'], '_qf_Main_upload-bottom'); + $this->openCiviPage('contribute/transact', "reset=1&id=$pageId", '_qf_Main_upload-bottom'); //build the membership dates. - require_once 'CRM/Core/Config.php'; - require_once 'CRM/Utils/Array.php'; - require_once 'CRM/Utils/Date.php'; $currentYear = date('Y'); $currentMonth = date('m'); $previousDay = date('d') - 1; diff --git a/tests/phpunit/WebTest/Member/OnlineMembershipRenewTest.php b/tests/phpunit/WebTest/Member/OnlineMembershipRenewTest.php index aa2950a3e0..a36d5cc7fe 100644 --- a/tests/phpunit/WebTest/Member/OnlineMembershipRenewTest.php +++ b/tests/phpunit/WebTest/Member/OnlineMembershipRenewTest.php @@ -32,6 +32,9 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { parent::setUp(); } + /** + * FIXME: This test tries to update a contribution page (id=2) that may not exist :( + */ function testOnlineMembershipRenew() { // a random 7-char string and an even number to make this pass unique $hash = substr(sha1(rand()), 0, 7); @@ -53,8 +56,7 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { // save $this->waitForElementPresent("_qf_Amount_next"); - $this->click('_qf_Amount_next'); - $this->waitForPageToLoad(); + $this->clickLink('_qf_Amount_next'); // go to Membership block $this->click('css=#tab_membership a'); @@ -214,6 +216,9 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { } } + /** + * FIXME: This test tries to update a contribution page (id=2) that may not exist :( + */ function testOnlineMembershipRenewChangeType() { // a random 7-char string and an even number to make this pass unique $hash = substr(sha1(rand()), 0, 7); @@ -601,7 +606,7 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { //logout $this->webtestLogout(); - $this->openCiviPage("contribute/transact", "reset=1&id=$pageId"); + $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom"); $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'$membershipTypeTitle')]"); $this->type("email-5", $email); diff --git a/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php b/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php index 41797c1e97..f3b038bb1a 100644 --- a/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php +++ b/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php @@ -147,20 +147,16 @@ class WebTest_Member_SeperateMembershipPaymentTest extends CiviSeleniumTestCase function _testOnlineMembershipSignup($pageId, $memTypeId, $cid = NULL) { //Open Live Contribution Page + $args = array('reset' => 1, 'id' => $pageId); if ($cid) { - $contribUrl = array('url' => "contribute/transact", 'args' => "reset=1&id=$pageId&cid=$cid"); + $args['cid'] = $cid; } - else { - $contribUrl = array('url' => "contribute/transact", 'args' => "reset=1&id=$pageId"); - } - $this->openCiviPage($contribUrl['url'], $contribUrl['args'], '_qf_Main_upload-bottom'); + $this->openCiviPage("contribute/transact", $args, '_qf_Main_upload-bottom'); // Select membership type 1 $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'$memTypeId')]"); $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 60); - $this->click("_qf_Main_upload-bottom"); - $this->waitForElementPresent("_qf_Confirm_next-bottom"); - $this->click("_qf_Confirm_next-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); + $this->clickLink("_qf_Confirm_next-bottom", NULL); } } -- 2.25.1