whitespace cleanup
[civicrm-core.git] / tests / phpunit / WebTest / Mailing / MailingTest.php
index 11731f695779ed4b149ef27f1f2143e0ac21338f..c3edaa3fa1ac769b1b7086615a14610585baed6c 100644 (file)
@@ -24,7 +24,6 @@
  +--------------------------------------------------------------------+
 */
 
-
 require_once 'CiviTest/CiviSeleniumTestCase.php';
 class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
 
@@ -33,12 +32,10 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
   }
 
   function testAddMailing() {
-    $this->open($this->sboxPath);
     $this->webtestLogin();
 
     //----do create test mailing group
 
-    // Go directly to the URL of the screen that you will be testing (New Group).
     $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
 
     // make group name
@@ -76,19 +73,11 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
     $this->click("css=li#tab_group a");
     $this->waitForElementPresent("_qf_GroupContact_next");
     $this->select("group_id", "$groupName");
-    $this->click("_qf_GroupContact_next");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->waitForElementPresent("_qf_GroupContact_next");
+    $this->clickLink("_qf_GroupContact_next", "_qf_GroupContact_next");
 
     // configure default mail-box
-    $this->openCiviPage("admin/mailSettings", "action=update&id=1&reset=1", '_qf_MailSettings_cancel-bottom');
-    $this->type('name', 'Test Domain');
-    $this->type('domain', 'example.com');
-    $this->select('protocol', 'value=1');
-    $this->click('_qf_MailSettings_next-bottom');
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->setupDefaultMailbox();
 
-    // Go directly to Schedule and Send Mailing form
     $this->openCiviPage("mailing/send", "reset=1", "_qf_Group_cancel");
 
     //-------select recipients----------
@@ -239,14 +228,13 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
     // verify email
     $this->verifyText("xpath=//table[@id='mailing_event']/tbody//tr/td[2]", preg_quote("mailino$firstName@mailson.co.in"));
 
-    require_once 'CRM/Mailing/Event/DAO/Queue.php';
     $eventQueue = new CRM_Mailing_Event_DAO_Queue();
     $eventQueue->contact_id = $contactId;
     $eventQueue->find(TRUE);
 
     $permission = array('edit-1-access-civimail-subscribeunsubscribe-pages');
     $this->changePermissions($permission);
-    $this->openCiviPage('logout', 'reset=1', NULL);
+    $this->webtestLogout();
 
     // build forward url
     $forwardUrl = array("mailing/forward", "reset=1&jid={$eventQueue->job_id}&qid={$eventQueue->id}&h={$eventQueue->hash}");
@@ -262,7 +250,6 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
     $this->waitForPageToLoad($this->getTimeoutMsec());
     $this->assertElementContainsText('css=div.messages', 'Mailing is forwarded successfully to 2 email addresses');
 
-    $this->open($this->sboxPath);
     $this->waitForPageToLoad($this->getTimeoutMsec());
     $this->webtestLogin();
 
@@ -290,8 +277,7 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
     // $unsubscribeUrl = "civicrm/mailing/optout?reset=1&jid={$eventQueue->job_id}&qid={$eventQueue->id}&h={$eventQueue->hash}&confirm=1";
 
     // // logout to unsubscribe
-    // $this->open($this->sboxPath . 'civicrm/logout?reset=1');
-    // $this->waitForPageToLoad($this->getTimeoutMsec());
+    // $this->webtestLogout();
 
     // // click(visit) unsubscribe path
     // $this->open($this->sboxPath . $unsubscribeUrl);
@@ -310,13 +296,11 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
 
     // //------ end unsubscribe -------
   }
-  
+
   function testAdvanceSearchAndReportCheck() {
 
-    $this->open($this->sboxPath);
     $this->webtestLogin();
 
-    // Go directly to the URL of the screen that you will be testing (New Group).
     $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
 
     // make group name
@@ -354,9 +338,7 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
     $this->click("css=li#tab_group a");
     $this->waitForElementPresent("_qf_GroupContact_next");
     $this->select("group_id", "$groupName");
-    $this->click("_qf_GroupContact_next");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->waitForElementPresent("_qf_GroupContact_next");
+    $this->clickLink("_qf_GroupContact_next", "_qf_GroupContact_next");
 
     // configure default mail-box
     $this->openCiviPage("admin/mailSettings", "action=update&id=1&reset=1", '_qf_MailSettings_cancel-bottom');
@@ -366,7 +348,7 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
     $this->click('_qf_MailSettings_next-bottom');
     $this->waitForPageToLoad($this->getTimeoutMsec());
 
-    // Go directly to Schedule and Send Mailing form
+    // Go to Schedule and Send Mailing form
     $this->openCiviPage('mailing/send', 'reset=1', '_qf_Group_cancel');
 
     //-------select recipients----------
@@ -398,7 +380,7 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
 
     // fill subject for mailing
     $this->type("subject", "Test subject {$mailingName} for Webtest");
-    
+
     // check for default option enabled
     $this->assertChecked("CIVICRM_QFID_1_upload_type");
 
@@ -461,7 +443,7 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
     $this->verifyText("xpath=//table//tr[td/a[text()='Successful Deliveries']]/descendant::td[2]", preg_quote("1 (100.00%)"));
 
     $summaryInfoLinks = array('Intended Recipients', 'Successful Deliveries', 'Tracked Opens', 'Click-throughs', 'Forwards', 'Replies', 'Bounces', 'Unsubscribe Requests','Opt-out Requests');
-    
+
     //check for report and adv search links
     foreach($summaryInfoLinks as $value) {
       $this->assertTrue($this->isElementPresent("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$value}']]/descendant::td[3]/span/a[1][text()='Report']"), "Report link missing for {$value}");
@@ -563,4 +545,4 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
       }
     }
   }
-}
\ No newline at end of file
+}