X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FWebTest%2FMember%2FOfflineMembershipRenewTest.php;h=0129a8384371b9852eedad6881a345757a473167;hb=6de877255b5e0807eb4b6c660f6d013bd0d2a961;hp=30cdc36403771f3ec012aaf82178f5a072414178;hpb=197055856e1ba72ef7b334c8a39a226ba6056d81;p=civicrm-core.git diff --git a/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php b/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php index 30cdc36403..0129a83843 100644 --- a/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php +++ b/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php @@ -1,9 +1,9 @@ open($this->sboxPath); $this->webtestLogin(); // make sure period is correct for the membership type we testing for, @@ -66,7 +64,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->webtestFillDate('join_date', '-2 year'); // Let Start Date and End Date be auto computed - // added sleep to make sure jscript onchange for total_amount has a chance to fire + + // Because it tends to cause problems, all uses of sleep() must be justified in comments + // Sleep should never be used for wait for anything to load from the server + // Justification for this instance: make sure onchange for total_amount has a chance to fire sleep(2); // Clicking save. @@ -77,14 +78,12 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForTextPresent($sourceText); // Is status message correct? - $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.", - "Status message didn't show up after saving!" - ); + $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); // click through to the Membership Renewal Link - $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); @@ -96,10 +95,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { // page was loaded $this->waitForTextPresent($sourceText); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); // click through to the membership view screen - $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); @@ -120,7 +119,6 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { } function testOfflineMemberRenewOverride() { - $this->open($this->sboxPath); $this->webtestLogin(); // add membership type @@ -185,14 +183,12 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForTextPresent($sourceText); // Is status message correct? - $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.", - "Status message didn't show up after saving!" - ); + $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); // click through to the Membership Renewal Link - $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); @@ -204,10 +200,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { // page was loaded $this->waitForTextPresent($sourceText); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); // click through to the membership view screen - $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); @@ -229,7 +225,6 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { } function testOfflineMembershipRenewChangeType() { - $this->open($this->sboxPath); $this->webtestLogin(); // make sure period is correct for the membership type we testing for, @@ -262,7 +257,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->webtestFillDate('join_date', '-2 year'); // Let Start Date and End Date be auto computed - // added sleep to make sure jscript onchange for total_amount has a chance to fire + + // Because it tends to cause problems, all uses of sleep() must be justified in comments + // Sleep should never be used for wait for anything to load from the server + // Justification for this instance: make sure onchange for total_amount has a chance to fire sleep(2); // Clicking save. @@ -273,14 +271,12 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForTextPresent($sourceText); // Is status message correct? - $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.", - "Status message didn't show up after saving!" - ); + $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->waitForElementPresent("xpath=//div[@id='inactive-memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']"); // click through to the Membership Renewal Link - $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->click("xpath=//div[@id='inactive-memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']"); $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); @@ -291,20 +287,22 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->select('membership_type_id[1]', "label={$newMembershipType['membership_type']}"); $this->click('membership_type_id[0]'); + // Because it tends to cause problems, all uses of sleep() must be justified in comments + // Sleep should never be used for wait for anything to load from the server + // Justification for this instance: wait for onchange handler sleep(2); // save the renewed membership $this->click('_qf_MembershipRenewal_upload-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); // page was loaded $this->waitForTextPresent($sourceText); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); // click through to the membership view screen - $this->click("xpath=//div[@id='Memberships']//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); @@ -326,7 +324,6 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { } function testOfflineMembershipRenewMultipleTerms() { - $this->open($this->sboxPath); $this->webtestLogin(); // make sure period is correct for the membership type we testing for, @@ -369,7 +366,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->type('check_number', '1023'); $this->select('contribution_status_id', "label=Completed"); $this->click('send_receipt'); - // added sleep to make sure jscript onchange for total_amount has a chance to fire + + // Because it tends to cause problems, all uses of sleep() must be justified in comments + // Sleep should never be used for wait for anything to load from the server + // Justification for this instance: make sure onchange for total_amount has a chance to fire sleep(2); // Clicking save. @@ -380,17 +380,13 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForTextPresent($sourceText); // Is status message correct? - $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.", - "Status message didn't show up after saving!" - ); - $this->assertElementContainsText('crm-notification-container', "A membership confirmation and receipt has been sent to {$firstName}@memberson.com.", - "Email sent to member message didn't show up after saving membership!" - ); + $this->waitForText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."); + $this->waitForText('crm-notification-container', "A membership confirmation and receipt has been sent to {$firstName}@memberson.com."); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); // click through to the Membership Renewal Link - $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); + $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); // Record contribution and set number of terms to 2 @@ -400,7 +396,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForElementPresent('num_terms'); $this->type('num_terms', ''); $this->type('num_terms', '2'); - // added sleep to make sure jscript onchange for total_amount has a chance to fire + + // Because it tends to cause problems, all uses of sleep() must be justified in comments + // Sleep should never be used for wait for anything to load from the server + // Justification for this instance: make sure onchange for total_amount has a chance to fire sleep(2); $this->click('total_amount'); $this->verifyValue('total_amount', "200.00"); @@ -414,15 +413,14 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { // save the renewed membership $this->click('_qf_MembershipRenewal_upload-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); // page was loaded $this->waitForTextPresent($sourceText); - $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); // click through to the membership view screen - $this->click("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); + $this->click("xpath=//div[@id='memberships']//table/tbody/tr/td[9]/span/a[text()='View']"); $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); @@ -442,4 +440,4 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { ); $this->webtestVerifyTabularData($verifyMembershipRenewData); } -} \ No newline at end of file +}