Merge pull request #4903 from colemanw/INFRA-132
[civicrm-core.git] / tests / phpunit / WebTest / Event / ParticipantCountTest.php
index 8b16442c4b67ed6ecd5ca614583f54a453eae93d..194f0968d9b95769f9071364cf99714a3704d7da 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
 */
 
 require_once 'CiviTest/CiviSeleniumTestCase.php';
+
+/**
+ * Class WebTest_Event_ParticipantCountTest
+ */
 class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase {
 
   protected function setUp() {
     parent::setUp();
   }
 
-  function testParticipantCountWithFeelevel() {
+  public function testParticipantCountWithFeelevel() {
     // Log in using webtestLogin() method
     $this->webtestLogin();
 
-    // We need a payment processor
-    $processorName = 'Webtest Dummy' . substr(sha1(rand()), 0, 7);
+    // Use default payment processor
+    $processorName = 'Test Processor';
     $this->webtestAddPaymentProcessor($processorName);
 
     // create an event
@@ -69,7 +73,7 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase {
 
     $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
     $this->type('first_name', 'Mary');
-    $this->type('last_name', 'Jones'. substr(sha1(rand()), 0, 5));
+    $this->type('last_name', 'Jones' . substr(sha1(rand()), 0, 5));
     $this->type('email-Primary', $email);
 
     // fill billing details and register
@@ -86,7 +90,7 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase {
     $this->click("xpath=//input[@class='crm-form-radio']");
     $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
     $this->type('first_name', 'Mary');
-    $this->type('last_name', 'Jones'. substr(sha1(rand()), 0, 5));
+    $this->type('last_name', 'Jones' . substr(sha1(rand()), 0, 5));
     $this->type('email-Primary', $email);
 
     // fill billing details and register
@@ -102,15 +106,15 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // verify number of registered participants
-    $this->assertStringsPresent(array('2 Result'));
+    $this->assertElementContainsText("xpath=//div[@id='search-status']/table/tbody/tr[1]/td", '2 Results');
   }
 
-  function testParticipantCountWithPriceset() {
+  public function testParticipantCountWithPriceset() {
     // Log in using webtestLogin() method
     $this->webtestLogin();
 
-    // We need a payment processor
-    $processorName = 'Webtest Dummy' . substr(sha1(rand()), 0, 7);
+    // Use default payment processor
+    $processorName = 'Test Processor';
     $this->webtestAddPaymentProcessor($processorName);
 
     // create priceset
@@ -184,7 +188,8 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase {
       else {
         $this->_testAddMultipleChoiceOptions($field['options']);
       }
-      $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom');
+      $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom', FALSE);
+      $this->waitForText("crm-notification-container", "Price Field '$label' has been saved.");
     }
 
     // create event.
@@ -285,14 +290,18 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
     // verify number of participants records and total participant count
-    $this->assertStringsPresent(array('2 Result', 'Actual participant count : 24'));
+    $this->assertStringsPresent(array('2 Results', 'Actual participant count : 24'));
 
     // CRM-7953, check custom search Price Set Details for Event
     // Participants
     $this->_testPricesetDetailsCustomSearch($paramsEvent, $participants, $priceFieldOptionCounts);
   }
 
-  function _testAddSet($setTitle, $financialType = 'Event Fee') {
+  /**
+   * @param $setTitle
+   * @param string $financialType
+   */
+  public function _testAddSet($setTitle, $financialType = 'Event Fee') {
     $this->openCiviPage('admin/price', 'reset=1&action=add', '_qf_Set_next-bottom');
 
     // Enter Priceset fields (Title, Used For ...)
@@ -305,7 +314,10 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase {
     $this->clickLink('_qf_Set_next-bottom', '_qf_Field_next-bottom');
   }
 
-  function _testAddMultipleChoiceOptions($options) {
+  /**
+   * @param $options
+   */
+  public function _testAddMultipleChoiceOptions($options) {
     foreach ($options as $oIndex => $oValue) {
       $this->type("option_label_{$oIndex}", $oValue['label']);
       $this->type("option_amount_{$oIndex}", $oValue['amount']);
@@ -318,7 +330,12 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase {
     $this->click('CIVICRM_QFID_1_2');
   }
 
-  function _testAddEvent($params) {
+  /**
+   * @param array $params
+   *
+   * @return string
+   */
+  public function _testAddEvent($params) {
     $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
 
     $this->select('event_type_id', "value={$params['event_type_id']}");
@@ -371,6 +388,7 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase {
     $this->check('is_online_registration');
     $this->assertChecked('is_online_registration');
 
+    $this->click('intro_text-plain');
     $this->fillRichTextField('intro_text', 'Fill in all the fields below and click Continue.');
 
     // enable confirmation email
@@ -391,7 +409,10 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase {
     return $this->getLocation();
   }
 
-  function _testRegisterWithBillingInfo($participant = array()) {
+  /**
+   * @param array $participant
+   */
+  public function _testRegisterWithBillingInfo($participant = array()) {
     $this->waitForElementPresent("credit_card_type");
     $this->select('credit_card_type', 'value=Visa');
     $this->type('credit_card_number', '4111111111111111');
@@ -415,14 +436,19 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase {
     $this->assertStringsPresent($thankStrings);
   }
 
-  function _testPricesetDetailsCustomSearch($eventParams, $participants, $priceFieldOptionCounts) {
+  /**
+   * @param array $eventParams
+   * @param $participants
+   * @param $priceFieldOptionCounts
+   */
+  public function _testPricesetDetailsCustomSearch($eventParams, $participants, $priceFieldOptionCounts) {
     $this->openCiviPage('contact/search/custom', 'csid=9&reset=1');
 
     $this->select('event_id', 'label=' . $eventParams['title']);
     $this->click('_qf_Custom_refresh-bottom');
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
-    $tableHeaders = array('Contact Id', 'Participant Id', 'Name');
+    $tableHeaders = array('Contact ID', 'Participant ID', 'Name');
     $tableHeaders = array_merge($tableHeaders, array_keys(current($priceFieldOptionCounts)));
 
     $tdnum = 2;
@@ -441,4 +467,3 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase {
     }
   }
 }
-