Made some tests more robust and work with PHP 8.1 (#1285)
This commit is contained in:
parent
5e607a802c
commit
fd48bcbf69
|
@ -79,7 +79,7 @@ install:
|
|||
}
|
||||
- echo Downloading MSODBCSQL 17
|
||||
# AppVeyor build works are x64 VMs and 32-bit ODBC driver cannot be installed on it
|
||||
- ps: (new-object net.webclient).DownloadFile('https://download.microsoft.com/download/2/c/c/2cc12eab-a3aa-45d6-95bb-13f968fb6cd6/en-US/17.7.2.1/x64/msodbcsql.msi', 'c:\projects\msodbcsql.msi')
|
||||
- ps: (new-object net.webclient).DownloadFile('https://download.microsoft.com/download/a/e/b/aeb7d4ff-ca20-45db-86b8-8a8f774ce97b/en-US/17.8.1.1/x64/msodbcsql.msi', 'c:\projects\msodbcsql.msi')
|
||||
- cmd /c start /wait msiexec /i "c:\projects\msodbcsql.msi" /q IACCEPTMSODBCSQLLICENSETERMS=YES ADDLOCAL=ALL
|
||||
- echo Checking the version of MSODBCSQL
|
||||
- reg query "HKLM\SOFTWARE\ODBC\odbcinst.ini\ODBC Driver 17 for SQL Server"
|
||||
|
|
|
@ -16,4 +16,11 @@ function dropProc($conn, $procName)
|
|||
sqlsrv_query($conn, $tsql);
|
||||
}
|
||||
|
||||
// RevisionNumber in SalesOrderHeader is subject to a trigger incrementing it whenever
|
||||
// changes are made to SalesOrderDetail. Since RevisionNumber is a tinyint, it can
|
||||
// overflow quickly if the BVT tests often run. Disable the trigger.
|
||||
function disableTrigger($conn)
|
||||
{
|
||||
sqlsrv_query($conn, 'DISABLE TRIGGER uSalesOrderHeader ON Sales.SalesOrderHeader');
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -14,8 +14,7 @@ if( $conn === false )
|
|||
die( print_r( sqlsrv_errors(), true ));
|
||||
}
|
||||
|
||||
$tsql = "DISABLE TRIGGER uSalesOrderHeader ON Sales.SalesOrderHeader";
|
||||
$stmt = sqlsrv_query($conn, $tsql);
|
||||
disableTrigger($conn);
|
||||
|
||||
/* Initiate transaction. */
|
||||
/* Exit script if transaction cannot be initiated. */
|
||||
|
@ -64,9 +63,6 @@ else
|
|||
$d_sql = "DELETE FROM Sales.SalesOrderDetail WHERE SalesOrderID=43659 AND OrderQty=5 AND ProductID=709 AND SpecialOfferID=1 AND Unitprice=5.70";
|
||||
$stmt3 = sqlsrv_query($conn, $d_sql);
|
||||
|
||||
$tsql = "ENABLE TRIGGER uSalesOrderHeader ON Sales.SalesOrderHeader";
|
||||
$stmt = sqlsrv_query($conn, $tsql);
|
||||
|
||||
/* Free statement and connection resources. */
|
||||
sqlsrv_free_stmt( $stmt1);
|
||||
sqlsrv_free_stmt( $stmt2);
|
||||
|
|
|
@ -57,12 +57,7 @@ echo "<br>";
|
|||
|
||||
sqlsrv_free_stmt( $stmt);
|
||||
|
||||
// RevisionNumber in SalesOrderHeader is subject to a trigger incrementing it whenever
|
||||
// changes are made to SalesOrderDetail. Since RevisonNumber is a tinyint, it can
|
||||
// overflow quickly if this test is often run. So disable the trigger.
|
||||
$tsql = "DISABLE TRIGGER uSalesOrderHeader ON Sales.SalesOrderHeader";
|
||||
$stmt = sqlsrv_query($conn, $tsql);
|
||||
|
||||
disableTrigger($conn);
|
||||
|
||||
/* Prepare with string type in parameter. */
|
||||
$tsql = "UPDATE Sales.SalesOrderDetail
|
||||
|
@ -142,10 +137,6 @@ else
|
|||
}
|
||||
echo sqlsrv_rows_affected( $stmt)." rows affected.<br>";
|
||||
|
||||
// Re-enable the trigger
|
||||
$tsql = "ENABLE TRIGGER uSalesOrderHeader ON Sales.SalesOrderHeader";
|
||||
$stmt = sqlsrv_query($conn, $tsql);
|
||||
|
||||
/* Free the statement and connection resources. */
|
||||
sqlsrv_free_stmt( $stmt);
|
||||
sqlsrv_close( $conn);
|
||||
|
|
|
@ -15,11 +15,7 @@ if( $conn === false )
|
|||
die( print_r( sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
// RevisionNumber in SalesOrderHeader is subject to a trigger incrementing it whenever
|
||||
// changes are made to SalesOrderDetail. Since RevisonNumber is a tinyint, it can
|
||||
// overflow quickly if this test is often run. So disable the trigger.
|
||||
$tsql = "DISABLE TRIGGER uSalesOrderHeader ON Sales.SalesOrderHeader";
|
||||
$stmt = sqlsrv_query($conn, $tsql);
|
||||
disableTrigger($conn);
|
||||
|
||||
/* Set up the parameterized query. */
|
||||
$tsql = "INSERT INTO Sales.SalesOrderDetail
|
||||
|
@ -47,10 +43,6 @@ else
|
|||
die( print_r( sqlsrv_errors(), true));
|
||||
}
|
||||
|
||||
// Re-enable the trigger
|
||||
$tsql = "ENABLE TRIGGER uSalesOrderHeader ON Sales.SalesOrderHeader";
|
||||
$stmt = sqlsrv_query($conn, $tsql);
|
||||
|
||||
/* Free statement and connection resources. */
|
||||
sqlsrv_free_stmt( $stmt);
|
||||
sqlsrv_close( $conn);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
--TEST--
|
||||
Test for retrieving encrypted data of floats as output parameters
|
||||
--DESCRIPTION--
|
||||
Use PDOstatement::bindParam with all PDO::PARAM_ types
|
||||
Use PDOstatement::bindParam with all PDO::PARAM_ types. This test generates input float. For your reference:
|
||||
https://en.wikipedia.org/wiki/Single-precision_floating-point_format#Precision_limitations_on_integer_values
|
||||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
|
@ -51,9 +52,9 @@ function testOutputFloats($fetchNumeric, $inout)
|
|||
$inputValues = array();
|
||||
// create random input values
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
$mantissa = rand(1, 100000000);
|
||||
$decimals = rand(1, 100000000);
|
||||
$floatNum = $mantissa + $decimals / 10000000;
|
||||
$mantissa = rand(1, 10000000);
|
||||
$decimals = rand(1, 100);
|
||||
$floatNum = $mantissa + $decimals / 10000;
|
||||
if ($i > 0) {
|
||||
// make the second input negative
|
||||
$floatNum *= -1;
|
||||
|
|
|
@ -11,6 +11,16 @@ PHPT_EXEC=true
|
|||
require_once('MsSetup.inc');
|
||||
require_once('MsCommon_mid-refactor.inc');
|
||||
|
||||
function verifyPhoto($image, $photo)
|
||||
{
|
||||
// With PHP 8.1+, bindColumn() of binary fields will be resource
|
||||
if (PHP_VERSION_ID >= 80100) {
|
||||
return verifyBinaryStream($image, $photo);
|
||||
} else {
|
||||
return verifyBinaryData($image, $photo);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
date_default_timezone_set('America/Los_Angeles');
|
||||
|
||||
|
@ -76,7 +86,7 @@ try {
|
|||
$stmt = $conn->query($tsql);
|
||||
$stmt->bindColumn('Photo', $photo, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);
|
||||
if ($row = $stmt->fetch(PDO::FETCH_BOUND)) {
|
||||
if (!verifyBinaryData($images[$index], $photo)) {
|
||||
if (!verifyPhoto($images[$index], $photo)) {
|
||||
echo 'Image data corrupted for row '. ($index + 1) . PHP_EOL;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -11,6 +11,16 @@ PHPT_EXEC=true
|
|||
require_once('MsSetup.inc');
|
||||
require_once('MsCommon_mid-refactor.inc');
|
||||
|
||||
function verifyPhoto($image, $photo)
|
||||
{
|
||||
// With PHP 8.1+, bindColumn() of binary fields will be resource
|
||||
if (PHP_VERSION_ID >= 80100) {
|
||||
return verifyBinaryStream($image, $photo);
|
||||
} else {
|
||||
return verifyBinaryData($image, $photo);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
date_default_timezone_set('America/Los_Angeles');
|
||||
|
||||
|
@ -84,8 +94,9 @@ try {
|
|||
$stmt = $conn->query($tsql);
|
||||
$index = 2;
|
||||
$stmt->bindColumn('Photo', $photo, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY);
|
||||
|
||||
if ($row = $stmt->fetch(PDO::FETCH_BOUND)) {
|
||||
if (!verifyBinaryData($images[$index], $photo)) {
|
||||
if (!verifyPhoto($images[$index], $photo)) {
|
||||
echo 'Image data corrupted for row '. ($index + 1) . PHP_EOL;
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue