From b5821b28f8a76b688b1d42cd8798f80b72dfafbc Mon Sep 17 00:00:00 2001 From: v-susanh Date: Sat, 17 Mar 2018 00:22:50 -0700 Subject: [PATCH] Updated to handle non-encrypted data (#724) updated to handle non-encrypted data --- ...lsrv_ae_output_param_sqltype_datetime.phpt | 10 +++-- ...qlsrv_ae_output_param_sqltype_numeric.phpt | 39 ++++++++++--------- ...sqlsrv_ae_output_param_sqltype_string.phpt | 12 +++--- 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/test/functional/sqlsrv/sqlsrv_ae_output_param_sqltype_datetime.phpt b/test/functional/sqlsrv/sqlsrv_ae_output_param_sqltype_datetime.phpt index 19631bca..7eebb400 100755 --- a/test/functional/sqlsrv/sqlsrv_ae_output_param_sqltype_datetime.phpt +++ b/test/functional/sqlsrv/sqlsrv_ae_output_param_sqltype_datetime.phpt @@ -80,17 +80,19 @@ foreach ($dataTypes as $dataType) { } sqlsrv_execute($stmt); $errors = sqlsrv_errors(); - if (empty($errors)) { + if (empty($errors) && AE\IsDataEncrypted()) { // SQLSRV_PHPTYPE_DATETIME not supported echo "$dataType should not be compatible with any datetime type.\n"; $success = false; } } - - sqlsrv_free_stmt($stmt); } } - } + } + + // cleanup + sqlsrv_free_stmt($stmt); + sqlsrv_query($conn, "TRUNCATE TABLE $tbname"); if ($success) { echo "Test successfully done.\n"; diff --git a/test/functional/sqlsrv/sqlsrv_ae_output_param_sqltype_numeric.phpt b/test/functional/sqlsrv/sqlsrv_ae_output_param_sqltype_numeric.phpt index a5f20e43..25d7d15f 100755 --- a/test/functional/sqlsrv/sqlsrv_ae_output_param_sqltype_numeric.phpt +++ b/test/functional/sqlsrv/sqlsrv_ae_output_param_sqltype_numeric.phpt @@ -25,7 +25,7 @@ $compatList = array("bit" => array( "SQLSRV_SQLTYPE_BINARY", "SQLSRV_SQLTYPE_VAR $epsilon = 0.0001; $conn = AE\connect(); - + foreach ($dataTypes as $dataType) { echo "\nTesting $dataType:\n"; $success = true; @@ -101,24 +101,26 @@ foreach ($dataTypes as $dataType) { if (stripos("SQLSRV_SQLTYPE_" . $dataType, $sqlType) !== false) { var_dump(sqlsrv_errors()); $success = false; - } + } } else { - if ($dataType == "float" || $dataType == "real") { - if (abs($c_detOut - $inputValues[0]) > $epsilon || abs($c_randOut - $inputValues[1]) > $epsilon) { - echo "Incorrect output retrieved for datatype $dataType and sqlType $sqlType:\n"; - print(" c_det: " . $c_detOut . "\n"); - print(" c_rand: " . $c_randOut . "\n"); - $success = false; - } - } else { - if ($c_detOut != $inputValues[0] || $c_randOut != $inputValues[1]) { - echo "Incorrect output retrieved for datatype $dataType and sqlType $sqlType:\n"; - print(" c_det: " . $c_detOut . "\n"); - print(" c_rand: " . $c_randOut . "\n"); - $success = false; - } - } + if (AE\IsDataEncrypted() || stripos("SQLSRV_SQLTYPE_" . $dataType, $sqlType) !== false) { + if ($dataType == "float" || $dataType == "real") { + if (abs($c_detOut - $inputValues[0]) > $epsilon || abs($c_randOut - $inputValues[1]) > $epsilon) { + echo "Incorrect output retrieved for datatype $dataType and sqlType $sqlType:\n"; + print(" c_det: " . $c_detOut . "\n"); + print(" c_rand: " . $c_randOut . "\n"); + $success = false; + } + } else { + if ($c_detOut != $inputValues[0] || $c_randOut != $inputValues[1]) { + echo "Incorrect output retrieved for datatype $dataType and sqlType $sqlType:\n"; + print(" c_det: " . $c_detOut . "\n"); + print(" c_rand: " . $c_randOut . "\n"); + $success = false; + } + } + } } sqlsrv_free_stmt($stmt); @@ -130,10 +132,11 @@ foreach ($dataTypes as $dataType) { if (AE\isColEncrypted()) { dropProc($conn, $spname); } - + if ($success) { echo "Test successfully done.\n"; } + dropTable($conn, $tbname); } diff --git a/test/functional/sqlsrv/sqlsrv_ae_output_param_sqltype_string.phpt b/test/functional/sqlsrv/sqlsrv_ae_output_param_sqltype_string.phpt index 44057427..77d53147 100755 --- a/test/functional/sqlsrv/sqlsrv_ae_output_param_sqltype_string.phpt +++ b/test/functional/sqlsrv/sqlsrv_ae_output_param_sqltype_string.phpt @@ -89,11 +89,13 @@ foreach ($dataTypes as $dataType) { } else { - if ($c_detOut != $inputValues[0] || $c_randOut != $inputValues[1]) { - echo "Incorrect output retrieved for datatype $dataType and sqlType $sqlType:\n"; - print(" c_det: " . $c_detOut . "\n"); - print(" c_rand: " . $c_randOut . "\n"); - $success = false; + if (AE\IsDataEncrypted() || stripos("SQLSRV_SQLTYPE_" . $dataType, $sqlType) !== false) { + if ($c_detOut != $inputValues[0] || $c_randOut != $inputValues[1]) { + echo "Incorrect output retrieved for datatype $dataType and sqlType $sqlType:\n"; + print(" c_det: " . $c_detOut . "\n"); + print(" c_rand: " . $c_randOut . "\n"); + $success = false; + } } }