Tweaks and fixes for certain tests
This commit is contained in:
parent
11aa0073c0
commit
862b275459
|
@ -13,6 +13,9 @@ $lines_to_add="CPTimeout=5\n[ODBC]\nPooling=Yes\n";
|
|||
$lines = explode("\n", shell_exec("odbcinst -j"));
|
||||
$odbcinst_ini = explode(" ", $lines[1])[1];
|
||||
|
||||
//back up the odbcinst.ini file
|
||||
shell_exec("cp $odbcinst_ini $odbcinst_ini.bak")
|
||||
|
||||
//enable pooling by modifying the odbcinst.ini file
|
||||
$current = file_get_contents($odbcinst_ini);
|
||||
$current.=$lines_to_add;
|
||||
|
@ -28,8 +31,14 @@ file_put_contents($odbcinst_ini, $current);
|
|||
|
||||
print_r(shell_exec("php ./test/pdo_sqlsrv/isPooled.php"));
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
$lines = explode("\n", shell_exec("odbcinst -j"));
|
||||
$odbcinst_ini = explode(" ", $lines[1])[1];
|
||||
shell_exec("cp /etc/odbcinst.ini.bak $odbcinst_ini");
|
||||
shell_exec("rm /etc/odbcinst.ini.bak");
|
||||
?>
|
||||
--EXPECT--
|
||||
Pooled
|
||||
Not Pooled
|
||||
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ SQLSRV Connection Pooling Test on Unix
|
|||
This test assumes odbcinst.ini has not been modified.
|
||||
This test also requires root privileges to modify odbcinst.ini file on Linux.
|
||||
--SKIPIF--
|
||||
<?php if(PHP_OS === "WINNT") die("Skipped: Test for Linux and Mac");?>
|
||||
<?php if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') die("Skipped: Test for Linux and Mac");
|
||||
--FILE--
|
||||
<?php
|
||||
$lines_to_add="CPTimeout=5\n[ODBC]\nPooling=Yes\n";
|
||||
|
@ -13,6 +13,9 @@ $lines_to_add="CPTimeout=5\n[ODBC]\nPooling=Yes\n";
|
|||
$lines = explode("\n", shell_exec("odbcinst -j"));
|
||||
$odbcinst_ini = explode(" ", $lines[1])[1];
|
||||
|
||||
//back up the odbcinst.ini file
|
||||
shell_exec("cp $odbcinst_ini $odbcinst_ini.bak")
|
||||
|
||||
//enable pooling by modifying the odbcinst.ini file
|
||||
$current = file_get_contents($odbcinst_ini);
|
||||
$current.=$lines_to_add;
|
||||
|
@ -28,8 +31,14 @@ file_put_contents($odbcinst_ini, $current);
|
|||
|
||||
print_r(shell_exec("php ./test/sqlsrv/isPooled.php"));
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
$lines = explode("\n", shell_exec("odbcinst -j"));
|
||||
$odbcinst_ini = explode(" ", $lines[1])[1];
|
||||
shell_exec("cp /etc/odbcinst.ini.bak $odbcinst_ini");
|
||||
shell_exec("rm /etc/odbcinst.ini.bak");
|
||||
?>
|
||||
--EXPECT--
|
||||
Pooled
|
||||
Not Pooled
|
||||
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ sqlsrv_configure( 'WarningsReturnAsErrors', 0 );
|
|||
sqlsrv_configure( 'LogSeverity', SQLSRV_LOG_SEVERITY_ALL );
|
||||
|
||||
// test an invalid encoding
|
||||
$c = connect(array( 'CharacterSet' => 'jibberish' ));
|
||||
$c = connect(array( 'CharacterSet' => 'gibberish' ));
|
||||
if( $c !== false ) {
|
||||
FatalError( "Should have errored on an invalid encoding." );
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ Array
|
|||
[SQLSTATE] => IMSSP
|
||||
[1] => -48
|
||||
[code] => -48
|
||||
[2] => The encoding 'jibberish' is not a supported encoding for the CharacterSet connection option.
|
||||
[2] => The encoding 'gibberish' is not a supported encoding for the CharacterSet connection option.
|
||||
[message] => The encoding 'jibberish' is not a supported encoding for the CharacterSet connection option.
|
||||
)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
--TEST--
|
||||
warnings as errors
|
||||
--SKIPIF--
|
||||
<?php require('skipif_unix.inc'); ?>
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
@ -14,8 +14,15 @@ $conn = Connect();
|
|||
if( $conn === false ) {
|
||||
die( print_r( sqlsrv_errors(), true ));
|
||||
}
|
||||
|
||||
// Should print connection warnings and not die
|
||||
// Outputting the first two elements works around a bug in unixODBC that
|
||||
// duplicates error messages and would otherwise cause the test to fail because
|
||||
// of the extra output
|
||||
echo "Warnings from sqlsrv_connect:\n";
|
||||
print_r( sqlsrv_errors(SQLSRV_ERR_WARNINGS) ); // should print connection warnings and not die
|
||||
print_r( sqlsrv_errors(SQLSRV_ERR_WARNINGS)[0] );
|
||||
print_r( sqlsrv_errors(SQLSRV_ERR_WARNINGS)[1] );
|
||||
|
||||
echo "Errors from sqlsrv_connect:\n";
|
||||
print_r( sqlsrv_errors(SQLSRV_ERR_ERRORS) );
|
||||
$v1 = 1;
|
||||
|
@ -34,8 +41,10 @@ if( $stmt === false ) {
|
|||
echo "Errors from sqlsrv_query with WarningsReturnAsErrors = true:\n";
|
||||
print_r( sqlsrv_errors(SQLSRV_ERR_ERRORS) ); // should be 1 warning of '3'
|
||||
}
|
||||
|
||||
echo "Warnings from sqlsrv_query with WarningsReturnAsErrors = true:\n";
|
||||
print_r( sqlsrv_errors(SQLSRV_ERR_WARNINGS) ); // should be nothing
|
||||
|
||||
echo "Output:\n$v3\n";
|
||||
|
||||
sqlsrv_configure( 'WarningsReturnAsErrors', false );
|
||||
|
@ -44,8 +53,10 @@ if( $stmt === false ) {
|
|||
echo "Errors from sqlsrv_query with WarningsReturnAsErrors = false:\n";
|
||||
die( print_r( sqlsrv_errors() ));
|
||||
}
|
||||
|
||||
echo "Warnings from sqlsrv_query with WarningsReturnAsErrors = false:\n";
|
||||
print_r( sqlsrv_errors() );
|
||||
|
||||
echo "Output:\n$v3\n";
|
||||
|
||||
sqlsrv_close( $conn );
|
||||
|
@ -57,26 +68,21 @@ print "Test successful";
|
|||
Warnings from sqlsrv_connect:
|
||||
Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => 01000
|
||||
[SQLSTATE] => 01000
|
||||
[1] => 5701
|
||||
[code] => 5701
|
||||
[2] => %SChanged database context to '%S'.
|
||||
[message] => %SChanged database context to '%S'.
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[0] => 01000
|
||||
[SQLSTATE] => 01000
|
||||
[1] => 5703
|
||||
[code] => 5703
|
||||
[2] => %SChanged language setting to us_english.
|
||||
[message] => %SChanged language setting to us_english.
|
||||
)
|
||||
|
||||
[0] => 01000
|
||||
[SQLSTATE] => 01000
|
||||
[1] => 5701
|
||||
[code] => 5701
|
||||
[2] => %SChanged database context to '%S'.
|
||||
[message] => %SChanged database context to '%S'.
|
||||
)
|
||||
Array
|
||||
(
|
||||
[0] => 01000
|
||||
[SQLSTATE] => 01000
|
||||
[1] => 5703
|
||||
[code] => 5703
|
||||
[2] => %SChanged language setting to us_english.
|
||||
[message] => %SChanged language setting to us_english.
|
||||
)
|
||||
Errors from sqlsrv_connect:
|
||||
Errors from raiserror
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
--TEST--
|
||||
warnings as errors
|
||||
--SKIPIF--
|
||||
<?php require('skipif_unix.inc'); ?>
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
@ -50,7 +50,10 @@ $result = sqlsrv_rows_affected( $stmt );
|
|||
if( $result !== false ) {
|
||||
die( "sqlsrv_rows_affected should have failed because it wasn't yet executed." );
|
||||
}
|
||||
print_r( sqlsrv_errors() );
|
||||
// Outputting the zero element of the error array works around a bug in the
|
||||
// ODBC driver for Linux that produces an error message saying 'Cancel treated
|
||||
// as FreeStmt/Close' on a statement that has not been executed.
|
||||
print_r( sqlsrv_errors()[0] );
|
||||
|
||||
sqlsrv_execute( $stmt );
|
||||
|
||||
|
@ -146,15 +149,11 @@ Array
|
|||
)
|
||||
Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => IMSSP
|
||||
[SQLSTATE] => IMSSP
|
||||
[1] => -11
|
||||
[code] => -11
|
||||
[2] => The statement must be executed before results can be retrieved.
|
||||
[message] => The statement must be executed before results can be retrieved.
|
||||
)
|
||||
|
||||
[0] => IMSSP
|
||||
[SQLSTATE] => IMSSP
|
||||
[1] => -11
|
||||
[code] => -11
|
||||
[2] => The statement must be executed before results can be retrieved.
|
||||
[message] => The statement must be executed before results can be retrieved.
|
||||
)
|
||||
Test successful
|
||||
|
|
Loading…
Reference in a new issue