X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FWebTest%2FMember%2FOnlineMembershipAddPricesetTest.php;h=7ef3bb385d820b5a79ce2a279a74f536dd14f34a;hb=6de877255b5e0807eb4b6c660f6d013bd0d2a961;hp=481583c92edfc3d2c4317918400271ebe92ebfdf;hpb=efb29358e53fbbc80df81b7541662e5db73d760d;p=civicrm-core.git diff --git a/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php b/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php index 481583c92e..7ef3bb385d 100644 --- a/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php +++ b/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php @@ -1,9 +1,9 @@ parseURL(); - $sid = $elements['queryString']['sid']; + $sid = $this->urlArg('sid'); $this->assertType('numeric', $sid); $fields = array( @@ -66,13 +64,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 +78,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() { @@ -103,19 +99,18 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $setHelp = 'Select your membership options.'; $memTypeParams1 = $this->webtestAddMembershipType(); $memTypeTitle1 = $memTypeParams1['membership_type']; - $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href")); + $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[1]/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href")); $memTypeId1 = $memTypeId1[1]; $this->_testAddSet($setTitle, $usedFor, $contributionType, $setHelp); // 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"); $this->openCiviPage('admin/price/field', "reset=1&action=add&sid={$sid}"); - + $validateStrings[] = $fields[0]; $this->type('label', $fields[0]); $this->select('html_type', "value={$fields[1]}"); @@ -137,7 +132,7 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas 'amount' => 120.00, 'membership_num_terms' => 3, ), - + ); $i = 2; foreach($options as $index => $values){ @@ -150,7 +145,8 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[5]/input",$values['label']); $this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[6]/input",$values['amount']); if($i > 3){ - $this->click('link=another choice'); + $this->click('link=another choice'); + } $i++; } @@ -159,20 +155,18 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $this->waitForElementPresent('_qf_Field_next-bottom'); $this->click('_qf_Field_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->assertElementContainsText('crm-notification-container', "Price Field '{$fields[0]}' has been saved."); - + $this->waitForText('crm-notification-container', "Price Field '{$fields[0]}' has been saved."); + // load the Price Set Preview and check for expected values $this->_testVerifyPriceSet($validateStrings, $sid); $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 +177,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); } @@ -203,28 +197,25 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas elseif ($usedFor == 'Membership') { $this->click('extends[3]'); $this->waitForElementPresent( 'financial_type_id' ); - $this->select("css=select.form-select", "label={$contributionType}"); + $this->select("css=select.crm-form-select", "label={$contributionType}"); } $this->type('help_pre', $setHelp); $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.'); - $this->click('_qf_Set_next-bottom'); - - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent('_qf_Field_next-bottom'); - $this->assertElementContainsText('crm-notification-container', "Your Set '{$setTitle}' has been added. You can add fields to this set now."); + $this->clickLink('_qf_Set_next-bottom', '_qf_Field_next-bottom'); + $this->waitForText('crm-notification-container', "Your Set '{$setTitle}' has been added. You can add fields to this set now."); } function _testAddPriceFields(&$fields, &$validateString, $dateSpecificFields = FALSE, $title, $sid, $contributionType) { $memTypeParams1 = $this->webtestAddMembershipType(); $memTypeTitle1 = $memTypeParams1['membership_type']; - $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href")); + $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[1]/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href")); $memTypeId1 = $memTypeId1[1]; $memTypeParams2 = $this->webtestAddMembershipType(); $memTypeTitle2 = $memTypeParams2['membership_type']; - $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle2}']/../td[12]/span/a[3]@href")); + $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[1]/table/tbody//tr/td[text()='{$memTypeTitle2}']/../td[12]/span/a[3]@href")); $memTypeId2 = $memTypeId2[1]; $this->openCiviPage('admin/price/field', "reset=1&action=add&sid={$sid}"); @@ -270,10 +261,8 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas break; } $this->select("financial_type_id", "label={$contributionType}"); - $this->click('_qf_Field_next_new-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent('_qf_Field_next-bottom'); - $this->assertElementContainsText('crm-notification-container', "Price Field '{$label}' has been saved."); + $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom'); + $this->waitForText('crm-notification-container', "Price Field '{$label}' has been saved."); } return array($memTypeTitle1, $memTypeTitle2); } @@ -284,36 +273,18 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $this->openCiviPage('admin/price', 'reset=1'); // Use the price set id ($sid) to pick the correct row - $this->click("css=tr#row_{$sid} a[title='Preview Price Set']"); - - $this->waitForPageToLoad($this->getTimeoutMsec()); - // Look for Register button - $this->waitForElementPresent('_qf_Preview_cancel-bottom'); + $this->clickLink("css=tr#price_set-{$sid} a[title='Preview Price Set']", '_qf_Preview_cancel-bottom'); // Check for expected price set field strings $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; @@ -356,10 +327,7 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $this->select("billing_country_id-5", "value=1228"); $this->select("billing_state_province_id-5", "value=1004"); $this->type("billing_postal_code-5", "94129"); - $this->click("_qf_Main_upload-bottom"); - - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("_qf_Confirm_next-bottom"); + $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); $this->click("_qf_Confirm_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -395,8 +363,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]", FALSE); $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"); @@ -414,33 +381,29 @@ 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']}"); - $this->click("_qf_Search_refresh"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("xpath=//div[@id='memberSearch']/table/tbody/tr"); + $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr"); $this->click("xpath=//div[@id='memberSearch']/table/tbody//tr/td[4][text()='{$memTypeTitle1}']/../td[11]/span/a[text()='View']"); $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); $year = CRM_Utils_Date::processDate($this->getText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='End date']/following-sibling::td")); $prevYear = substr($year, 0, 4); } - + $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; $endYear = ($term == 3) ? $currentYear + 3 : (($term == 2) ? $currentYear + 2 : $currentYear + 1); - $endYear = ($renew) ? $endYear + ($prevYear - $currentYear) : $endYear; + $endYear = ($renew) ? $endYear + ($prevYear - $currentYear) : $endYear; + $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear)); @@ -480,10 +443,7 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $this->select("billing_country_id-5", "value=1228"); $this->select("billing_state_province_id-5", "value=1004"); $this->type("billing_postal_code-5", "94129"); - $this->click("_qf_Main_upload-bottom"); - - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("_qf_Confirm_next-bottom"); + $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); $this->click("_qf_Confirm_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -519,6 +479,7 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas ); } //check if the membership amount is correct + $this->waitForElementPresent("xpath=//form[@id='MembershipView']/div[2]/div/table[2]/tbody/tr/td/span[text()='{$amount}']"); $this->assertTrue($this->isElementPresent("xpath=//form[@id='MembershipView']/div[2]/div/table[2]/tbody/tr/td/span[text()='{$amount}']")); }