more test cleanups
authorPratik Joshi <pratik.joshi@webaccess.co.in>
Fri, 8 Mar 2013 17:22:28 +0000 (22:52 +0530)
committerPratik Joshi <pratik.joshi@webaccess.co.in>
Fri, 8 Mar 2013 17:22:28 +0000 (22:52 +0530)
tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php
tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php
tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php

index 83f0bc5593a13dca01d5ae1888b4b5aee2f4d174..30cdc36403771f3ec012aaf82178f5a072414178 100644 (file)
@@ -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
index e794de94189ed0b17fcc8242ed82e042d01a5df2..a59277a10891bb218f937f86acc673c48946b5b0 100644 (file)
@@ -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;
index 8b11323143015e39aa9ec0085513b78c60ceebe0..86cef3729072fc402912844a5faa990212dafc3f 100644 (file)
@@ -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;