Merge pull request #5252 from JKingsnorth/CRM-10551
[civicrm-core.git] / tests / phpunit / WebTest / Event / MultiprofileEventTest.php
index 831d44b0be6ca3365692507e1a867e0aa92e6719..5d0bebd42750912078778429ba43bb7d6bfeb7b6 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
    +--------------------------------------------------------------------+
-   | CiviCRM version 4.5                                                |
+   | CiviCRM version 4.6                                                |
    +--------------------------------------------------------------------+
-   | Copyright CiviCRM LLC (c) 2004-2014                                |
+   | Copyright CiviCRM LLC (c) 2004-2015                                |
    +--------------------------------------------------------------------+
    | This file is a part of CiviCRM.                                    |
    |                                                                    |
@@ -35,7 +35,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
     parent::setUp();
   }
 
-  function testCreateEventRegisterPage() {
+  public function testCreateEventRegisterPage() {
     // Log in using webtestLogin() method
     $this->webtestLogin();
 
@@ -97,8 +97,8 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
     $name = $firstName . " " . $lastName;
     $status = 'Registered';
 
-    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name));
-    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
+    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table[1]/tbody/tr[1]/td[2]/strong/a", preg_quote($name));
+    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table[1]/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
     $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
 
     // Find additional  Participant
@@ -110,9 +110,9 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
     $name = $participantfname . " " . $participantlname;
     $status = 'Registered';
 
-    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name));
-    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
-    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
+    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table[1]/tbody/tr[1]/td[2]/strong/a", preg_quote($name));
+    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table[1]/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
+    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table[1]/tbody/tr[6]/td[2]", preg_quote($status));
 
     // delete all custom data
     if (isset($cfId)) {
@@ -128,7 +128,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
   }
 
-  function testAnoumyousRegisterPage() {
+  public function testAnoumyousRegisterPage() {
     // add the required Drupal permission
     $permission = array('edit-1-access-all-custom-data');
     $this->changePermissions($permission);
@@ -200,7 +200,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
     $name = $firstName . " " . $lastName;
     $status = 'Registered';
 
-    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name));
+    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/strong/a", preg_quote($name));
     $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
     $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
 
@@ -213,7 +213,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
     $name = $participantfname . " " . $participantlname;
     $status = 'Registered';
 
-    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name));
+    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/strong/a", preg_quote($name));
     $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
     $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
 
@@ -238,7 +238,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
     $name = $firstName2 . " " . $lastName2;
     $status = 'Registered';
 
-    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name));
+    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/strong/a", preg_quote($name));
     $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
     $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
 
@@ -251,7 +251,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
     $name = $participantfname2 . " " . $participantlname2;
     $status = 'Registered';
 
-    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name));
+    $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/strong/a", preg_quote($name));
     $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
     $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
 
@@ -270,11 +270,13 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
   }
 
   /**
-   * @param $customGrpId1
+   * Get custom field ID.
+   *
+   * @param int $customGrpId1
    *
    * @return array
    */
