CRM-12378 a new webtest helper function introduction which can help detect break...
[civicrm-core.git] / tests / phpunit / WebTest / Event / AddParticipationTest.php
index fd24855fac0e9b5240e3ae50c85a7f205f0b1888..a5cda779ffc5c0e0457815eb30205f9b56abd029 100644 (file)
@@ -24,7 +24,6 @@
  +--------------------------------------------------------------------+
 */
 
-
 require_once 'CiviTest/CiviSeleniumTestCase.php';
 class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
 
@@ -90,14 +89,13 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // Is status message correct?
-    $this->assertElementContainsText("crm-notification-container", "Event registration for $displayName has been added", "Status message didn't show up after saving!");
+    $this->waitForText('crm-notification-container', "Event registration for $displayName has been added");
 
     $this->waitForElementPresent("xpath=//div[@id='Events']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
     //click through to the participant view screen
     $this->click("xpath=//div[@id='Events']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
     $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
 
-
     $this->webtestVerifyTabularData(
       array(
         'Event' => 'Rain-forest Cup Youth Soccer Tournament',
@@ -160,7 +158,7 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     //Is custom group created?
-    $this->assertElementContainsText("crm-notification-container", "Your custom field set '$customGroupTitle' has been added. You can add custom fields now.");
+    $this->waitForText('crm-notification-container', "Your custom field set '$customGroupTitle' has been added. You can add custom fields now.");
 
     //add custom field - alphanumeric checkbox
     $checkboxFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
@@ -180,7 +178,6 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->type('option_label_3', $checkboxOptionLabel3);
     $this->type('option_value_3', '3');
 
-
     //enter options per line
     $this->type('options_per_line', '2');
 
@@ -198,7 +195,7 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     //Is custom field created?
-    $this->assertElementContainsText("crm-notification-container", "Your custom field '$checkboxFieldLabel' has been saved.");
+    $this->waitForText('crm-notification-container', "Your custom field '$checkboxFieldLabel' has been saved.");
 
     //create another custom field - Integer Radio
     $this->click("//a[@id='newCustomField']/span");
@@ -289,7 +286,7 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // Is status message correct?
-    $this->assertElementContainsText("crm-notification-container", "Event registration for $displayName has been added", "Status message didn't show up after saving!");
+    $this->waitForText('crm-notification-container', "Event registration for $displayName has been added");
 
     $this->waitForElementPresent("xpath=//div[@id='Events']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
     //click through to the participant view screen
@@ -327,10 +324,11 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     );
   }
 
-  function testEventAddMultipleParticipants() {    
+  function testEventAddMultipleParticipants() {
+
     // Log in using webtestLogin() method
     $this->webtestLogin();
-    
+
     $processorId = $this->webtestAddPaymentProcessor('dummy' . substr(sha1(rand()), 0, 7));
     $rand = substr(sha1(rand()), 0, 7);
     $firstName = 'First' . $rand;
@@ -339,19 +337,19 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $lastName2 = 'Last' . $rand;
 
     $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone&mode=test&eid=3");
-    
+
     $this->assertTrue($this->isTextPresent("Register New Participant"), "Page title 'Register New Participant' missing");
     $this->assertTrue($this->isTextPresent("A TEST transaction will be submitted"), "test mode status 'A TEST transaction will be submitted' missing");
     $this->_fillParticipantDetails($firstName, $lastName, $processorId);
     $this->click('_qf_Participant_upload_new-bottom');
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    
+
     $this->assertTrue($this->isTextPresent("Register New Participant"), "Page title 'Register New Participant' missing");
     $this->assertTrue($this->isTextPresent("A TEST transaction will be submitted"), "test mode status 'A TEST transaction will be submitted' missing");
     $this->_fillParticipantDetails($firstName, $lastName2, $processorId);
     $this->click('_qf_Participant_upload_new-bottom');
     $this->waitForPageToLoad($this->getTimeoutMsec());
-    
+
     //searching the paricipants
     $this->openCiviPage("event/search", "reset=1");
     $this->type('sort_name', $firstName);
@@ -363,21 +361,33 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->check('participant_test');
     $this->click("_qf_Search_refresh");
     $this->waitForElementPresent("participantSearch");
-      
+
     //verifying the registered participants
     $names = array( "{$lastName}, {$firstName}", "{$lastName2}, {$firstName}" );
     $status = "Registered (test)";
-    
+
     foreach($names as $name) {
       $this->verifyText("xpath=//div[@id='participantSearch']//table//tbody//tr/td[@class='crm-participant-sort_name']/a[text()='{$name}']/../../td[9]", preg_quote($status));
       $this->verifyText("xpath=//div[@id='participantSearch']//table//tbody//tr/td[@class='crm-participant-sort_name']/a[text()='{$name}']/../../td[4]/a", preg_quote($eventName));
 }
   }
 
+  function testAjaxCustomGroupLoad() {
+    $this->webtestLogin();
+
+    $customSets = array(
+      array('entity' => 'ParticipantEventName', 'subEntity' => 'Fall Fundraiser Dinner',
+        'triggerElement' => array('name' => "event_id", 'type' => "select")),
+      array('entity' => 'ParticipantRole', 'subEntity' => 'Attendee','triggerElement' => array('type' => "checkbox"))
+    );
+    $pageUrl = array('url' => "participant/add", 'args' => "reset=1&action=add&context=standalone");
+    $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
+  }
+
   function _fillParticipantDetails($firstName, $lastName, $processorId) {
     $this->select("id=profiles_1", "label=New Individual");
     $this->waitForElementPresent('_qf_Edit_next');
-    
+
     $this->type("id=first_name", $firstName);
     $this->type("id=last_name", $lastName);
     $this->click("id=_qf_Edit_next");
@@ -387,5 +397,4 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->webtestAddCreditCardDetails();
     $this->webtestAddBillingDetails();
   }
-}
-
+}
\ No newline at end of file