diff --git a/test/bvt/sqlsrv/msdn_sqlsrv_query_stream.phpt b/test/bvt/sqlsrv/msdn_sqlsrv_query_stream.phpt
index 4f1b737a..2e002f3e 100644
--- a/test/bvt/sqlsrv/msdn_sqlsrv_query_stream.phpt
+++ b/test/bvt/sqlsrv/msdn_sqlsrv_query_stream.phpt
@@ -1,56 +1,76 @@
---TEST--
-insert stream.
---SKIPIF--
-
-?>
---FILE--
+--TEST--
+insert stream.
+--SKIPIF--
+--FILE--
"$databaseName", "UID"=>"$uid", "PWD"=>"$pwd");
-$conn = sqlsrv_connect( $server, $connectionInfo);
-if( $conn === false )
-{
- echo "Could not connect.\n";
- die( print_r( sqlsrv_errors(), true));
+$conn = sqlsrv_connect($server, $connectionInfo);
+if ($conn === false) {
+ echo "Could not connect.\n";
+ die(print_r(sqlsrv_errors(), true));
}
+
+/* Remove any records with from the table with ProductID = 999*/
+$productID = 999;
+$tsql = "DELETE FROM Production.ProductReview WHERE ProductID = $productID";
+sqlsrv_query($conn, $tsql);
/* Set up the Transact-SQL query. */
-$tsql = "INSERT INTO Production.ProductReview (ProductID,
- ReviewerName,
- ReviewDate,
- EmailAddress,
- Rating,
- Comments)
+$tsql = "INSERT INTO Production.ProductReview (ProductID,
+ ReviewerName,
+ ReviewDate,
+ EmailAddress,
+ Rating,
+ Comments)
VALUES (?, ?, ?, ?, ?, ?)";
-
+
/* Set the parameter values and put them in an array.
Note that $comments is opened as a stream. */
-$productID = '709';
+
+$number = rand(99, 9999);
+$input = "[Insert some number $number]";
+
+/* There is no record in this table with ProductID = 999 */
$name = 'Customer Name';
$date = date("Y-m-d");
$email = 'customer@name.com';
$rating = 3;
-$comments = fopen( "data://text/plain,[ Insert lengthy comment here.]",
- "r");
+$comments = fopen("data://text/plain,$input", "r");
$params = array($productID, $name, $date, $email, $rating, $comments);
/* Execute the query. All stream data is sent upon execution.*/
$stmt = sqlsrv_query($conn, $tsql, $params);
-if( $stmt === false )
-{
- echo "Error in statement execution.\n";
- die( print_r( sqlsrv_errors(), true));
-}
-else
-{
- echo "The query was successfully executed.";
+if ($stmt === false) {
+ echo "Error in statement execution.\n";
+ die(print_r(sqlsrv_errors(), true));
}
+
+/* Read it back to check the comment */
+$tsql = "SELECT Comments FROM Production.ProductReview
+ WHERE ProductID = $productID";
+$stmt = sqlsrv_query($conn, $tsql);
+if (sqlsrv_fetch($stmt)) {
+ $review = sqlsrv_get_field($stmt, 0);
+ if ($review !== $input) {
+ echo "Comment retrieved \'$review\' is incorrect!" . PHP_EOL;
+ }
+} else {
+ echo "Error in retrieving comments!" . PHP_EOL;
+ die(print_r(sqlsrv_errors(), true));
+}
+
+/* Remove the entry from the table */
+$tsql = "DELETE FROM Production.ProductReview WHERE ProductID = $productID";
+sqlsrv_query($conn, $tsql);
+
+echo "Done" . PHP_EOL;
/* Free statement and connection resources. */
-sqlsrv_free_stmt( $stmt);
-sqlsrv_close( $conn);
-?>
---EXPECT--
+sqlsrv_free_stmt($stmt);
+sqlsrv_close($conn);
+?>
+--EXPECT--
The query was successfully executed.
\ No newline at end of file
diff --git a/test/bvt/sqlsrv/msdn_sqlsrv_send_stream_data.phpt b/test/bvt/sqlsrv/msdn_sqlsrv_send_stream_data.phpt
index eab20a3d..15cbade9 100644
--- a/test/bvt/sqlsrv/msdn_sqlsrv_send_stream_data.phpt
+++ b/test/bvt/sqlsrv/msdn_sqlsrv_send_stream_data.phpt
@@ -1,48 +1,69 @@
---TEST--
-Sends data from parameter streams to the server
---SKIPIF--
-
---FILE--
+--TEST--
+Sends data from parameter streams to the server
+--SKIPIF--
+
+--FILE--
"$databaseName", "UID"=>"$uid", "PWD"=>"$pwd");
-$conn = sqlsrv_connect( $server, $connectionInfo);
-if( $conn === false )
-{
- echo "Could not connect.
";
- die( print_r( sqlsrv_errors(), true));
+$connectionInfo = array("Database"=>"$databaseName", "UID"=>"$uid", "PWD"=>"$pwd");
+$conn = sqlsrv_connect($server, $connectionInfo);
+if ($conn === false) {
+ echo "Could not connect.
";
+ die(print_r(sqlsrv_errors(), true));
}
/* Define the query. */
-$tsql = "UPDATE Production.ProductReview
- SET Comments = ( ?)
+$tsql = "UPDATE Production.ProductReview
+ SET Comments = (?)
WHERE ProductReviewID = 3";
-
+$number = rand(99, 9999);
+$input = "[Insert some number $number]";
+
/* Open parameter data as a stream and put it in the $params array. */
-$comment = fopen( "data://text/plain,[ Insert lengthy comment.]", "r");
-$params = array( &$comment);
+$comments = fopen("data://text/plain,$input", "r");
+$params = array(&$comments);
/* Prepare the statement. Use the $options array to turn off the
default behavior, which is to send all stream data at the time of query
execution. */
-$options = array("SendStreamParamsAtExec"=>0);
-$stmt = sqlsrv_prepare( $conn, $tsql, $params, $options);
+$options = array("SendStreamParamsAtExec" => 0);
+$stmt = sqlsrv_prepare($conn, $tsql, $params, $options);
/* Execute the statement. */
-sqlsrv_execute( $stmt);
+sqlsrv_execute($stmt);
/* Send up to 8K of parameter data to the server with each call to
sqlsrv_send_stream_data. Count the calls. */
$i = 1;
-while( sqlsrv_send_stream_data( $stmt))
-{
- echo "$i call(s) made.
";
- $i++;
-}
+while (sqlsrv_send_stream_data($stmt)) {
+ $i++;
+}
+
+/* For PHP 7.2, it takes 2 calls whereas older PHP versions
+take up to 3 calls */
+if ($i < 2 || $i > 3) {
+ echo "Expects 2 to 3 calls only." . PHP_EOL;
+}
+
+/* Read it back to check the comments */
+$tsql = "SELECT Comments FROM Production.ProductReview
+ WHERE ProductReviewID = 3";
+$stmt = sqlsrv_query($conn, $tsql);
+if (sqlsrv_fetch($stmt)) {
+ $review = sqlsrv_get_field($stmt, 0);
+ if ($review !== $input) {
+ echo "Comments retrieved \'$review\' is incorrect!" . PHP_EOL;
+ }
+} else {
+ echo "Error in retrieving comments!" . PHP_EOL;
+ die(print_r(sqlsrv_errors(), true));
+}
+
+echo "Done" . PHP_EOL;
/* Free statement and connection resources. */
-sqlsrv_free_stmt( $stmt);
-sqlsrv_close( $conn);
-?>
---EXPECT--
-1 call(s) made.
2 call(s) made.
3 call(s) made.
\ No newline at end of file
+sqlsrv_free_stmt($stmt);
+sqlsrv_close($conn);
+?>
+--EXPECT--
+Done
\ No newline at end of file
diff --git a/test/bvt/sqlsrv/msdn_sqlsrv_send_stream_data_no_sendStreamParamsAtExec.phpt b/test/bvt/sqlsrv/msdn_sqlsrv_send_stream_data_no_sendStreamParamsAtExec.phpt
index f324c3c7..0731909b 100644
--- a/test/bvt/sqlsrv/msdn_sqlsrv_send_stream_data_no_sendStreamParamsAtExec.phpt
+++ b/test/bvt/sqlsrv/msdn_sqlsrv_send_stream_data_no_sendStreamParamsAtExec.phpt
@@ -1,39 +1,43 @@
---TEST--
-sned stream data with SendStreamParamsAtExec turned off.
---SKIPIF--
-
-?>
---FILE--
+--TEST--
+Send stream data with SendStreamParamsAtExec turned off.
+--SKIPIF--
+--FILE--
"$databaseName", "UID"=>"$uid", "PWD"=>"$pwd");
-$conn = sqlsrv_connect( $server, $connectionInfo);
-if( $conn === false )
-{
- echo "Could not connect.\n";
- die( print_r( sqlsrv_errors(), true));
+$connectionInfo = array("Database"=>"$databaseName", "UID"=>"$uid", "PWD"=>"$pwd");
+$conn = sqlsrv_connect($server, $connectionInfo);
+if ($conn === false) {
+ echo "Could not connect.\n";
+ die(print_r(sqlsrv_errors(), true));
}
+
+/* Remove any records with from the table with ProductID = 999*/
+$productID = 999;
+$tsql = "DELETE FROM Production.ProductReview WHERE ProductID = $productID";
+sqlsrv_query($conn, $tsql);
/* Set up the Transact-SQL query. */
-$tsql = "INSERT INTO Production.ProductReview (ProductID,
- ReviewerName,
- ReviewDate,
- EmailAddress,
- Rating,
- Comments)
+$tsql = "INSERT INTO Production.ProductReview (ProductID,
+ ReviewerName,
+ ReviewDate,
+ EmailAddress,
+ Rating,
+ Comments)
VALUES (?, ?, ?, ?, ?, ?)";
/* Set the parameter values and put them in an array.
-Note that $comments is opened as a stream. */
-$productID = '709';
+Note that $comments is opened as a stream. */
+$number = rand(99, 9999);
+$input = "[Insert some number $number]";
+
+/* There is no record in this table with ProductID 999 */
$name = 'Customer Name';
$date = date("Y-m-d");
$email = 'customer@name.com';
$rating = 3;
-$comments = fopen( "data://text/plain,[ Insert lengthy comment here.]",
- "r");
+$comments = fopen("data://text/plain,$input", "r");
$params = array($productID, $name, $date, $email, $rating, $comments);
/* Turn off the default behavior of sending all stream data at
@@ -42,26 +46,47 @@ $options = array("SendStreamParamsAtExec" => 0);
/* Execute the query. */
$stmt = sqlsrv_query($conn, $tsql, $params, $options);
-if( $stmt === false )
-{
- echo "Error in statement execution.\n";
- die( print_r( sqlsrv_errors(), true));
+if ($stmt === false) {
+ echo "Error in statement execution.\n";
+ die(print_r(sqlsrv_errors(), true));
}
/* Send up to 8K of parameter data to the server with each call to
sqlsrv_send_stream_data. Count the calls. */
$i = 1;
-while( sqlsrv_send_stream_data( $stmt))
-{
- echo "$i call(s) made.\n";
- $i++;
+while (sqlsrv_send_stream_data($stmt)) {
+ $i++;
}
+
+/* For PHP 7.2, it takes 2 calls whereas older PHP versions
+take up to 3 calls */
+if ($i < 2 || $i > 3) {
+ echo "Expects 2 to 3 calls only." . PHP_EOL;
+}
+
+/* Read it back to check the comments */
+$tsql = "SELECT Comments FROM Production.ProductReview
+ WHERE ProductID = $productID";
+$stmt = sqlsrv_query($conn, $tsql);
+if (sqlsrv_fetch($stmt)) {
+ $review = sqlsrv_get_field($stmt, 0);
+ if ($review !== $input) {
+ echo "Comments retrieved \'$review\' is incorrect!" . PHP_EOL;
+ }
+} else {
+ echo "Error in retrieving comments!" . PHP_EOL;
+ die(print_r(sqlsrv_errors(), true));
+}
+
+/* Remove the entry from the table */
+$tsql = "DELETE FROM Production.ProductReview WHERE ProductID = $productID";
+sqlsrv_query($conn, $tsql);
+
+echo "Done" . PHP_EOL;
/* Free statement and connection resources. */
-sqlsrv_free_stmt( $stmt);
-sqlsrv_close( $conn);
-?>
---EXPECT--
-1 call(s) made.
-2 call(s) made.
-3 call(s) made.
\ No newline at end of file
+sqlsrv_free_stmt($stmt);
+sqlsrv_close($conn);
+?>
+--EXPECT--
+Done
\ No newline at end of file