-  function _testGetCustomFieldId($customGrpId1) {
+  public function _testGetCustomFieldId($customGrpId1) {
     $customId = array();
 
     // Create a custom data to add in profile
@@ -316,9 +318,9 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
   }
 
   /**
-   * @param $eventPageId
+   * @param int $eventPageId
    */
-  function _testRemoveProfile($eventPageId) {
+  public function _testRemoveProfile($eventPageId) {
     $this->openCiviPage("event/manage/settings", "reset=1&action=update&id=$eventPageId");
 
     // Go to Online Contribution tab
@@ -333,11 +335,11 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
   }
 
   /**
-   * @param $customId
+   * @param int $customId
    *
    * @return array
    */
-  function _testGetProfileId($customId) {
+  public function _testGetProfileId($customId) {
     // create profiles
     $profileId = array();
     $profilefield = array(
@@ -410,14 +412,16 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
   }
 
   /**
-   * @param $profilefield
+   * Test profile creation.
+   *
+   * @param array $profileField
    * @param int $location
    * @param $type
    *
    * @return null
    */
-  function _testCreateProfile($profilefield, $location = 0, $type) {
-    $locationfields = array(
+  public function _testCreateProfile($profileField, $location = 0, $type) {
+    $locationFields = array(
       'supplemental_address_1',
       'supplemental_address_2',
       'city',
@@ -429,22 +433,22 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
     );
 
     // Add new profile.
-    $profilename = "Profile_" . substr(sha1(rand()), 0, 7);
+    $profileName = "Profile_" . substr(sha1(rand()), 0, 7);
     $this->openCiviPage("admin/uf/group", "reset=1");
     $this->click('newCiviCRMProfile-top');
     $this->waitForElementPresent('_qf_Group_next-top');
 
     //Name of profile
-    $this->type('title', $profilename);
+    $this->type('title', $profileName);
     $this->click('uf_group_type_Profile');
     $this->click('_qf_Group_next-top');
     $this->waitForPageToLoad($this->getTimeoutMsec());
     $profileId = $this->urlArg('gid');
 
     //Add field to profile_testCreateProfile
-    foreach ($profilefield as $key => $value) {
+    foreach ($profileField as $key => $value) {
       $this->openCiviPage("admin/uf/group/field/add", "reset=1&action=add&gid=$profileId");
-      if (in_array($value, $locationfields)) {
+      if (in_array($value, $locationFields)) {
         $this->select("field_name[0]", "value={$type}");
         $this->select("field_name[1]", "value={$value}");
         $this->select("field_name[2]", "value={$location}");
@@ -465,7 +469,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
    * @param $eventTitle
    * @param $eventDescription
    */
-  function _testAddEventInfo($eventTitle, $eventDescription) {
+  public function _testAddEventInfo($eventTitle, $eventDescription) {
     $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
 
     $this->select("event_type_id", "value=1");
@@ -493,7 +497,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
   /**
    * @param $streetAddress
    */
-  function _testAddLocation($streetAddress) {
+  public function _testAddLocation($streetAddress) {
     // Wait for Location tab form to load
     $this->waitForPageToLoad($this->getTimeoutMsec());
     $this->waitForElementPresent("_qf_Location_upload-bottom");
@@ -520,7 +524,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
    * @param bool $priceSet
    * @param string $processorName
    */
-  function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro") {
+  public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro") {
     // Go to Fees tab
     $this->click("link=Fees");
     $this->waitForElementPresent("_qf_Fee_upload-bottom");
@@ -555,64 +559,66 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
   }
 
   /**
-   * @param $profileId
+   * Test adding multiple profiles.
+   *
+   * @param int $profileId
    *
    * @return null
    */
-  function _testAddMultipleProfile($profileId) {
+  public function _testAddMultipleProfile($profileId) {
     // Go to Online Contribution tab
     $this->click("link=Online Registration");
     $this->waitForElementPresent("_qf_Registration_upload-bottom");
     $this->click("is_online_registration");
     $this->check("is_multiple_registrations");
-    $this->select("xpath=//*[@id='custom_pre_id']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=1");
-    $this->select("xpath=//*[@id='custom_post_id']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[3]);
-    $this->select("xpath=//*[@id='additional_custom_post_id']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "- same as for main contact -");
+    $this->select("xpath=//*[@id='custom_pre_id']/parent::td/div[1]/div/span/select", "value=1");
+    $this->select("xpath=//*[@id='custom_post_id']/parent::td/div[1]/div/span/select", "value=" . $profileId[3]);
+    $this->select("xpath=//*[@id='additional_custom_post_id']/parent::td/div[1]/div/span/select", "- same as for main contact -");
 
     $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->waitForElementPresent("custom_post_id_multiple_1");
-    $this->select("xpath=//*[@id='custom_post_id_multiple_1']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[2]);
+    $this->select("xpath=//*[@id='custom_post_id_multiple_1']/parent::td/div[1]/div/span/select", "value=" . $profileId[2]);
 
     $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->waitForElementPresent("custom_post_id_multiple_2");
-    $this->select("xpath=//*[@id='custom_post_id_multiple_2']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[1]);
+    $this->select("xpath=//*[@id='custom_post_id_multiple_2']/parent::td/div[1]/div/span/select", "value=" . $profileId[1]);
 
     $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->waitForElementPresent("custom_post_id_multiple_3");
-    $this->select("xpath=//*[@id='custom_post_id_multiple_3']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[4]);
+    $this->select("xpath=//*[@id='custom_post_id_multiple_3']/parent::td/div[1]/div/span/select", "value=" . $profileId[4]);
 
     $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->waitForElementPresent("custom_post_id_multiple_4");
-    $this->select("xpath=//*[@id='custom_post_id_multiple_4']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[5]);
+    $this->select("xpath=//*[@id='custom_post_id_multiple_4']/parent::td/div[1]/div/span/select", "value=" . $profileId[5]);
 
     $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->waitForElementPresent("custom_post_id_multiple_5");
-    $this->select("xpath=//*[@id='custom_post_id_multiple_5']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[6]);
+    $this->select("xpath=//*[@id='custom_post_id_multiple_5']/parent::td/div[1]/div/span/select", "value=" . $profileId[6]);
 
     $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->waitForElementPresent("additional_custom_post_id_multiple_1");
-    $this->select("xpath=//*[@id='additional_custom_post_id_multiple_1']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[5]);
+    $this->select("xpath=//*[@id='additional_custom_post_id_multiple_1']/parent::td/div[1]/div/span/select", "value=" . $profileId[5]);
 
     $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->waitForElementPresent("additional_custom_post_id_multiple_2");
-    $this->select("xpath=//*[@id='additional_custom_post_id_multiple_2']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[1]);
+    $this->select("xpath=//*[@id='additional_custom_post_id_multiple_2']/parent::td/div[1]/div/span/select", "value=" . $profileId[1]);
 
     $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->waitForElementPresent("additional_custom_post_id_multiple_3");
-    $this->select("xpath=//*[@id='additional_custom_post_id_multiple_3']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[2]);
+    $this->select("xpath=//*[@id='additional_custom_post_id_multiple_3']/parent::td/div[1]/div/span/select", "value=" . $profileId[2]);
 
     $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add another profile (bottom of page)']");
     $this->waitForElementPresent("additional_custom_post_id_multiple_4");
-    $this->select("xpath=//*[@id='additional_custom_post_id_multiple_4']/parent::td/div[1]/div/span/select[@class='select2-offscreen']", "value=" . $profileId[3]);
+    $this->select("xpath=//*[@id='additional_custom_post_id_multiple_4']/parent::td/div[1]/div/span/select", "value=" . $profileId[3]);
 
     $this->click("CIVICRM_QFID_1_is_email_confirm");
     $this->type("confirm_from_name", "TestEvent");
@@ -627,17 +633,18 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
   }
 
   /**
-   * @param $eventPageId
-   * @param $customId
-   * @param $firstName
-   * @param $lastName
-   * @param $participantfname
-   * @param $participantlname
+   * @param int $eventPageId
+   * @param int $customId
+   * @param string $firstName
+   * @param string $lastName
+   * @param string $participantfname
+   * @param string $participantlname
    * @param $email1
    * @param $email2
    */
-  function _testEventRegistration($eventPageId, $customId, $firstName, $lastName,
-                                  $participantfname, $participantlname, $email1, $email2
+  public function _testEventRegistration(
+    $eventPageId, $customId, $firstName, $lastName,
+    $participantfname, $participantlname, $email1, $email2
   ) {
     $this->openCiviPage("event/register", "id={$eventPageId}&reset=1", "_qf_Register_upload-bottom");
     $this->select("additional_participants", "value=1");
@@ -645,7 +652,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
     $this->type("email-Primary", $email1);
     $this->type("first_name", $firstName);
     $this->type("last_name", $lastName);
-    $this->type("street_address-1", "Test street addres");
+    $this->type("street_address-1", "Test street address");
     $this->type("city-1", "Mumbai");
     $this->type("postal_code-1", "2354");
     $this->select("state_province-1", "value=1001");
@@ -693,7 +700,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
     $this->type("email-Primary", $email2);
     $this->type("first_name", $participantfname);
     $this->type("last_name", $participantlname);
-    $this->type("street_address-1", "participant street addres");
+    $this->type("street_address-1", "participant street address");
     $this->type("city-1", "pune");
     $this->type("postal_code-1", "2354");
     $this->select("state_province-1", "value=1001");
@@ -720,23 +727,23 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
   }
 
   /**
-   * @param $eventPageId
-   * @param $customId
-   * @param $firstName2
-   * @param $lastName2
-   * @param $participantfname2
+   * @param int $eventPageId
+   * @param int $customId
+   * @param string $firstName2
+   * @param string $lastName2
+   * @param string $participantfname2
    * @param $participantlname2
    * @param $email3
    * @param $email4
    */
-  function _testEventRegistrationAfterRemoving($eventPageId, $customId, $firstName2, $lastName2, $participantfname2, $participantlname2, $email3, $email4) {
+  public function _testEventRegistrationAfterRemoving($eventPageId, $customId, $firstName2, $lastName2, $participantfname2, $participantlname2, $email3, $email4) {
     $this->openCiviPage("event/register", "id={$eventPageId}&reset=1", "_qf_Register_upload-bottom");
     $this->select("additional_participants", "value=1");
 
     $this->type("email-Primary", $email4);
     $this->type("first_name", $firstName2);
     $this->type("last_name", $lastName2);
-    $this->type("street_address-1", "Test street addres");
+    $this->type("street_address-1", "Test street address");
     $this->type("city-1", "Mumbai");
     $this->type("postal_code-1", "2354");
     $this->select("state_province-1", "value=1001");
@@ -782,7 +789,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
     $this->type("email-Primary", $email3);
     $this->type("first_name", $participantfname2);
     $this->type("last_name", $participantlname2);
-    $this->type("street_address-1", "participant street addres");
+    $this->type("street_address-1", "participant street address");
     $this->type("city-1", "pune");
     $this->type("postal_code-1", "2354");
     $this->select("state_province-1", "value=1001");
@@ -797,7 +804,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
   /**
    * @return array|string
    */
-  function _addEmailField() {
+  public function _addEmailField() {
     //add email field in name and address profile
     $this->openCiviPage('admin/uf/group/field/add', 'reset=1&action=add&gid=1', "_qf_Field_next-bottom");
     $this->select("field_name[0]", "value=Contact");
@@ -817,11 +824,12 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
   }
 
   /**
-   * @param $cfId
+   * @param int $cfId
    */
-  function _removeEmailField($cfId) {
+  public function _removeEmailField($cfId) {
     $this->openCiviPage("admin/uf/group/field", "action=delete&id={$cfId}");
     $this->click("_qf_Field_next-bottom");
     $this->waitForPageToLoad($this->getTimeoutMsec());
   }
+
 }