CRM-11856 - Update custom values when option values are modified
[civicrm-core.git] / tests / phpunit / Utils.php
index 8a6d2c18ab4af93cfde5b5b16a140f1aaf9e7e31..1e31961069e73f23aa6662eb2aa6868bba770fd0 100644 (file)
 class Utils {
 
   /**
-   *  PDO for the database
+   *  PDO for the database.
    * @var PDO
    */
   public $pdo;
 
   /**
-   *  Construct an object for this database
+   *  Construct an object for this database.
+   * @param $host
+   * @param $port
+   * @param $user
+   * @param $pass
    */
   public function __construct($host, $port, $user, $pass) {
     try {
@@ -52,19 +56,19 @@ class Utils {
         array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE)
       );
     }
-    catch(PDOException$e) {
+    catch (PDOException$e) {
       echo "Can't connect to MySQL server:" . PHP_EOL . $e->getMessage() . PHP_EOL;
       exit(1);
     }
   }
 
   /**
-   *  Prepare and execute a query
+   * Prepare and execute a query.
    *
-   *  If the query fails, output a diagnostic message
-   * @param  string  Query to run
-   * @return mixed   PDOStatement => Results of the query
-   *                  false        => Query failed
+   * If the query fails, output a diagnostic message
+   * @param string $query
+   *   Query to run
+   * @return bool
    */
   public function do_query($query) {
     // echo "do_query($query)\n";
@@ -91,43 +95,44 @@ class Utils {
     }
 
     /*******
-     if ( $this->pdo->errorCode() == 0 ) {
-     //echo "returning the PDOStmt\n";
-     return $stmt;
-     }
-
-     //  operation failed, so output description of where and why
-     $errorInfo = $this->pdo->errorInfo();
-     echo "Oops, can't do query:\n    {$query}\n    in "
-     . basename( __FILE__) . " line " . __LINE__.":\n    "
-     . $errorInfo[0] . ": " . $errorInfo[2] . "\n    Call stack:\n";
-     $backtrace = debug_backtrace();
-     $dir_name  = dirname( __FILE__ );
-     $cwd_len   = strlen( $dir_name ) + 1;
-     foreach ($backtrace as $frame ) {
-     echo "      ";
-     if ( array_key_exists( 'class', $frame ) ) {
-     echo " class {$frame['class']}";
-     if ( array_key_exists( 'function', $frame ) ) {
-     echo " method {$frame['function']}";
-     }
-     }
-     else {
-     if ( array_key_exists( 'function', $frame ) ) {
-     echo " function {$frame['function']}";
-     }
-     }
-     if ( array_key_exists( 'file', $frame ) ) {
-     echo " file ". substr( $frame['file'], $cwd_len );
-     }
-     if ( array_key_exists( 'line', $frame ) ) {
-     echo " line {$frame['line']}";
-     }
-     echo "\n";
-     }
+     if ( $this->pdo->errorCode() == 0 ) {
+     //echo "returning the PDOStmt\n";
+     return $stmt;
+     }
+     *
+     //  operation failed, so output description of where and why
+     $errorInfo = $this->pdo->errorInfo();
+     echo "Oops, can't do query:\n    {$query}\n    in "
+     . basename( __FILE__) . " line " . __LINE__.":\n    "
+     . $errorInfo[0] . ": " . $errorInfo[2] . "\n    Call stack:\n";
+     $backtrace = debug_backtrace();
+     $dir_name  = dirname( __FILE__ );
+     $cwd_len   = strlen( $dir_name ) + 1;
+     foreach ($backtrace as $frame ) {
+     echo "      ";
+     if ( array_key_exists( 'class', $frame ) ) {
+     echo " class {$frame['class']}";
+     if ( array_key_exists( 'function', $frame ) ) {
+     echo " method {$frame['function']}";
+     }
+     }
+     else {
+     if ( array_key_exists( 'function', $frame ) ) {
+     echo " function {$frame['function']}";
+     }
+     }
+     if ( array_key_exists( 'file', $frame ) ) {
+     echo " file ". substr( $frame['file'], $cwd_len );
+     }
+     if ( array_key_exists( 'line', $frame ) ) {
+     echo " line {$frame['line']}";
+     }
+     echo "\n";
+     }
      ******/
     return TRUE;
   }
+
 }
 // class Utils