Skip to content

Commit

Permalink
Merge pull request #796 from yitam/connPooltests
Browse files Browse the repository at this point in the history
Fixed connection pooling tests for more than one ODBC drivers
  • Loading branch information
yitam authored Jun 11, 2018
2 parents ea6381c + d554492 commit 53e4da4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
13 changes: 11 additions & 2 deletions test/functional/pdo_sqlsrv/PDO_ConnPool_Unix.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ This test assumes the default odbcinst.ini has not been modified.
<?php if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') die("Skipped: Test for Linux and Mac"); ?>
--FILE--
<?php
function findODBCDriver($content, $lines_to_add)
{
require_once('MsSetup.inc');
$command = "odbcinst -q -d -n '$driver'";
$info = shell_exec($command);

return str_replace($info, $info.$lines_to_add, $content);
}

$lines_to_add="CPTimeout=5\n[ODBC]\nPooling=Yes\n";

//get default odbcinst.ini location
Expand All @@ -18,8 +27,8 @@ copy( $odbcinst_ini, $custom_odbcinst_ini);

//enable pooling by modifying the odbcinst.ini file
$current = file_get_contents($custom_odbcinst_ini);
$current.=$lines_to_add;
file_put_contents($custom_odbcinst_ini, $current);
$new_content = findODBCDriver($current, $lines_to_add);
file_put_contents($custom_odbcinst_ini, $new_content);

//Creating a new php process, because for changes in odbcinst.ini file to affect pooling, drivers must be reloaded.
//Also setting the odbcini path to the current folder for the same process.
Expand Down
4 changes: 2 additions & 2 deletions test/functional/pdo_sqlsrv/isPooled.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
include 'MsSetup.inc';
$conn1 = new PDO("sqlsrv:Server=$server; database=$databaseName", $uid, $pwd);
$conn1 = new PDO("sqlsrv:Server=$server; database=$databaseName; driver=$driver", $uid, $pwd);
$connId1 = ConnectionID($conn1);
$conn1 = null;

$conn2 = new PDO("sqlsrv:Server=$server; database=$databaseName", $uid, $pwd);
$conn2 = new PDO("sqlsrv:Server=$server; database=$databaseName; driver=$driver", $uid, $pwd);
$connId2 = ConnectionID($conn2);
$conn2 = null;

Expand Down
13 changes: 11 additions & 2 deletions test/functional/sqlsrv/sqlsrv_ConnPool_Unix.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ This test assumes the default odbcinst.ini has not been modified.
<?php if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') die("Skipped: Test for Linux and Mac"); ?>
--FILE--
<?php
function findODBCDriver($content, $lines_to_add)
{
require_once('MsSetup.inc');
$command = "odbcinst -q -d -n '$driver'";
$info = shell_exec($command);

return str_replace($info, $info.$lines_to_add, $content);
}

$lines_to_add="CPTimeout=5\n[ODBC]\nPooling=Yes\n";

//get default odbcinst.ini location
Expand All @@ -18,8 +27,8 @@ copy( $odbcinst_ini, $custom_odbcinst_ini);

//enable pooling by modifying the odbcinst.ini file
$current = file_get_contents($custom_odbcinst_ini);
$current.=$lines_to_add;
file_put_contents($custom_odbcinst_ini, $current);
$new_content = findODBCDriver($current, $lines_to_add);
file_put_contents($custom_odbcinst_ini, $new_content);

//Creating a new php process, because for changes in odbcinst.ini file to affect pooling, drivers must be reloaded.
//Also setting the odbcini path to the current folder for the same process.
Expand Down

0 comments on commit 53e4da4

Please sign in to comment.