tests/phpunit - Fix for running with MySQL on alternative port
authorTim Otten <totten@civicrm.org>
Sat, 4 Jan 2014 02:24:04 +0000 (18:24 -0800)
committerTim Otten <totten@civicrm.org>
Sat, 4 Jan 2014 02:24:04 +0000 (18:24 -0800)
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/CiviTest/civicrm.settings.dist.php
tests/phpunit/Utils.php

index 37d667bb4d90efa83c2f5479fdd42408dfa0d967..bdcc2c96bbcbc7f45e4ffb3d29c5e4963d5f3ae8 100644 (file)
@@ -148,6 +148,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
 
     //  create test database
     self::$utils = new Utils($GLOBALS['mysql_host'],
+      $GLOBALS['mysql_port'],
       $GLOBALS['mysql_user'],
       $GLOBALS['mysql_pass']
     );
@@ -406,6 +407,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    */
   function foreignKeyChecksOff() {
     self::$utils = new Utils($GLOBALS['mysql_host'],
+      $GLOBALS['mysql_port'],
       $GLOBALS['mysql_user'],
       $GLOBALS['mysql_pass']
     );
index 4ef32fc7f737ce22a2e6dc0f20d3e12b35c3bf5c..5e2d96b00f4a28d4ff018048c6f2006ab12080a1 100644 (file)
@@ -42,11 +42,11 @@ require_once "DB.php";
 $dsninfo = DB::parseDSN(CIVICRM_DSN);
 
 $GLOBALS['mysql_host'] = $dsninfo['hostspec'];
+$GLOBALS['mysql_port'] = @$dsninfo['port'];
 $GLOBALS['mysql_user'] = $dsninfo['username'];
 $GLOBALS['mysql_pass'] = $dsninfo['password'];
 $GLOBALS['mysql_db'] = $dsninfo['database'];
 
-
 /**
  * Content Management System (CMS) Host:
  *
index 3d4fa63e2a2114de12d3750493d9fb984fed2d8f..560fa2538f38daa1f7debe0d0afa994a456da848 100644 (file)
@@ -45,9 +45,9 @@ class Utils {
   /**
    *  Construct an object for this database
    */
-  public function __construct($host, $user, $pass) {
+  public function __construct($host, $port, $user, $pass) {
     try {
-      $this->pdo = new PDO("mysql:host={$host}",
+      $this->pdo = new PDO("mysql:host={$host}" . ($port ? ";port=$port" : ""),
         $user, $pass,
         array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE)
       );