From f2ff7d84a36117085b15a60af747f3292fa695af Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Fri, 8 Mar 2013 22:52:28 +0530 Subject: [PATCH] more test cleanups --- .../Member/OfflineMembershipRenewTest.php | 47 ++++++++++--------- .../OnlineAutoRenewMembershipGCTest.php | 25 ++++------ .../Member/OnlineAutoRenewMembershipTest.php | 43 ++++++----------- 3 files changed, 47 insertions(+), 68 deletions(-) diff --git a/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php b/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php index 83f0bc5593..30cdc36403 100644 --- a/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php +++ b/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php @@ -77,7 +77,9 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForTextPresent($sourceText); // Is status message correct? - $this->assertTrue($this->isTextPresent("{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."), "Status message didn't show up after saving!"); + $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.", + "Status message didn't show up after saving!" + ); $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); @@ -114,10 +116,8 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { 'Start date' => $startDate, 'End date' => $endDate, ); - foreach ($verifyMembershipRenewData as $label => $value) { - $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value)); - } - } + $this->webtestVerifyTabularData($verifyMembershipRenewData); + } function testOfflineMemberRenewOverride() { $this->open($this->sboxPath); @@ -164,7 +164,7 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { // select the financial type for the selected membership type $this->select('financial_type_id', 'value=2'); - + // the amount for the selected membership type $this->type('total_amount', '100.00'); @@ -185,7 +185,9 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForTextPresent($sourceText); // Is status message correct? - $this->assertTrue($this->isTextPresent("{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."), "Status message didn't show up after saving!"); + $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.", + "Status message didn't show up after saving!" + ); $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); @@ -223,9 +225,7 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { 'Start date' => $startDate, 'End date' => $endDate, ); - foreach ($verifyMembershipRenewOverrideData as $label => $value) { - $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value)); - } + $this->webtestVerifyTabularData($verifyMembershipRenewOverrideData); } function testOfflineMembershipRenewChangeType() { @@ -273,7 +273,9 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForTextPresent($sourceText); // Is status message correct? - $this->assertTrue($this->isTextPresent("{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."), "Status message didn't show up after saving!"); + $this->assertElementContainsText('crm-notification-container', "{$membershipTypes['membership_type']} membership for $firstName Memberson has been added.", + "Status message didn't show up after saving!" + ); $this->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[7]/span[2][text()='more']/ul/li/a[text()='Renew']"); @@ -320,9 +322,7 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { 'Start date' => $startDate, 'End date' => $endDate, ); - foreach ($verifyMembershipData as $label => $value) { - $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value)); - } + $this->webtestVerifyTabularData($verifyMembershipData); } function testOfflineMembershipRenewMultipleTerms() { @@ -380,8 +380,12 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForTextPresent($sourceText); // Is status message correct? - $this->assertTrue($this->isTextPresent("{$membershipTypes['membership_type']} membership for $firstName Memberson has been added."), "Status message didn't show up after saving!"); - $this->assertTrue($this->isTextPresent("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->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->waitForElementPresent("xpath=//div[@id='Memberships']//table/tbody/tr/td[9]/span[2][text()='more']/ul/li/a[text()='Renew']"); @@ -391,7 +395,7 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_MembershipRenewal_cancel-bottom'); // Record contribution and set number of terms to 2 $this->click('record_contribution'); - $this->waitForElementPresent( 'financial_type_id' ); + $this->waitForElementPresent('financial_type_id'); $this->click('changeTermsLink'); $this->waitForElementPresent('num_terms'); $this->type('num_terms', ''); @@ -400,7 +404,7 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { sleep(2); $this->click('total_amount'); $this->verifyValue('total_amount', "200.00"); - $this->select( 'financial_type_id', "label=Member Dues" ); + $this->select('financial_type_id', "label=Member Dues"); $this->select('payment_instrument_id', "label=Check"); $this->waitForElementPresent('check_number'); $this->type('check_number', '1024'); @@ -436,9 +440,6 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { 'Start date' => $startDate, 'End date' => $endDate, ); - foreach ($verifyMembershipRenewData as $label => $value) { - $this->verifyText("xpath=//form[@id='MembershipView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", preg_quote($value)); - } + $this->webtestVerifyTabularData($verifyMembershipRenewData); } -} - +} \ No newline at end of file diff --git a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php index e794de9418..a59277a108 100644 --- a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php +++ b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php @@ -37,9 +37,7 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas $pageId = $this->_configureMembershipPage(); //now do the test membership signup. - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&action=preview&id={$pageId}"); - $this->waitForPageToLoad("3000"); - $this->waitForElementPresent("_qf_Main_upload-bottom"); + $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom"); $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); $this->click("auto_renew"); @@ -53,7 +51,7 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas $this->waitForElementPresent("_qf_Confirm_next_checkout"); $text = 'I want this membership to be renewed automatically every 1 year(s).'; - $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); + $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); $this->click("_qf_Confirm_next_checkout"); sleep(5); @@ -71,10 +69,7 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas $this->waitForPageToLoad($this->getTimeoutMsec()); //now do the test membership signup. - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&action=preview&id={$pageId}"); - $this->waitForPageToLoad("3000"); - $this->waitForElementPresent("_qf_Main_upload-bottom"); - + $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom"); $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); $this->click("auto_renew"); @@ -88,7 +83,7 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas $this->waitForElementPresent("_qf_Confirm_next_checkout"); $text = 'I want this membership to be renewed automatically every 1 year(s).'; - $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); + $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); $this->click("_qf_Confirm_next_checkout"); sleep(5); @@ -111,8 +106,7 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas $this->webtestAddPaymentProcessor($processorName, 'Google_Checkout'); // -- start updating membership types - $this->open($this->sboxPath . "civicrm/admin/member/membershipType/add?action=update&id=1&reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('admin/member/membershipType/add', 'action=update&id=1&reset=1'); $this->waitForElementPresent("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]"); $this->click("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]"); @@ -126,8 +120,7 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas $this->click("_qf_MembershipType_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . "civicrm/admin/member/membershipType/add?action=update&id=2&reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('admin/member/membershipType/add', 'action=update&id=2&reset=1'); $this->waitForElementPresent("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]"); $this->click("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]"); @@ -180,16 +173,14 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas ); // now logout and login with admin credentials - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('logout', 'reset=1', NULL); //make sure we do have required permissions. $permissions = array("edit-1-make-online-contributions"); $this->changePermissions($permissions); // now logout and do membership test that way - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('logout', 'reset=1', NULL); } return $pageId; diff --git a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php index 8b11323143..86cef37290 100644 --- a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php +++ b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php @@ -37,10 +37,8 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $pageId = $this->_configureMembershipPage(); //now do the test membership signup. - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&action=preview&id={$pageId}"); - $this->waitForPageToLoad("3000"); - $this->waitForElementPresent("_qf_Main_upload-bottom"); - + $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom"); + $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); $this->click("auto_renew"); @@ -56,13 +54,13 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->waitForElementPresent("_qf_Confirm_next-bottom"); $text = 'I want this membership to be renewed automatically every 1 year(s).'; - $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); + $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); $this->click("_qf_Confirm_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); $text = 'This membership will be renewed automatically every 1 year(s).'; - $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); + $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); } function testOnlineAutoRenewMembershipAuthenticated() { @@ -74,10 +72,8 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->waitForPageToLoad($this->getTimeoutMsec()); //now do the test membership signup. - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&action=preview&id={$pageId}"); - $this->waitForPageToLoad("3000"); - $this->waitForElementPresent("_qf_Main_upload-bottom"); - + $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom"); + $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); $this->click("auto_renew"); @@ -89,17 +85,16 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->type('email-5', "{$lastName}@example.com"); $this->click("_qf_Main_upload-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent("_qf_Confirm_next-bottom"); $text = 'I want this membership to be renewed automatically every 1 year(s).'; - $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); + $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); $this->click("_qf_Confirm_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); $text = 'This membership will be renewed automatically every 1 year(s).'; - $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); + $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); } function testOnlinePendingAutoRenewMembershipAnonymous() { @@ -107,10 +102,8 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $pageId = $this->_configureMembershipPage(); //now do the test membership signup. - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&action=preview&id={$pageId}"); - $this->waitForPageToLoad("3000"); - $this->waitForElementPresent("_qf_Main_upload-bottom"); - + $this->openCiviPage('contribute/transact', "reset=1&action=preview&id={$pageId}", "_qf_Main_upload-bottom"); + $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); $this->click("auto_renew"); @@ -120,17 +113,16 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->type('email-5', "{$lastName}@example.com"); $this->click("_qf_Main_upload-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent("_qf_Confirm_next-bottom"); $text = 'I want this membership to be renewed automatically every 1 year(s).'; - $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); + $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); $this->click("_qf_Confirm_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); $text = 'This membership will be renewed automatically every 1 year(s).'; - $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); + $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); } function _configureMembershipPage() { @@ -147,10 +139,8 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->webtestAddPaymentProcessor($processorName, 'AuthNet'); // -- start updating membership types - $this->open($this->sboxPath . "civicrm/admin/member/membershipType/add?action=update&id=1&reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('admin/member/membershipType/add', "action=update&id=1&reset=1", "_qf_MembershipType_upload-bottom"); - $this->waitForElementPresent("_qf_MembershipType_upload-bottom"); $this->click("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]"); $this->type("duration_interval", "1"); @@ -162,10 +152,8 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->click("_qf_MembershipType_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . "civicrm/admin/member/membershipType/add?action=update&id=2&reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('admin/member/membershipType/add', "action=update&id=2&reset=1", "_qf_MembershipType_upload-bottom"); - $this->waitForElementPresent("_qf_MembershipType_upload-bottom"); $this->click("xpath=//div[@id='membership_type_form']//table/tbody/tr[6]/td/label[contains(text(), 'Auto-renew Option')]/../../td[2]/label[contains(text(), 'Give option, but not required')]"); $this->type("duration_interval", "1"); @@ -221,8 +209,7 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->changePermissions($permissions); // now logout and do membership test that way - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('logout', 'reset=1', NULL); } return $pageId; -- 2.25.1