From 132dc7e9e91f06f3b1e648c16cbfe1063918d8c6 Mon Sep 17 00:00:00 2001 From: v-kaywon Date: Tue, 16 Jan 2018 15:47:36 -0800 Subject: [PATCH] correct tests with streaming --- test/functional/sqlsrv/0020.phpt | 8 +------ test/functional/sqlsrv/0066.phpt | 6 +---- test/functional/sqlsrv/TC42_FetchField.phpt | 12 +--------- test/functional/sqlsrv/TC51_StreamRead.phpt | 16 +------------ test/functional/sqlsrv/TC81_MemoryCheck.phpt | 9 +------ .../sqlsrv/sqlsrv_fetch_large_stream.phpt | 24 +++++++------------ test/functional/sqlsrv/sqlsrv_prepare.phpt | 6 +---- test/functional/sqlsrv/sqlsrv_query.phpt | 6 +---- .../sqlsrv/sqlsrv_send_stream_data.phpt | 6 +---- .../sqlsrv/test_warning_errors3.phpt | 6 +---- 10 files changed, 17 insertions(+), 82 deletions(-) diff --git a/test/functional/sqlsrv/0020.phpt b/test/functional/sqlsrv/0020.phpt index ef7df7cb..150c56bd 100644 --- a/test/functional/sqlsrv/0020.phpt +++ b/test/functional/sqlsrv/0020.phpt @@ -23,8 +23,6 @@ function runTest($fieldType) sqlsrv_fetch($stmt) || die(print_r(sqlsrv_errors(), true)); - // Do not support getting stream if AE enabled, so expect - // it to fail with the correct error message $stream = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STREAM("char")); if ($stream) { stream_filter_append($originalStream, "convert.base64-encode") @@ -37,11 +35,7 @@ function runTest($fieldType) } } } else { - if (AE\isColEncrypted()) { - verifyError(sqlsrv_errors()[0], 'IMSSP', 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.'); - } else { - fatalError('Fetching data stream failed!'); - } + fatalError('Fetching data stream failed!'); } dropTable($conn, $params['tableName']); diff --git a/test/functional/sqlsrv/0066.phpt b/test/functional/sqlsrv/0066.phpt index a8bcf590..5af8f85a 100644 --- a/test/functional/sqlsrv/0066.phpt +++ b/test/functional/sqlsrv/0066.phpt @@ -38,11 +38,7 @@ inserting and retrieving UTF-8 text. $u = sqlsrv_get_field($s, 1, SQLSRV_PHPTYPE_STREAM('utf-8')); if ($u === false) { - if (AE\isColEncrypted()) { - verifyError(sqlsrv_errors()[0], 'IMSSP', 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.'); - } else { - die(print_r(sqlsrv_errors(), true)); - } + die(print_r(sqlsrv_errors(), true)); } else { $utf8_2 = fread($u, 10000); if ($utf8 != $utf8_2) { diff --git a/test/functional/sqlsrv/TC42_FetchField.phpt b/test/functional/sqlsrv/TC42_FetchField.phpt index d605bcea..c3ac8580 100644 --- a/test/functional/sqlsrv/TC42_FetchField.phpt +++ b/test/functional/sqlsrv/TC42_FetchField.phpt @@ -33,9 +33,6 @@ function fetchFields() $stmt1 = AE\selectFromTable($conn1, $tableName); $numFields = sqlsrv_num_fields($stmt1); - $errState = 'IMSSP'; - $errMessage = 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.'; - trace("Retrieving $noRowsInserted rows with $numFields fields each ..."); for ($i = 0; $i < $noRowsInserted; $i++) { $row = sqlsrv_fetch($stmt1); @@ -44,16 +41,9 @@ function fetchFields() } for ($j = 0; $j < $numFields; $j++) { $fld = sqlsrv_get_field($stmt1, $j); - - // With AE enabled, those fields that sqlsrv_get_field() will fetch - // as stream data will return a specific error message $col = $j+1; if ($fld === false) { - if (AE\isColEncrypted() && isStreamData($col)) { - verifyError(sqlsrv_errors()[0], $errState, $errMessage); - } else { - fatalError("Field $j of Row $i is missing\n", true); - } + fatalError("Field $j of Row $i is missing\n", true); } } } diff --git a/test/functional/sqlsrv/TC51_StreamRead.phpt b/test/functional/sqlsrv/TC51_StreamRead.phpt index 6412f458..0f223ccc 100644 --- a/test/functional/sqlsrv/TC51_StreamRead.phpt +++ b/test/functional/sqlsrv/TC51_StreamRead.phpt @@ -68,7 +68,7 @@ function verifyStream($stmt, $row, $colIndex) } } if ($stream === false) { - verifyStreamError("Failed to read field $col: $type"); + fatalError("Failed to read field $col: $type"); } else { $value = ''; if ($stream) { @@ -87,16 +87,6 @@ function verifyStream($stmt, $row, $colIndex) } } -function verifyStreamError($message) -{ - global $errState, $errMessage; - if (AE\isColEncrypted()) { - verifyError(sqlsrv_errors()[0], $errState, $errMessage); - } else { - fatalError($message); - } -} - function checkData($col, $actual, $expected) { $success = true; @@ -128,10 +118,6 @@ setUSAnsiLocale(); global $testName; $testName = "Stream - Read"; -// error message expected with AE enabled -$errState = 'IMSSP'; -$errMessage = 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.'; - // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) startTest($testName); if (isLocaleSupported()) { diff --git a/test/functional/sqlsrv/TC81_MemoryCheck.phpt b/test/functional/sqlsrv/TC81_MemoryCheck.phpt index 5712eb8d..6ba19639 100644 --- a/test/functional/sqlsrv/TC81_MemoryCheck.phpt +++ b/test/functional/sqlsrv/TC81_MemoryCheck.phpt @@ -272,9 +272,6 @@ function runTest($noPasses, $noRows, $tableName, $conn, $prepared, $release, $mo break; case 5: // fetch fields - $errState = 'IMSSP'; - $errMessage = 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.'; - $stmt = execQuery($conn, $tableName, $prepared); $numFields = sqlsrv_num_fields($stmt); while (sqlsrv_fetch($stmt)) { @@ -284,11 +281,7 @@ function runTest($noPasses, $noRows, $tableName, $conn, $prepared, $release, $mo $col = $i + 1; if ($fld === false) { - if (AE\isColEncrypted() && isStreamData($col)) { - verifyError(sqlsrv_errors()[0], $errState, $errMessage); - } else { - fatalError("Field $i of row $rowCount is missing"); - } + fatalError("Field $i of row $rowCount is missing"); } unset($fld); } diff --git a/test/functional/sqlsrv/sqlsrv_fetch_large_stream.phpt b/test/functional/sqlsrv/sqlsrv_fetch_large_stream.phpt index 3bb94841..7b6f6e40 100644 --- a/test/functional/sqlsrv/sqlsrv_fetch_large_stream.phpt +++ b/test/functional/sqlsrv/sqlsrv_fetch_large_stream.phpt @@ -35,23 +35,15 @@ if (!sqlsrv_fetch($stmt)) { $stream = sqlsrv_get_field($stmt, 0, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_CHAR)); $success = false; -if ($stream === false) { - $error = sqlsrv_errors()[0]; - if (AE\isColEncrypted() && $error['SQLSTATE'] === "IMSSP" && $error['code'] === -109 && - $error['message'] === "Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.") { - $success = true; - } -} else { +if ($stream !== false) { $value = ''; - if (!AE\isColEncrypted()) { - $num = 0; - while (!feof($stream)) { - $value .= fread($stream, 8192); - } - fclose($stream); - if (checkData($value, $inValue)) { // compare the data to see if they match! - $success = true; - } + $num = 0; + while (!feof($stream)) { + $value .= fread($stream, 8192); + } + fclose($stream); + if (checkData($value, $inValue)) { // compare the data to see if they match! + $success = true; } } if ($success) { diff --git a/test/functional/sqlsrv/sqlsrv_prepare.phpt b/test/functional/sqlsrv/sqlsrv_prepare.phpt index 8f504303..deda10c9 100644 --- a/test/functional/sqlsrv/sqlsrv_prepare.phpt +++ b/test/functional/sqlsrv/sqlsrv_prepare.phpt @@ -80,11 +80,7 @@ binding parameters, including output parameters, using the simplified syntax. echo "$name\n"; $stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY)); if (!$stream) { - if (AE\isColEncrypted()) { - verifyError(sqlsrv_errors()[0], 'IMSSP', 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.'); - } else { - fatalError('Fetching data stream failed!'); - } + fatalError('Fetching data stream failed!'); } else { while (!feof($stream)) { $str = fread($stream, 10000); diff --git a/test/functional/sqlsrv/sqlsrv_query.phpt b/test/functional/sqlsrv/sqlsrv_query.phpt index e3fde92a..3350e90c 100644 --- a/test/functional/sqlsrv/sqlsrv_query.phpt +++ b/test/functional/sqlsrv/sqlsrv_query.phpt @@ -49,11 +49,7 @@ sqlsrv_query test. Performs same tasks as 0006.phpt, using sqlsrv_query. echo "$name\n"; $stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY)); if (!$stream) { - if (AE\isColEncrypted()) { - verifyError(sqlsrv_errors()[0], 'IMSSP', 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.'); - } else { - fatalError('Fetching data stream failed!'); - } + fatalError('Fetching data stream failed!'); } else { while (!feof($stream)) { $str = fread($stream, 4000); diff --git a/test/functional/sqlsrv/sqlsrv_send_stream_data.phpt b/test/functional/sqlsrv/sqlsrv_send_stream_data.phpt index aa9ff82d..1f3982b6 100644 --- a/test/functional/sqlsrv/sqlsrv_send_stream_data.phpt +++ b/test/functional/sqlsrv/sqlsrv_send_stream_data.phpt @@ -114,11 +114,7 @@ binding streams using full syntax. echo "$name\n"; $stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY)); if (!$stream) { - if (AE\isColEncrypted()) { - verifyError(sqlsrv_errors()[0], 'IMSSP', 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.'); - } else { - fatalError('Fetching data stream failed!'); - } + fatalError('Fetching data stream failed!'); } else { while (!feof($stream)) { $str = fread($stream, 10000); diff --git a/test/functional/sqlsrv/test_warning_errors3.phpt b/test/functional/sqlsrv/test_warning_errors3.phpt index 9ee8dc37..1b0bdc66 100644 --- a/test/functional/sqlsrv/test_warning_errors3.phpt +++ b/test/functional/sqlsrv/test_warning_errors3.phpt @@ -86,11 +86,7 @@ error messages when trying to retrieve past the end of a result set and when no echo "$name\n"; $stream = sqlsrv_get_field($stmt, 3, SQLSRV_PHPTYPE_STREAM(SQLSRV_ENC_BINARY)); if (!$stream) { - if (AE\isColEncrypted()) { - verifyError(sqlsrv_errors()[0], 'IMSSP', 'Connection with Column Encryption enabled does not support fetching stream. Please fetch the data as a string.'); - } else { - fatalError('Fetching data stream failed!'); - } + fatalError('Fetching data stream failed!'); } else { while (!feof($stream)) { $str = fread($stream, 10000);