Merge pull request #4903 from colemanw/INFRA-132
[civicrm-core.git] / tests / phpunit / WebTest / Event / TellAFriendTest.php
index 2ae7f0a83faa2786e7544a9cf154ede9e8b55d56..eb5661f93a769e57b5ae4f42cdc3a6fd6f5736fd 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
    +--------------------------------------------------------------------+
-   | CiviCRM version 4.4                                                |
+   | CiviCRM version 4.6                                                |
    +--------------------------------------------------------------------+
-   | Copyright CiviCRM LLC (c) 2004-2013                                |
+   | Copyright CiviCRM LLC (c) 2004-2014                                |
    +--------------------------------------------------------------------+
    | This file is a part of CiviCRM.                                    |
    |                                                                    |
   */
 
 require_once 'CiviTest/CiviSeleniumTestCase.php';
+
+/**
+ * Class WebTest_Event_TellAFriendTest
+ */
 class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase {
 
   protected function setUp() {
     parent::setUp();
   }
 
-  function testAddEvent() {
+  public function testAddEvent() {
     // Log in using webtestLogin() method
     $this->webtestLogin('admin');
 
@@ -55,7 +59,7 @@ class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase {
     $this->_testAddTellAFriend($subject, $thankYouMsg, $eventTitle);
 
     // get the url for registration
-    $this->waitForElementPresent("xpath=//div[@id='event_status_id']//div[@class='dataTables_wrapper']/table/tbody//tr/td[1]/a[text()='$eventTitle']");
+    $this->waitForElementPresent("xpath=//div[@id='event_status_id']//div[@id='option11_wrapper']/table/tbody//tr/td[1]/a[text()='$eventTitle']");
     $this->click("link=$eventTitle");
     $this->waitForElementPresent("link=Register Now");
     $this->click("link=Register Now");
@@ -71,13 +75,15 @@ class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase {
     $this->open($registerUrl);
     $this->waitForElementPresent('_qf_Register_upload-bottom');
 
-    $firstName = 'Jane' .substr(sha1(rand()), 0, 7);
+    $firstName = 'Jane' . substr(sha1(rand()), 0, 7);
     $lastName = 'Doe' . substr(sha1(rand()), 0, 7);
     $this->type('first_name', "$firstName");
     $this->type('last_name', "$lastName");
     $this->type('email-Primary', "$firstName@$lastName.com");
     $this->click('_qf_Register_upload-bottom');
     $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->click('_qf_Confirm_next-bottom');
+    $this->waitForPageToLoad($this->getTimeoutMsec());
     $this->click("css=div.crm-event-thankyou-form-block div#tell-a-friend a");
     $this->waitForElementPresent('_qf_Form_cancel');
 
@@ -135,37 +141,39 @@ class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase {
     $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh');
     $this->type('sort_name', $firstName);
     $this->click('_qf_Basic_refresh ');
-    $this->waitForElementPresent('Print');
-    $this->assertTrue($this->isTextPresent('1 Contact'));
+    $this->waitForTextPresent('1 Contact');
 
     // Verify Activity created
     $this->openCiviPage("activity/search", "reset=1", '_qf_Search_refresh');
     $this->type('sort_name', $firstName1);
     $this->click('_qf_Search_refresh');
-    $this->waitForElementPresent("_qf_Search_next_print");
-    $this->click("xpath=//div[@class='crm-search-results']//table[@class='selector']/tbody/tr[2]/td[9]/span/a[text()='View']");
+    $this->waitForElementPresent("xpath=//div[@class='crm-search-results']//table[@class='selector row-highlight']/tbody/tr[2]/td[9]/span/a[text()='View']");
+    $this->click("xpath=//div[@class='crm-search-results']//table[@class='selector row-highlight']/tbody/tr[2]/td[9]/span/a[text()='View']");
     $this->waitForElementPresent('_qf_Activity_cancel-bottom');
-
-    $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[1]/td[2]",
+    $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[1]/td[2]/span/a[1]",
       preg_quote("$lastName, $firstName")
     );
 
-    $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/a[1]",
+    $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/span",
       preg_quote("$lastName1, $firstName1")
     );
-    $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/a[2]",
+    $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/span",
       preg_quote("$lastName2, $firstName2")
     );
-    $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/a[3]",
+    $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/span",
       preg_quote("$lastName3, $firstName3")
     );
 
-    $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[4]/td[2]",
+    $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[4]/td[2]/span",
       preg_quote("Tell a Friend:")
     );
   }
 
-  function _testAddEventInfo($eventTitle, $eventDescription) {
+  /**
+   * @param $eventTitle
+   * @param $eventDescription
+   */
+  public function _testAddEventInfo($eventTitle, $eventDescription) {
     $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
 
     $this->select("event_type_id", "value=1");
@@ -190,7 +198,10 @@ class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase {
     $this->click("_qf_EventInfo_upload-bottom");
   }
 
-  function _testAddLocation($streetAddress) {
+  /**
+   * @param $streetAddress
+   */
+  public function _testAddLocation($streetAddress) {
     // Wait for Location tab form to load
     $this->waitForPageToLoad($this->getTimeoutMsec());
     $this->waitForElementPresent("_qf_Location_upload-bottom");
@@ -200,17 +211,22 @@ class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase {
     $this->type("address_1_street_address", $streetAddress);
     $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->click("_qf_Location_upload-bottom");
 
     // Wait for "saved" status msg
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->waitForTextPresent("'Location' information has been saved.");
+    $this->waitForElementPresent("_qf_Location_upload-bottom");
+    $this->waitForTextPresent("'Event Location' information has been saved.");
   }
 
-  function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) {
+  /**
+   * @param $registerIntro
+   * @param bool $multipleRegistrations
+   */
+  public function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) {
     // Go to Online Registration tab
     $this->click("link=Online Registration");
     $this->waitForElementPresent("_qf_Registration_upload-bottom");
@@ -222,6 +238,7 @@ class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase {
       $this->assertChecked("is_multiple_registrations");
     }
 
+    $this->click('intro_text-plain');
     $this->fillRichTextField("intro_text", $registerIntro);
 
     // enable confirmation email
@@ -230,11 +247,16 @@ class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase {
     $this->type("confirm_from_email", "jane.doe@example.org");
 
     $this->click("_qf_Registration_upload-bottom");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->waitForTextPresent("'Registration' information has been saved.");
+    $this->waitForElementPresent("_qf_Registration_upload-bottom");
+    $this->waitForTextPresent("'Online Registration' information has been saved.");
   }
 
-  function _testAddTellAFriend($subject, $thankYouMsg, $eventTitle) {
+  /**
+   * @param $subject
+   * @param $thankYouMsg
+   * @param $eventTitle
+   */
+  public function _testAddTellAFriend($subject, $thankYouMsg, $eventTitle) {
     // Go to Tell A Friend Tab
     $this->click('link=Tell a Friend');
     $this->waitForElementPresent('_qf_Event_cancel-bottom');
@@ -251,7 +273,6 @@ class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase {
     $this->type('tf_thankyou_text', $thankYouMsg);
 
     $this->click('_qf_Event_upload_done-bottom');
-    $this->waitForElementPresent("xpath=//div[@id='event_status_id']//div[@class='dataTables_wrapper']/table/tbody//tr/td[1]/a[text()='$eventTitle']");
+    $this->waitForElementPresent("xpath=//div[@id='event_status_id']//div[@id='option11_wrapper']/table/tbody//tr/td[1]/a[text()='$eventTitle']");
   }
 }
-