CRM-15031 Event Webtest Fix
[civicrm-core.git] / tests / phpunit / WebTest / Event / AddParticipationTest.php
index db5390566fdf93078b1adad193ea55347d5133c0..00590e6d8d8acb66a027098899b0c9e4a5783096 100644 (file)
 */
 
 require_once 'CiviTest/CiviSeleniumTestCase.php';
+
+/**
+ * Class WebTest_Event_AddParticipationTest
+ */
 class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
 
   protected function setUp() {
@@ -191,7 +195,7 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->click('is_searchable');
 
     //clicking save
-    $this->click('_qf_Field_next');
+    $this->click('_qf_Field_done-bottom');
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     //Is custom field created?
@@ -232,7 +236,7 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->click('is_searchable');
 
     //clicking save
-    $this->click('_qf_Field_next');
+    $this->click('_qf_Field_done-bottom');
 
     $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
 
@@ -245,10 +249,10 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     // Select roles
     $this->multiselect2('role_id', array('Volunteer', 'Host'));
 
-    $this->waitForElementPresent("xpath=//*[@id='2_chk']//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper collapsed']");
-    $this->click("xpath=//*[@id='2_chk']/div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper collapsed']//div[1]");
-    $this->click("xpath=//*[@id='2_chk']/div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper']//div[2]//table//tbody//tr[2]//td[2]//table//tbody//tr[1]//td[1]//label");
-    $this->click("xpath=//*[@id='2_chk']/div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper']//div[2]//table//tbody//tr[4]//td[2]//table//tbody//tr[1]//td[1]//label");
+    $this->waitForElementPresent("xpath=//div[@class='crm-customData-block']//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper collapsed']");
+    $this->click("xpath=//div[@class='crm-customData-block']//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper collapsed']//div[1]");
+    $this->click("xpath=//div[@class='crm-customData-block']//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper']//div[2]//table//tbody//tr[2]//td[2]//table//tbody//tr[1]//td[1]//label");
+    $this->click("xpath=//div[@class='crm-customData-block']//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper']//div[2]//table//tbody//tr[4]//td[2]//table//tbody//tr[1]//td[1]//label");
 
     // Choose Registration Date.
     // Using helper webtestFillDate function.
@@ -313,12 +317,12 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
       array(
         'From' => $displayName,
         'Financial Type' => 'Event Fee',
-        'Total Amount' => '$ 800.00',
         'Contribution Status' => 'Completed',
         'Paid By' => 'Check',
         'Check Number' => '1044',
       )
     );
+    $this->verifyText("xpath=//table/tbody/tr/td[text()='Total Amount']/following-sibling::td/strong", preg_quote('$ 800.00'), 'In line ' . __LINE__);
   }
 
   function testEventAddMultipleParticipants() {
@@ -351,10 +355,7 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->openCiviPage("event/search", "reset=1");
     $this->type('sort_name', $firstName);
     $eventName = "Rain-forest Cup Youth Soccer Tournament";
-    $this->type("event_name", $eventName);
-    $this->click("event_name");
-    $this->waitForElementPresent("css=div.ac_results-inner li");
-    $this->click("css=div.ac_results-inner li");
+    $this->select2("event_id", $eventName, FALSE, FALSE);
     $this->check('participant_test');
     $this->click("_qf_Search_refresh");
     $this->waitForElementPresent("participantSearch");
@@ -375,7 +376,7 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $customSets = array(
       array('entity' => 'ParticipantEventName', 'subEntity' => 'Fall Fundraiser Dinner',
         'triggerElement' => array('name' => "event_id", 'type' => "select2")),
-      array('entity' => 'ParticipantRole', 'subEntity' => 'Attendee','triggerElement' => array('type' => "checkbox"))
+      array('entity' => 'ParticipantRole', 'subEntity' => 'Attendee','triggerElement' => array('name' => 'role_id', 'type' => "select"))
     );
     $pageUrl = array('url' => "participant/add", 'args' => "reset=1&action=add&context=standalone");
     $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
@@ -418,12 +419,19 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     }
   }
 
+  /**
+   * @param $firstName
+   * @param $lastName
+   * @param $processorId
+   */
   function _fillParticipantDetails($firstName, $lastName, $processorId) {
     $this->webtestNewDialogContact($firstName, $lastName);
 
     $this->select('payment_processor_id', "value={$processorId}");
-    $this->verifySelectedValue("event_id", "3");
-    $this->check("role_id[1]");
+    $event_id = $this->getAttribute("xpath=//*[@id='event_id']@value");
+    //check if it is the selected event
+    $this->assertEquals($event_id, 3);
+    $this->select("role_id", "value=1");
     $this->webtestAddCreditCardDetails();
     $this->webtestAddBillingDetails();
   }