Fixed two failing tests (#991)
This commit is contained in:
parent
f369ce6212
commit
7e0bf91eec
|
@ -17,6 +17,7 @@ function bindTypeNoEncoding($conn, $sql, $input)
|
|||
$stmt->setAttribute(constant('PDO::SQLSRV_ATTR_ENCODING'), PDO::SQLSRV_ENCODING_BINARY);
|
||||
$stmt->bindParam(2, $input, PDO::PARAM_LOB);
|
||||
$stmt->execute();
|
||||
echo "bindTypeNoEncoding: expected to fail!\n";
|
||||
} catch (PDOException $e) {
|
||||
$error = '*An encoding was specified for parameter 1. Only PDO::PARAM_LOB and PDO::PARAM_STR can take an encoding option.';
|
||||
if (!fnmatch($error, $e->getMessage())) {
|
||||
|
@ -36,6 +37,7 @@ function bindDefaultEncoding($conn, $sql, $input)
|
|||
$stmt->setAttribute(constant('PDO::SQLSRV_ATTR_ENCODING'), PDO::SQLSRV_ENCODING_BINARY);
|
||||
$stmt->bindParam(2, $input, PDO::PARAM_LOB);
|
||||
$stmt->execute();
|
||||
echo "bindDefaultEncoding: expected to fail!\n";
|
||||
} catch (PDOException $e) {
|
||||
$error = '*Invalid encoding specified for parameter 1.';
|
||||
if (!fnmatch($error, $e->getMessage())) {
|
||||
|
@ -52,8 +54,9 @@ function insertData($conn, $sql, $input)
|
|||
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bindParam(1, $value);
|
||||
$stmt->setAttribute(constant('PDO::SQLSRV_ATTR_ENCODING'), PDO::SQLSRV_ENCODING_BINARY);
|
||||
$stmt->bindParam(2, $input, PDO::PARAM_LOB);
|
||||
// Specify binary encoding for the second parameter only such that the first
|
||||
// parameter is unaffected
|
||||
$stmt->bindParam(2, $input, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);
|
||||
$stmt->execute();
|
||||
} catch (PDOException $e) {
|
||||
echo "Error unexpected in insertData\n";
|
||||
|
@ -68,6 +71,7 @@ function invalidEncoding1($conn, $sql)
|
|||
$stmt->bindColumn(1, $id, PDO::PARAM_INT, 0, PDO::SQLSRV_ENCODING_UTF8);
|
||||
$stmt->execute();
|
||||
$stmt->fetch(PDO::FETCH_BOUND);
|
||||
echo "invalidEncoding1: expected to fail!\n";
|
||||
} catch (PDOException $e) {
|
||||
$error = '*An encoding was specified for column 1. Only PDO::PARAM_LOB and PDO::PARAM_STR column types can take an encoding option.';
|
||||
if (!fnmatch($error, $e->getMessage())) {
|
||||
|
@ -84,6 +88,7 @@ function invalidEncoding2($conn, $sql)
|
|||
$stmt->bindColumn('Value', $val1, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_DEFAULT);
|
||||
$stmt->execute();
|
||||
$stmt->fetch(PDO::FETCH_BOUND);
|
||||
echo "invalidEncoding2: expected to fail!\n";
|
||||
} catch (PDOException $e) {
|
||||
$error = '*Invalid encoding specified for column 1.';
|
||||
if (!fnmatch($error, $e->getMessage())) {
|
||||
|
@ -100,6 +105,7 @@ function invalidEncoding3($conn, $sql)
|
|||
$stmt->bindColumn(1, $id, PDO::PARAM_STR, 0, "dummy");
|
||||
$stmt->execute();
|
||||
$stmt->fetch(PDO::FETCH_BOUND);
|
||||
echo "invalidEncoding3: expected to fail!\n";
|
||||
} catch (PDOException $e) {
|
||||
$error = '*An invalid type or value was given as bound column driver data for column 1. Only encoding constants such as PDO::SQLSRV_ENCODING_UTF8 may be used as bound column driver data.';
|
||||
if (!fnmatch($error, $e->getMessage())) {
|
||||
|
|
|
@ -11,15 +11,23 @@ $serverName = "WRONG_SERVER_NAME";
|
|||
|
||||
$t0 = microtime(true);
|
||||
|
||||
$conn = sqlsrv_connect($serverName , array("LoginTimeout" => 8));
|
||||
// Based on the following reference, a login timeout of less than approximately 10 seconds
|
||||
// is not reliable. The defaut is 15 seconds so we fix it at 20 seconds.
|
||||
// https://docs.microsoft.com/sql/connect/odbc/windows/features-of-the-microsoft-odbc-driver-for-sql-server-on-windows
|
||||
|
||||
$timeout = 20;
|
||||
$conn = sqlsrv_connect($serverName , array("LoginTimeout" => $timeout));
|
||||
|
||||
$t1 = microtime(true);
|
||||
|
||||
echo "Connection attempt time: " . ($t1 - $t0) . " [sec]\n";
|
||||
$elapsed = $t1 - $t0;
|
||||
$diff = abs($elapsed - $timeout);
|
||||
|
||||
if ($elapsed < $timeout || $diff > 1.0) {
|
||||
echo "Connection failed at $elapsed secs. Leeway is 1.0 sec but the difference is $diff\n";
|
||||
}
|
||||
|
||||
print "Done";
|
||||
?>
|
||||
|
||||
--EXPECTREGEX--
|
||||
Connection attempt time: [7-9]\.[0-9]+ \[sec\]
|
||||
--EXPECT--
|
||||
Done
|
||||
|
|
Loading…
Reference in a new issue