Merge pull request #5182 from colemanw/Cleanup
[civicrm-core.git] / tests / phpunit / CiviTest / CiviSeleniumTestCase.php
index f7b70cb2b3678aa965ea4e1b0f8991183ce373a3..4df99add862a3f3a91c482066bc04305979e68c9 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *  Include configuration
@@ -49,7 +49,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   protected $loggedInAs = NULL;
 
   /**
-   *  Constructor
+   *  Constructor.
    *
    *  Because we are overriding the parent class constructor, we
    *  need to show the same arguments as exist in the constructor of
@@ -103,6 +103,9 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
     }
   }
 
+  /**
+   * @return string
+   */
   protected function prepareTestSession() {
     $result = parent::prepareTestSession();
 
@@ -120,13 +123,13 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
 
   /**
    * @param array $cookies
-   *   Each item is an array with keys:.
-   *  - name: string
-   *  - value: string; note that RFC's don't define particular encoding scheme, so
+   *   Each item is an Array with keys:
+   *   - name: string
+   *   - value: string; note that RFC's don't define particular encoding scheme, so
    *    you must pick one yourself and pre-encode; does not allow values with
    *    commas, semicolons, or whitespace
-   *  - path: string; default: '/'
-   *  - max_age: int; default: 1 week (7*24*60*60)
+   *   - path: string; default: '/'
+   *   - max_age: int; default: 1 week (7*24*60*60)
    */
   protected function setCookies($cookies) {
     foreach ($cookies as $cookie) {
@@ -151,7 +154,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Authenticate as drupal user
+   * Authenticate as drupal user.
    * @param $user : (str) the key 'user' or 'admin', or a literal username
    * @param $pass : (str) if $user is a literal username and not 'user' or 'admin', supply the password
    */
@@ -191,10 +194,10 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   /**
    * Open an internal path beginning with 'civicrm/'
    *
-   * @param $url
-   *   (str) omit the 'civicrm/' it will be added for you.
-   * @param $args
-   *   (str|array) optional url arguments.
+   * @param string $url
+   *   omit the 'civicrm/' it will be added for you.
+   * @param string|array $args
+   *   optional url arguments.
    * @param $waitFor
    *   Page element to wait for - using this is recommended to ensure the document is fully loaded.
    *
@@ -226,9 +229,12 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Click on a link or button
+   * Click on a link or button.
    * Wait for the page to load
    * Wait for an element to be present
+   * @param $element
+   * @param string $waitFor
+   * @param bool $waitForPageLoad
    */
   public function clickLink($element, $waitFor = 'civicrm-footer', $waitForPageLoad = TRUE) {
     $this->click($element);
@@ -243,7 +249,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Click a link or button and wait for an ajax dialog to load
+   * Click a link or button and wait for an ajax dialog to load.
    * @param string $element
    * @param string $waitFor
    */
@@ -255,7 +261,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Click a link or button and wait for ajax content to load or refresh
+   * Click a link or button and wait for ajax content to load or refresh.
    * @param string $element
    * @param string $waitFor
    */
@@ -283,7 +289,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Wait for all ajax snippets to finish loading
+   * Wait for all ajax snippets to finish loading.
    */
   public function waitForAjaxContent() {
     $this->waitForElementNotPresent('css=.blockOverlay');
@@ -296,8 +302,12 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Call the API on the local server
+   * Call the API on the local server.
    * (kind of defeats the point of a webtest - see CRM-11889)
+   * @param $entity
+   * @param $action
+   * @param $params
+   * @return array|int
    */
   public function webtest_civicrm_api($entity, $action, $params) {
     if (!isset($params['version'])) {
@@ -310,9 +320,13 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Call the API on the remote server
+   * Call the API on the remote server.
    * Experimental - currently only works if permissions on remote site allow anon user to access ajax api
    * @see CRM-11889
+   * @param $entity
+   * @param $action
+   * @param array $params
+   * @return mixed
    */
   public function rest_civicrm_api($entity, $action, $params = array()) {
     $params += array(
@@ -340,7 +354,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
     $result = $this->webtest_civicrm_api("OptionValue", "getvalue", array(
       'option_group_name' => $option_group_name,
       'option.limit' => 1,
-      'return' => 'value'
+      'return' => 'value',
     ));
     return $result;
   }
@@ -383,7 +397,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
       $result = $this->webtest_civicrm_api("Domain", "getvalue", array(
         'current_domain' => 1,
         'option.limit' => 1,
-        'return' => 'config_backend'
+        'return' => 'config_backend',
       ));
       $_config_backend = unserialize($result);
     }
@@ -391,7 +405,8 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Ensures the required CiviCRM components are enabled
+   * Ensures the required CiviCRM components are enabled.
+   * @param $components
    */
   public function enableComponents($components) {
     $this->openCiviPage("admin/setting/component", "reset=1", "_qf_Component_next-bottom");
@@ -412,7 +427,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Add a contact with the given first and last names and either a given email
+   * Add a contact with the given first and last names and either a given email.
    * (when specified), a random email (when true) or no email (when unspecified or null).
    *
    * @param string $fname
@@ -421,10 +436,10 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
    *   Contact’s last name.
    * @param mixed $email
    *   Contact’s email (when string) or random email (when true) or no email (when null).
+   * @param string $contactSubtype
    *
-   * @param null $contactSubtype
-   *
-   * @return mixed either a string with the (either generated or provided) email or null (if no email)
+   * @return string|null
+   *   either a string with the (either generated or provided) email or null (if no email)
    */
   public function webtestAddContact($fname = 'Anthony', $lname = 'Anderson', $email = NULL, $contactSubtype = NULL) {
     $args = 'reset=1&ct=Individual';
@@ -493,6 +508,8 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
+   * @param $sortName
+   * @param string $fieldName
    */
   public function webtestFillAutocomplete($sortName, $fieldName = 'contact_id') {
     $this->select2($fieldName, $sortName);
@@ -500,6 +517,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
+   * @param $sortName
    */
   public function webtestOrganisationAutocomplete($sortName) {
     $this->clickAt("//*[@id='contact_id']/../div/a");
@@ -534,7 +552,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
     $mon = date('n', $timeStamp) - 1;
     $day = date('j', $timeStamp);
 
-    $this->click("{$dateElement}_display");
+    $this->click("xpath=//input[starts-with(@id, '{$dateElement}_display_')]");
     $this->waitForElementPresent("css=div#ui-datepicker-div.ui-datepicker div.ui-datepicker-header div.ui-datepicker-title select.ui-datepicker-month");
     $this->select("css=div#ui-datepicker-div.ui-datepicker div.ui-datepicker-header div.ui-datepicker-title select.ui-datepicker-month", "value=$mon");
     $this->select("css=div#ui-datepicker-div div.ui-datepicker-header div.ui-datepicker-title select.ui-datepicker-year", "value=$year");
@@ -587,7 +605,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Types text into a ckEditor rich text field in a form
+   * Types text into a ckEditor rich text field in a form.
    *
    * @param string $fieldName
    *   Form field name (as assigned by PHP buildForm class).
@@ -596,7 +614,8 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
    * @param string $editor
    *   Which text editor (valid values are 'CKEditor', 'TinyMCE').
    *
-   * @return void
+   * @param bool $compressed
+   * @throws \PHPUnit_Framework_AssertionFailedError
    */
   public function fillRichTextField($fieldName, $text = 'Typing this text into editor.', $editor = 'CKEditor', $compressed = FALSE) {
     // make sure cursor focuses on the field
@@ -619,7 +638,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Types option label and name into a table of multiple choice options
+   * Types option label and name into a table of multiple choice options.
    * (for price set fields of type select, radio, or checkbox)
    * TODO: extend for custom field multiple choice table input
    *
@@ -647,11 +666,12 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Use a contact EntityRef field to add a new contact
+   * Use a contact EntityRef field to add a new contact.
    * @param string $field
    *   Selector.
    * @param string $contactType
-   * @return array of contact attributes (id, names, email)
+   * @return array
+   *   Array of contact attributes (id, names, email)
    */
   public function createDialogContact($field = 'contact_id', $contactType = 'Individual') {
     $selectId = 's2id_' . $this->getAttribute($field . '@id');
@@ -683,8 +703,15 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
 
   /**
    * @deprecated in favor of createDialogContact
+   * @param string $fname
+   * @param string $lname
+   * @param string $email
+   * @param int $type
+   * @param string $selectId
+   * @param int $row
+   * @param string $prefix
    */
-  function webtestNewDialogContact(
+  public function webtestNewDialogContact(
     $fname = 'Anthony', $lname = 'Anderson', $email = 'anthony@anderson.biz',
     $type = 4, $selectId = 's2id_contact_id', $row = 1, $prefix = '') {
     // 4 - Individual profile
@@ -722,12 +749,12 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Generic function to check that strings are present in the page
+   * Generic function to check that strings are present in the page.
    *
    * @strings  array    array of strings or a single string
    *
    * @param $strings
-   * @return   void
+   * @return void
    */
   public function assertStringsPresent($strings) {
     foreach ((array) $strings as $string) {
@@ -741,7 +768,8 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
    * @url      string url to parse or retrieve current url if null
    *
    * @param null $url
-   * @return   array  returns an associative array containing any of the various components
+   * @return array
+   *   returns an associative array containing any of the various components
    *                  of the URL that are present. Querystring elements are returned in sub-array (elements.queryString)
    *                  http://php.net/manual/en/function.parse-url.php
    */
@@ -759,7 +787,10 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Returns a single argument from the url query
+   * Returns a single argument from the url query.
+   * @param $arg
+   * @param null $url
+   * @return null
    */
   public function urlArg($arg, $url = NULL) {
     $elements = $this->parseURL($url);
@@ -781,7 +812,6 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
    * @throws PHPUnit_Framework_AssertionFailedError
    * @return int
    */
-
   public function webtestAddPaymentProcessor($processorName = 'Test Processor', $processorType = 'Dummy', $processorSettings = NULL, $financialAccount = 'Deposit Bank Account') {
     if (!$processorName) {
       $this->fail("webTestAddPaymentProcessor requires $processorName.");
@@ -908,7 +938,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
     if (!$filePath) {
       $filePath = '/tmp/testfile_' . substr(sha1(rand()), 0, 7) . '.txt';
       $fp = @fopen($filePath, 'w');
-      fputs($fp, 'Test file created by selenium test.');
+      fwrite($fp, 'Test file created by selenium test.');
       @fclose($fp);
     }
 
@@ -953,10 +983,11 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   /**
    * Create new relationship type w/ user specified params or default.
    *
-   * @param $params
-   *   Array of required params.
+   * @param array $params
+   *   array of required params.
    *
-   * @return an array of saved params values.
+   * @return array
+   *   array of saved params values.
    */
   public function webtestAddRelationshipType($params = array()) {
     $this->openCiviPage("admin/reltype", "reset=1&action=add");
@@ -1034,11 +1065,11 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
    * @param string $financialType
    * @param bool $fixedAmount
    * @param bool $membershipsRequired
-   * @internal param \can $User define pageTitle, hash and rand values for later data verification
    *
-   * @return null $pageId of newly created online contribution page.
+   * @return null
+   *   of newly created online contribution page.
    */
-  function webtestAddContributionPage(
+  public function webtestAddContributionPage(
     $hash = NULL,
     $rand = NULL,
     $pageTitle = NULL,
@@ -1598,8 +1629,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   /**
    * @return bool
    */
-  static
-  public function checkDoLocalDBTest() {
+  public static function checkDoLocalDBTest() {
     if (defined('CIVICRM_WEBTEST_LOCAL_DB') &&
       CIVICRM_WEBTEST_LOCAL_DB
     ) {
@@ -1610,117 +1640,75 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Generic function to compare expected values after an api call to retrieved
+   * Generic function to compare expected values after an api call to retrieved.
    * DB values.
    *
-   * @daoName  string   DAO Name of object we're evaluating.
-   * @id       int      Id of object
-   * @match    array    Associative array of field name => expected value. Empty if asserting
+   * @param string $daoName
+   *   DAO Name of object we're evaluating.
+   * @param int $id
+   *   Id of object
+   * @param array $match
+   *   Associative array of field name => expected value. Empty if asserting
    *                      that a DELETE occurred
-   * @delete   boolean  True if we're checking that a DELETE action occurred.
+   * @param bool $delete
+   *   are we checking that a DELETE action occurred?
    */
   public function assertDBState($daoName, $id, $match, $delete = FALSE) {
-    if (!self::checkDoLocalDBTest()) {
-      return;
+    if (self::checkDoLocalDBTest()) {
+      CiviDBAssert::assertDBState($this, $daoName, $id, $match, $delete);
     }
-
-    return CiviDBAssert::assertDBState($this, $daoName, $id, $match, $delete);
   }
 
-  // Request a record from the DB by seachColumn+searchValue. Success if a record is found.
   /**
+   * Request a record from the DB by seachColumn+searchValue. Success if a record is found.
    * @param string $daoName
-   * @param $searchValue
-   * @param $returnColumn
-   * @param $searchColumn
-   * @param $message
-   *
-   * @return null|string
+   * @param string $searchValue
+   * @param string $returnColumn
+   * @param string $searchColumn
+   * @param string $message
    */
   public function assertDBNotNull($daoName, $searchValue, $returnColumn, $searchColumn, $message) {
-    if (!self::checkDoLocalDBTest()) {
-      return;
+    if (self::checkDoLocalDBTest()) {
+      CiviDBAssert::assertDBNotNull($this, $daoName, $searchValue, $returnColumn, $searchColumn, $message);
     }
-
-    return CiviDBAssert::assertDBNotNull($this, $daoName, $searchValue, $returnColumn, $searchColumn, $message);
   }
 
-  // Request a record from the DB by seachColumn+searchValue. Success if returnColumn value is NULL.
   /**
+   * Request a record from the DB by searchColumn+searchValue. Success if returnColumn value is NULL.
    * @param string $daoName
-   * @param $searchValue
-   * @param $returnColumn
-   * @param $searchColumn
-   * @param $message
+   * @param string $searchValue
+   * @param string $returnColumn
+   * @param string $searchColumn
+   * @param string $message
    */
   public function assertDBNull($daoName, $searchValue, $returnColumn, $searchColumn, $message) {
-    if (!self::checkDoLocalDBTest()) {
-      return;
+    if (self::checkDoLocalDBTest()) {
+      CiviDBAssert::assertDBNull($this, $daoName, $searchValue, $returnColumn, $searchColumn, $message);
     }
-
-    return CiviDBAssert::assertDBNull($this, $daoName, $searchValue, $returnColumn, $searchColumn, $message);
   }
 
-  // Request a record from the DB by id. Success if row not found.
   /**
+   * Request a record from the DB by id. Success if row not found.
    * @param string $daoName
    * @param int $id
-   * @param $message
-   */
-  public function assertDBRowNotExist($daoName, $id, $message) {
-    if (!self::checkDoLocalDBTest()) {
-      return;
-    }
-
-    return CiviDBAssert::assertDBRowNotExist($this, $daoName, $id, $message);
-  }
-
-  // Compare a single column value in a retrieved DB record to an expected value
-  /**
-   * @param string $daoName
-   * @param $searchValue
-   * @param $returnColumn
-   * @param $searchColumn
-   * @param $expectedValue
    * @param string $message
    */
-  function assertDBCompareValue(
-    $daoName, $searchValue, $returnColumn, $searchColumn,
-    $expectedValue, $message
-  ) {
-    if (!self::checkDoLocalDBTest()) {
-      return;
+  public function assertDBRowNotExist($daoName, $id, $message) {
+    if (self::checkDoLocalDBTest()) {
+      CiviDBAssert::assertDBRowNotExist($this, $daoName, $id, $message);
     }
-
-    return CiviDBAssert::assertDBCompareValue($daoName, $searchValue, $returnColumn, $searchColumn,
-      $expectedValue, $message
-    );
   }
 
-  // Compare all values in a single retrieved DB record to an array of expected values
   /**
+   * Compare all values in a single retrieved DB record to an array of expected values.
    * @param string $daoName
    * @param array $searchParams
    * @param $expectedValues
    */
   public function assertDBCompareValues($daoName, $searchParams, $expectedValues) {
-    if (!self::checkDoLocalDBTest()) {
-      return;
+    if (self::checkDoLocalDBTest()) {
+      CiviDBAssert::assertDBCompareValues($this, $daoName, $searchParams, $expectedValues);
     }
-
-    return CiviDBAssert::assertDBCompareValues($this, $daoName, $searchParams, $expectedValues);
-  }
-
-  /**
-   * @param $expectedValues
-   * @param $actualValues
-   */
-  public function assertAttributesEquals(&$expectedValues, &$actualValues) {
-    if (!self::checkDoLocalDBTest()) {
-      return;
-    }
-
-    return CiviDBAssert::assertAttributesEquals($expectedValues, $actualValues);
   }
 
   /**
@@ -1729,13 +1717,23 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
    * @param string $message
    */
   public function assertType($expected, $actual, $message = '') {
-    return $this->assertInternalType($expected, $actual, $message);
+    $this->assertInternalType($expected, $actual, $message);
   }
 
   /**
-   * Add new Financial Account
+   * Add new Financial Account.
+   * @param $financialAccountTitle
+   * @param bool $financialAccountDescription
+   * @param bool $accountingCode
+   * @param bool $firstName
+   * @param bool $financialAccountType
+   * @param bool $taxDeductible
+   * @param bool $isActive
+   * @param bool $isTax
+   * @param bool $taxRate
+   * @param bool $isDefault
    */
-  function _testAddFinancialAccount(
+  public function _testAddFinancialAccount(
     $financialAccountTitle,
     $financialAccountDescription = FALSE,
     $accountingCode = FALSE,
@@ -1813,27 +1811,38 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Edit Financial Account
+   * Edit Financial Account.
+   * @param $editfinancialAccount
+   * @param bool $financialAccountTitle
+   * @param bool $financialAccountDescription
+   * @param bool $accountingCode
+   * @param bool $firstName
+   * @param bool $financialAccountType
+   * @param bool $taxDeductible
+   * @param bool $isActive
+   * @param bool $isTax
+   * @param bool $taxRate
+   * @param bool $isDefault
    */
-  function _testEditFinancialAccount(
+  public function _testEditFinancialAccount(
     $editfinancialAccount,
-                                     $financialAccountTitle = FALSE,
-                                     $financialAccountDescription = FALSE,
-                                     $accountingCode = FALSE,
-                                     $firstName = FALSE,
-                                     $financialAccountType = FALSE,
-                                     $taxDeductible = FALSE,
-                                     $isActive = TRUE,
-                                     $isTax = FALSE,
-                                     $taxRate = FALSE,
-                                     $isDefault = FALSE
+    $financialAccountTitle = FALSE,
+    $financialAccountDescription = FALSE,
+    $accountingCode = FALSE,
+    $firstName = FALSE,
+    $financialAccountType = FALSE,
+    $taxDeductible = FALSE,
+    $isActive = TRUE,
+    $isTax = FALSE,
+    $taxRate = FALSE,
+    $isDefault = FALSE
   ) {
     if ($firstName) {
       $this->openCiviPage("admin/financial/financialAccount", "reset=1");
     }
 
-    $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$editfinancialAccount}']/../td[9]/span/a[text()='Edit']");
-    $this->clickLink("xpath=//table/tbody//tr/td[1][text()='{$editfinancialAccount}']/../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom', FALSE);
+    $this->waitForElementPresent("xpath=//table/tbody//tr/td[1]/div[text()='{$editfinancialAccount}']/../../td[9]/span/a[text()='Edit']");
+    $this->clickLink("xpath=//table/tbody//tr/td[1]/div[text()='{$editfinancialAccount}']/../../td[9]/span/a[text()='Edit']", '_qf_FinancialAccount_cancel-botttom', FALSE);
 
     // Change Financial Account Name
     if ($financialAccountTitle) {
@@ -1901,10 +1910,11 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Delete Financial Account
+   * Delete Financial Account.
+   * @param $financialAccountTitle
    */
   public function _testDeleteFinancialAccount($financialAccountTitle) {
-    $this->click("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Delete']");
+    $this->click("xpath=//table/tbody//tr/td[1]/div[text()='{$financialAccountTitle}']/../../td[9]/span/a[text()='Delete']");
     $this->waitForElementPresent('_qf_FinancialAccount_next-botttom');
     $this->click('_qf_FinancialAccount_next-botttom');
     $this->waitForElementPresent('link=Add Financial Account');
@@ -1912,7 +1922,8 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Verify data after ADD and EDIT
+   * Verify data after ADD and EDIT.
+   * @param $verifyData
    */
   public function _assertFinancialAccount($verifyData) {
     foreach ($verifyData as $key => $expectedValue) {
@@ -1944,9 +1955,9 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
     $this->openCiviPage("admin/financial/financialType", "reset=1");
 
     if ($option == 'Delete') {
-      $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[name]']/../td[7]/span[2]");
+      $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1]/div[text()='$financialType[name]']/../../td[7]/span[2]");
       $this->waitForElementPresent("css=span.btn-slide-active");
-      $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[name]']/../td[7]/span[2]/ul/li[2]/a");
+      $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1]/div[text()='$financialType[name]']/../../td[7]/span[2]/ul/li[2]/a");
       $this->waitForElementPresent("_qf_FinancialType_next");
       $this->click("_qf_FinancialType_next");
       $this->waitForElementPresent("newFinancialType");
@@ -1957,7 +1968,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
       $this->click("link=Add Financial Type");
     }
     else {
-      $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='$financialType[oldname]']/../td[7]/span/a[text()='Edit']");
+      $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1]/div[text()='$financialType[oldname]']/../../td[7]/span/a[text()='Edit']");
     }
     $this->waitForElementPresent("name");
     $this->type('name', $financialType['name']);
@@ -1990,8 +2001,9 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Give the specified permissions
+   * Give the specified permissions.
    * Note: this function logs in as 'admin' (logging out if necessary)
+   * @param $permission
    */
   public function changePermissions($permission) {
     $this->webtestLogin('admin');
@@ -2069,7 +2081,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Ensure we have a default mailbox set up for CiviMail
+   * Ensure we have a default mailbox set up for CiviMail.
    */
   public function setupDefaultMailbox() {
     $this->openCiviPage('admin/mailSettings', 'action=update&id=1&reset=1');
@@ -2101,14 +2113,14 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
    *
    * @param array $customSets
    *   Custom sets i.e entity wise sets want to be created and checked.
-   * e.g    $customSets = array(array('entity' => 'Contribution', 'subEntity' => 'Donation',
+   *   e.g    $customSets = array(array('entity' => 'Contribution', 'subEntity' => 'Donation',
    * 'triggerElement' => $triggerElement))
    * array  $triggerElement:   the element which is responsible for custom group to load
    *
    * which uses the entity info as its selection value
    * @param array $pageUrl
    *   The url which on which the ajax custom group load takes place.
-   * @param bool $beforeTriggering
+   * @param string $beforeTriggering
    * @return void
    */
   public function customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl, $beforeTriggering = NULL) {
@@ -2219,8 +2231,8 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
         "{$customSet['entity']}_{$customSet['subEntity']}" => array(
           'cgtitle' => $customGroupTitle,
           'gid' => $gid,
-          'triggerElement' => $customSet['triggerElement']
-        )
+          'triggerElement' => $customSet['triggerElement'],
+        ),
       );
 
       // Go home for a sec to give time for caches to clear
@@ -2230,7 +2242,11 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Type and select first occurance of autocomplete
+   * Type and select first occurance of autocomplete.
+   * @param $fieldName
+   * @param $label
+   * @param bool $multiple
+   * @param bool $xpath
    */
   public function select2($fieldName, $label, $multiple = FALSE, $xpath = FALSE) {
     // In the case of chainSelect, wait for options to load
@@ -2262,7 +2278,9 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Select multiple options
+   * Select multiple options.
+   * @param $fieldid
+   * @param $params
    */
   public function multiselect2($fieldid, $params) {
     // In the case of chainSelect, wait for options to load
@@ -2279,6 +2297,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
 
   /**
    * Check for unobtrusive status message as set by CRM.status
+   * @param null $text
    */
   public function checkCRMStatus($text = NULL) {
     $this->waitForElementPresent("css=.crm-status-box-outer.status-success");
@@ -2289,6 +2308,8 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
 
   /**
    * Check for obtrusive status message as set by CRM.alert
+   * @param $text
+   * @param string $type
    */
   public function checkCRMAlert($text, $type = 'success') {
     $this->waitForElementPresent("css=div.ui-notify-message.$type");
@@ -2299,6 +2320,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
 
   /**
    * Enable or disable Pop-ups via Display Preferences
+   * @param bool $enabled
    */
   public function enableDisablePopups($enabled = TRUE) {
     $this->openCiviPage('admin/setting/preferences/display', 'reset=1');
@@ -2316,7 +2338,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   /**
-   * Attempt to get information about what went wrong if we encounter an error when loading a page
+   * Attempt to get information about what went wrong if we encounter an error when loading a page.
    */
   public function checkForErrorsOnPage() {
     foreach (array('Access denied', 'Page not found') as $err) {
@@ -2332,4 +2354,5 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
       $this->fail($msg);
     }
   }
+
 }