Merge pull request #5596 from pratikshad/webtest2
[civicrm-core.git] / tests / phpunit / CiviTest / CiviDBAssert.php
index 1a39267ada1552855a5a33fef17f82f500aff217..7c99c18a43e81a430b1a491fce17ddc15920f669 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  *
  */
@@ -43,6 +43,11 @@ class CiviDBAssert {
    * @match    array    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 $testCase
+   * @param $daoName
+   * @param $id
+   * @param $match
+   * @param bool $delete
    */
   public function assertDBState(&$testCase, $daoName, $id, $match, $delete = FALSE) {
     if (empty($id)) {
@@ -51,7 +56,7 @@ class CiviDBAssert {
       $testCase->fail('ID not populated. Please fix your assertDBState usage!!!');
     }
 
-    $object   = new $daoName();
+    $object = new $daoName();
     $object->id = $id;
     $verifiedCount = 0;
 
@@ -90,6 +95,13 @@ class CiviDBAssert {
 
   /**
    * Request a record from the DB by seachColumn+searchValue. Success if a record is found.
+   * @param $testCase
+   * @param $daoName
+   * @param $searchValue
+   * @param $returnColumn
+   * @param $searchColumn
+   * @param $message
+   * @return null|string
    */
   public function assertDBNotNull(&$testCase, $daoName, $searchValue, $returnColumn, $searchColumn, $message) {
     if (empty($searchValue)) {
@@ -103,6 +115,12 @@ class CiviDBAssert {
 
   /**
    * Request a record from the DB by seachColumn+searchValue. Success if returnColumn value is NULL.
+   * @param $testCase
+   * @param $daoName
+   * @param $searchValue
+   * @param $returnColumn
+   * @param $searchColumn
+   * @param $message
    */
   public function assertDBNull(&$testCase, $daoName, $searchValue, $returnColumn, $searchColumn, $message) {
     $value = CRM_Core_DAO::getFieldValue($daoName, $searchValue, $returnColumn, $searchColumn);
@@ -111,6 +129,10 @@ class CiviDBAssert {
 
   /**
    * Request a record from the DB by id. Success if row not found.
+   * @param $testCase
+   * @param $daoName
+   * @param $id
+   * @param $message
    */
   public function assertDBRowNotExist(&$testCase, $daoName, $id, $message) {
     $value = CRM_Core_DAO::getFieldValue($daoName, $id, 'id', 'id');
@@ -118,7 +140,7 @@ class CiviDBAssert {
   }
 
   /**
-   * Compare a single column value in a retrieved DB record to an expected value
+   * Compare a single column value in a retrieved DB record to an expected value.
    *
    * @param $testCase
    * @param string $daoName
@@ -128,7 +150,8 @@ class CiviDBAssert {
    * @param $expectedValue
    * @param string $message
    */
-  function assertDBCompareValue(&$testCase, $daoName, $searchValue, $returnColumn, $searchColumn,
+  public function assertDBCompareValue(
+    &$testCase, $daoName, $searchValue, $returnColumn, $searchColumn,
     $expectedValue, $message
   ) {
     $value = CRM_Core_DAO::getFieldValue($daoName, $searchValue, $returnColumn, $searchColumn);
@@ -136,14 +159,17 @@ class CiviDBAssert {
   }
 
   /**
-   * 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 $testCase
+   * @param $daoName
+   * @param $searchParams
+   * @param $expectedValues
    */
   public function assertDBCompareValues(&$testCase, $daoName, $searchParams, $expectedValues) {
     //get the values from db
     $dbValues = array();
     CRM_Core_DAO::commonRetrieve($daoName, $searchParams, $dbValues);
 
-
     // compare db values with expected values
     self::assertAttributesEquals($testCase, $expectedValues, $dbValues);
   }
@@ -163,4 +189,5 @@ class CiviDBAssert {
       }
     }
   }
+
 }