Merge pull request #71 from dpradeep/merge-20140930
[civicrm-core.git] / tests / phpunit / WebTest / Campaign / OnlineEventRegistrationTest.php
index 4bf2a7b47c7e680463dc3b1b06f7ea78607fcc8e..146538eeb855779f3925b2aa70c9d04687808da6 100644 (file)
 */
 
 require_once 'CiviTest/CiviSeleniumTestCase.php';
+
+/**
+ * Class WebTest_Campaign_OnlineEventRegistrationTest
+ */
 class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase {
 
   protected function setUp() {
@@ -51,7 +55,7 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase
     // add to group
     $this->select("group_id", "label=$groupName");
     $this->click("_qf_GroupContact_next");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->waitForElementPresent('link=Remove');
 
     $firstName2 = substr(sha1(rand()), 0, 7);
     $this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org");
@@ -64,7 +68,7 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase
     // add to group
     $this->select("group_id", "label=$groupName");
     $this->click("_qf_GroupContact_next");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->waitForElementPresent('link=Remove');
 
     // Enable CiviCampaign module if necessary
     $this->enableComponents(array('CiviCampaign'));
@@ -88,9 +92,7 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase
     $this->type("description", "This is a test campaign");
 
     // include groups for the campaign
-    $this->addSelection("includeGroups-f", "label=$groupName");
-    $this->click("//option[@value=4]");
-    $this->click("add");
+    $this->multiselect2("includeGroups", array("$groupName", "Advisory Board"));
 
     // fill the end date for campaign
     $this->webtestFillDate("end_date", "+1 year");
@@ -104,15 +106,19 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase
 
     $this->waitForText('crm-notification-container', "Campaign $title");
 
-    $this->waitForElementPresent("//div[@id='campaignList']/div[@class='dataTables_wrapper']/table/tbody/tr/td[text()='{$campaignTitle}']/../td[1]");
-    $id = (int) $this->getText("//div[@id='campaignList']/div[@class='dataTables_wrapper']/table/tbody/tr/td[text()='{$campaignTitle}']/../td[1]");
+    $this->waitForElementPresent("//div[@id='campaignList']/div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[text()='{$campaignTitle}']/../td[1]");
+    $id = (int) $this->getText("//div[@id='campaignList']/div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[text()='{$campaignTitle}']/../td[1]");
 
     $this->onlineParticipantAddTest($campaignTitle, $id);
   }
 
+  /**
+   * @param $campaignTitle
+   * @param $id
+   */
   function onlineParticipantAddTest($campaignTitle, $id) {
-    // We need a payment processor
-    $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
+    // Use default payment processor
+    $processorName = 'Test Processor';
     $paymentProcessorId = $this->webtestAddPaymentProcessor($processorName);
 
     $this->openCiviPage("event/add", "reset=1&action=add");
@@ -143,6 +149,11 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase
     $this->_testOnlineRegistration($campaignTitle, $registerUrl, $numberRegistrations, $anonymous);
   }
 
+  /**
+   * @param $id
+   * @param $eventTitle
+   * @param $eventDescription
+   */
   function _testAddEventInfo($id, $eventTitle, $eventDescription) {
     $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
 
@@ -172,25 +183,35 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase
     $this->click("_qf_EventInfo_upload-bottom");
   }
 
+  /**
+   * @param $streetAddress
+   */
   function _testAddLocation($streetAddress) {
     // Wait for Location tab form to load
-    $this->waitForPageToLoad($this->getTimeoutMsec());
     $this->waitForElementPresent("_qf_Location_upload-bottom");
 
     // Fill in address fields
     $streetAddress = "100 Main Street";
+    $this->waitForElementPresent('address_1_street_address');
     $this->type("address_1_street_address", $streetAddress);
+    $this->waitForElementPresent('address_1_city');
     $this->type("address_1_city", "San Francisco");
     $this->type("address_1_postal_code", "94117");
+    $this->select('address_1_country_id', 'United States');
     $this->select("address_1_state_province_id", "value=1004");
     $this->type("email_1_email", "info@civicrm.org");
 
-    $this->clickLink("_qf_Location_upload-bottom");
+    $this->clickLink("_qf_Location_upload-bottom", '', FALSE);
 
     // Wait for "saved" status msg
     $this->waitForText('crm-notification-container', "saved");
   }
 
+  /**
+   * @param bool $discount
+   * @param bool $priceSet
+   * @param $processorId
+   */
   function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorId) {
     // Go to Fees tab
     $this->click("link=Fees");
@@ -217,22 +238,26 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase
     $this->click("_qf_Fee_upload-bottom");
 
     // Wait for "saved" status msg
-    $this->waitForPageToLoad($this->getTimeoutMsec());
     $this->waitForText('crm-notification-container', "saved");
   }
 
+  /**
+   * @param $registerIntro
+   * @param bool $multipleRegistrations
+   */
   function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) {
     // Go to Online Registration tab
     $this->click("link=Online Registration");
     $this->waitForElementPresent("_qf_Registration_upload-bottom");
 
-    $this->check("is_online_registration");
+    $this->click("is_online_registration");
     $this->assertChecked("is_online_registration");
     if ($multipleRegistrations) {
       $this->check("is_multiple_registrations");
       $this->assertChecked("is_multiple_registrations");
     }
 
+    $this->click('intro_text-plain');
     $this->fillRichTextField("intro_text", $registerIntro);
 
     // enable confirmation email
@@ -241,10 +266,13 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase
     $this->type("confirm_from_email", "jane.doe@example.org");
 
     $this->click("_qf_Registration_upload-bottom");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
     $this->waitForText('crm-notification-container', "saved");
   }
 
+  /**
+   * @param $eventTitle
+   * @param $eventInfoStrings
+   */
   function _testVerifyEventInfo($eventTitle, $eventInfoStrings) {
     // verify event input on info page
     // start at Manage Events listing
@@ -255,6 +283,11 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase
     $this->assertStringsPresent($eventInfoStrings);
   }
 
+  /**
+   * @param $registerStrings
+   *
+   * @return string
+   */
   function _testVerifyRegisterPage($registerStrings) {
     // Go to Register page and check for intro text and fee levels
     $this->click("link=Register Now");
@@ -263,6 +296,12 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase
     return $this->getLocation();
   }
 
+  /**
+   * @param $campaignTitle
+   * @param $registerUrl
+   * @param int $numberRegistrations
+   * @param bool $anonymous
+   */
   function _testOnlineRegistration($campaignTitle, $registerUrl, $numberRegistrations = 1, $anonymous = TRUE) {
     if ($anonymous) {
       $this->webtestLogout();
@@ -318,7 +357,7 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase
 
     $this->type('sort_name', $email);
     $this->click("_qf_Search_refresh");
-    $this->waitForElementPresent("_qf_Search_next_print");
+    $this->waitForElementPresent("//*[@id='participantSearch']");
     $this->click("xpath=//div[@id='participantSearch']/table/tbody/tr/td[11]/span/a[text()='Edit']");
     $this->waitForElementPresent("_qf_Participant_cancel-bottom");
     $this->assertElementContainsText('crm-container', "$campaignTitle");