fix tests according to review comments

This commit is contained in:
v-kaywon 2018-03-13 12:50:20 -07:00
parent 24938f5232
commit c1afad2d57
18 changed files with 45 additions and 40 deletions

View file

@ -2,7 +2,7 @@
Test for retrieving encrypted data from char types columns using PDO::bindColumn
--DESCRIPTION--
Test conversion from char types column to output of PDO::PARAM types
With or without AE, conversion works if:
With or without Always Encrypted, conversion works if:
1. From any char type column to PDO::PARAM_STR
2. From any char type column to PDO::PARAM_LOB
--SKIPIF--

View file

@ -2,7 +2,7 @@
Test for retrieving encrypted data from datetime types columns using PDO::bindColumn
--DESCRIPTION--
Test conversion from datetime types column to output of PDO::PARAM types
With or without AE, conversion works if:
With or without Always Encrypted, conversion works if:
1. From any datetime type column to PDO::PARAM_STR
2. From any datetime type column to PDO::PARAM_LOB
--SKIPIF--
@ -38,7 +38,7 @@ try {
$row = $stmt->fetch(PDO::FETCH_BOUND);
// check the case when fetching as PDO::PARAM_BOOL, PDO::PARAM_NULL or PDO::PARAM_INT
// with or without AE; should not work
// with or without AE: should not work
if ($pdoParamType == "PDO::PARAM_BOOL" || $pdoParamType == "PDO::PARAM_NULL" || $pdoParamType == "PDO::PARAM_INT") {
if (!is_null($det) || !is_null($rand)) {
echo "Retrieving $dataType data as $pdoParamType should not be supported\n";

View file

@ -2,12 +2,13 @@
Test for retrieving encrypted data from datetime types columns with different precisions using PDO::bindColumn
--DESCRIPTION--
Test conversion from datetime types column to output of PDO::PARAM types
With or without AE, conversion works if:
With or without Always Encrypted, conversion works if:
1. From any datetime type column to PDO::PARAM_STR
2. From any datetime type column to PDO::PARAM_LOB
TODO: cannot insert into a datetime2(0) using the PDO_SQLSRV driver
returns operand type clash error between smalldatetime and datetime2(0)
to see error, uncomment 0 from the $precision array
documented in VSO 2693
--SKIPIF--
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
@ -74,7 +75,7 @@ try {
$row = $stmt->fetch(PDO::FETCH_BOUND);
// check the case when fetching as PDO::PARAM_BOOL, PDO::PARAM_NULL or PDO::PARAM_INT
// with or without AE; should not work
// with or without AE: should not work
if ($pdoParamType == "PDO::PARAM_BOOL" || $pdoParamType == "PDO::PARAM_NULL" || $pdoParamType == "PDO::PARAM_INT") {
if (!is_null($det) || !is_null($rand)) {
echo "Retrieving $typeFull data as $pdoParamType should not be supported\n";

View file

@ -2,15 +2,16 @@
Test for retrieving encrypted data from decimal types columns using PDO::bindColumn
--DESCRIPTION--
Test conversion from decimal types column to output of PDO::PARAM types
With or without AE, conversion works if:
With or without ALways Encrypted, conversion works if:
1. From any decimal type column to PDO::PARAM_STR
2. From any decimal type column to PDO::PARAM_LOB
TODO: behavior for teching decimals as PARAM_BOOL and PARAM_INT varies depending on the number being fetched
1. if the number is less than 1, returns 0 (even though the number being fetched is 0.9)
2. 2. if the number is greater than 1 and the number of digits is less than 11, returns the correctly rounded integer (e.g., returns 922 when fetching 922.3)
2. if the number is greater than 1 and the number of digits is less than 11, returns the correctly rounded integer (e.g., returns 922 when fetching 922.3)
3. if the number is greater than 1 and the number of digits is greater than 11, returns NULL
need to investigate which should be the correct behavior
for this test, assume to correct behavior is to return NULL
documented in VSO 2730
--SKIPIF--
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
@ -55,7 +56,7 @@ try {
$typeFull = "$dataType($m1, $m2)";
echo "\nTesting $typeFull:\n";
//create and populate table containing decimal(m1, m2) or numeric(m1, m2) columns
// create and populate table containing decimal(m1, m2) or numeric(m1, m2) columns
$tbname = "test_" . $dataType . $m1 . $m2;
$colMetaArr = array(new ColumnMeta($typeFull, "c_det"), new ColumnMeta($typeFull, "c_rand", null, "randomized"));
createTable($conn, $tbname, $colMetaArr);
@ -73,7 +74,7 @@ try {
$row = $stmt->fetch(PDO::FETCH_BOUND);
// check the case when fetching as PDO::PARAM_BOOL, PDO::PARAM_NULL or PDO::PARAM_INT
// with or without AE; should not work
// with or without AE: should not work
// assume to correct behavior is to return NULL, see description
if ($pdoParamType == "PDO::PARAM_BOOL" || $pdoParamType == "PDO::PARAM_NULL" || $pdoParamType == "PDO::PARAM_INT") {
if (!is_null($det) || !is_null($rand)) {

View file

@ -2,7 +2,7 @@
Test for retrieving encrypted data from float types columns using PDO::bindColumn
--DESCRIPTION--
Test conversion from float types column to output of PDO::PARAM types
With or without AE, conversion works if:
With or without Always Encrypted, conversion works if:
1. From any float type column to PDO::PARAM_STR
2. From any float type column to PDO::PARAM_LOB
--SKIPIF--
@ -51,7 +51,7 @@ try {
$row = $stmt->fetch(PDO::FETCH_BOUND);
// check the case when fetching as PDO::PARAM_BOOL, PDO::PARAM_NULL or PDO::PARAM_INT
// with or without AE; should not work
// with or without AE: should not work
if ($pdoParamType == "PDO::PARAM_BOOL" || $pdoParamType == "PDO::PARAM_NULL" || $pdoParamType == "PDO::PARAM_INT") {
if (!is_null($det) || !is_null($rand)) {
echo "Retriving $typeFull data as $pdoParamType should return NULL\n";

View file

@ -2,7 +2,7 @@
Test for retrieving encrypted data from nchar types columns using PDO::bindColumn
--DESCRIPTION--
Test conversion from nchar types column to output of PDO::PARAM types
With or without AE, conversion works if:
With or without Always Encrypted, conversion works if:
1. From any nchar type column to PDO::PARAM_STR
2. From any nchar type column to PDO::PARAM_LOB
--SKIPIF--

View file

@ -2,7 +2,7 @@
Test for retrieving encrypted data from numeric types columns using PDO::bindColumn
--DESCRIPTION--
Test conversion from numeric types column to output of PDO::PARAM types
With or without AE, conversion works if:
With or without Always Encrypted, conversion works if:
1. From any numeric type except for bigint column to PDO::PARAM_BOOL
2. From any numeric type except for bigint column to PDO::PARAM_INT
3. From any numeric type column to PDO::PARAM_STR

View file

@ -78,7 +78,7 @@ try {
$sql = "SELECT c_det, c_rand FROM $tbname";
$stmt = $conn->query($sql);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if (strlen($row['c_det']) == $m && strlen($row['c_rand']) == $m) {
if (trim($row['c_det']) == $inputValues[0] && trim($row['c_rand']) == $inputValues[1]) {
echo "****Conversion from $pdoParamType to $typeFull is supported****\n";
} else {
echo "Conversion from $pdoParamType to $typeFull causes data corruption\n";

View file

@ -30,7 +30,7 @@ try {
echo "\nTesting $typeFull:\n";
//create table containing char(m) or varchar(m) columns
$tbname = "test_" . str_replace(array('(', ')'), '', $dataType) . $m;
$tbname = getTableName("test_" . str_replace(array('(', ')'), '', $dataType) . $m);
$colMetaArr = array(new ColumnMeta($typeFull, "c1", null, "randomized"));
createTable($conn, $tbname, $colMetaArr);
$input = str_repeat("d", $m);

View file

@ -3,10 +3,10 @@ Test for inserting encrypted data into nchar types columns with different sizes
--DESCRIPTION--
Test conversions between different nchar types of different sizes
With or without Always Encrypted, implicit conversion works if:
1. From input of PDO::PARAM_BOOL to a any nchar column
2. From input of PDO::PARAM_INT to a any nchar column
3. From input of PDO::PARAM_STR to a any nchar column
4. From input of PDO::PARAM_LOB to a any nchar column
1. From input of PDO::PARAM_BOOL to any nchar column
2. From input of PDO::PARAM_INT to any nchar column
3. From input of PDO::PARAM_STR to any nchar column
4. From input of PDO::PARAM_LOB to any nchar column
--SKIPIF--
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--

View file

@ -4,16 +4,16 @@ Test for inserting encrypted data into numeric types columns
Test conversions between different numeric types
With Always Encrypted, implicit conversion works if:
1. From input of PDO::PARAM_BOOL to a real column
2. From input of PDO::PARAM_INT to a any numeric column
3. From input of PDO::PARAM_STR to a any numeric column
4. From input of PDO::PARAM_LOB to a any numeric column
Without Always Encrypted, all of the above works except for input of PDO::PARAM_STR to a bigint column in a x86 platform
PDO::PARAM_STR does not work for bigint in a x86 because in a x86 platform, the maximum value of an int is about 2147483647
2. From input of PDO::PARAM_INT to any numeric column
3. From input of PDO::PARAM_STR to any numeric column
4. From input of PDO::PARAM_LOB to any numeric column
Without Always Encrypted, all of the above work except for input of PDO::PARAM_STR to a bigint column in a x86 platform
PDO::PARAM_STR does not work for bigint in a x86 platform because the maximum value of an int is about 2147483647
Whereas in a x64 platform, the maximum value is about 9E18
In a x86 platform, when in integer is initialized to be > 2147483647, PHP implicitly change it to a float, represented by scientific notation
In a x86 platform, when an integer is > 2147483647, PHP implicitly changees it to a float, represented by scientific notation
When inserting a scientific notation form numeric string, SQL Server returns a converting data type nvarchar to bigint error
Works for with AE because the sqltype used for binding parameter is determined by SQLDescribeParam,
unlike without AE, the sqltype is predicted to be nvarchar when the input is a string and the encoding is utf8
unlike without AE, the sqltype is predicted to be nvarchar or varchar when the input is a string
--SKIPIF--
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
@ -146,6 +146,7 @@ Testing smallint:
****Conversion from PDO::PARAM_LOB to smallint is supported****
Testing int:
Conversion from PDO::PARAM_BOOL to int should be supported
****Conversion from PDO::PARAM_INT to int is supported****
****Conversion from PDO::PARAM_STR to int is supported****
****Conversion from PDO::PARAM_LOB to int is supported****

View file

@ -57,7 +57,7 @@ foreach($dataTypes as $dataType) {
// with AE: should not work
// without AE: should work
if (($n > $m || $maxsqltype) && !$maxcol) {
if (AE\isColEncrypted()) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
echo "AE: Conversion from $sqltypeFull to $typeFull should not be supported\n";
} else {

View file

@ -56,7 +56,7 @@ foreach($dataTypes as $dataType) {
// with AE: should not work
// without AE: should work
if (($n > $m || $maxsqltype) && !$maxcol) {
if (AE\isColEncrypted()) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
echo "AE: Conversion from $sqltypeFull to $typeFull should not be supported\n";
} else {

View file

@ -6,7 +6,7 @@ With Always Encrypted, implicit conversion works if:
1. From input of SQLSRV_SQLTYPE_DATETIME2 to a dateteim2(7) column
2. From input of SQLSRV_SQLTYPE_DATETIMEOFFSET to a datetimeoffset(7) column
3. From input of SQLSRV_SQLTYPE_TIME to a time(7) column
Note: with AE, implicit converion should work as long as the SQLSRV_SQLTYPE has a smaller precision than the one defined in the column. However, the SQLSRV driver does not let the user specify the precision in these SQLSRV_SQLTYPE_* constants and they are all default to a precision of 7. Hence when user specifies SQLSRV_SQLTYPE_DATETIME2, SQLSRV_SQLTYPE_DATETIMEOFFSET or SQLSRV_SQLTYPE_TIME when binding parameter during insertion, only insertion into a column of precision 7 is allowed.
Note: with Always Encrypted, implicit converion should work as long as the SQLSRV_SQLTYPE has a smaller precision than the one defined in the column. However, the SQLSRV driver does not let the user specify the precision in these SQLSRV_SQLTYPE_* constants and they are all default to a precision of 7. Hence when user specifies SQLSRV_SQLTYPE_DATETIME2, SQLSRV_SQLTYPE_DATETIMEOFFSET or SQLSRV_SQLTYPE_TIME when binding parameter during insertion, only insertion into a column of precision 7 is allowed.
Without AlwaysEncrypted, implicit conversion between different precisions works
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
@ -82,9 +82,9 @@ foreach($dataTypes as $dataType) {
// check the case when the column precision (m) is less than 7
// with AE: should not work
// with AE: should work
// without AE: should work
if ($m < 7) {
if (AE\isColEncrypted()) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
echo "AE: Conversion from $sqlType to $typeFull should not be supported\n";
} else {

View file

@ -78,7 +78,7 @@ foreach($dataTypes as $dataType) {
// without AE: should not work if n1 - n2 < m1 - m2 (Numeric value out of range error)
// or n2 != 0 && $m1 == $m2 (Arithmetic overflow error)
if ($n1 != $m1 || $n2 != $m2) {
if (AE\isColEncrypted()) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
echo "AE: Conversion from $sqltypeFull to $typeFull should not be supported\n";
} else {

View file

@ -4,8 +4,8 @@ Test for inserting encrypted data of float types with different number of bits
Test implicit conversions between different number of bits
With Always Encrypted, implicit conversion works if:
1. From input of SQLSRV_SQLTYPE_FLOAT to a float(m) column where m > 24
Note: with AE, implicit conversion should work as long as the SQLSRV_SQLTYPE has a smaller number of bits than the one defined in the column. However, the SQLSRV driver does not let the user specify the number of bits in the SQLSRV_SQLTYPE_FLOAT constant and it is default to 53. Hence when user specifies SQLSRV_SQLTYPE_FLOAT when binding parameter during insertion, only insertion into a column of > 24 is allowed.
Without AlwaysEncrypted, inplicit conversion between different number of bits works.
Note: with Always Encrypted, implicit conversion should work as long as the SQLSRV_SQLTYPE has a smaller number of bits than the one defined in the column. However, the SQLSRV driver does not let the user specify the number of bits in the SQLSRV_SQLTYPE_FLOAT constant and it is default to 53. Hence when user specifies SQLSRV_SQLTYPE_FLOAT when binding parameter during insertion, only insertion into a column of > 24 is allowed.
Without Always Encrypted, implicit conversion between different number of bits works.
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
--FILE--
@ -36,9 +36,9 @@ foreach($bits as $m) {
// check the case when the column number of bits is less than 25
// with AE: should not work
// with AE: should work
// without AE: should work
if ($m < 25) {
if (AE\isColEncrypted()) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
echo "AE: Conversion from $sqlType to $typeFull should not be supported\n";
} else {

View file

@ -18,7 +18,7 @@ With Always Encrypted, implicit conversion works if:
13. From input SQLSRV_SQLTYPE_INT to an int column
14. From input SQLSRV_SQLTYPE_INT to a bigint column
15. From input SQLSRV_SQLTYPE_BIGINT to a bigint column
Without AlwaysEncrypted, inplicit conversion between different integer types works
Without AlwaysEncrypted, implicit conversion between different integer types works
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
--FILE--
@ -54,7 +54,7 @@ foreach ($dataTypes as $dataType) {
// check the case if the type conversion is not listed in $aeConvList
if (!in_array($sqlType, $aeConvList["$dataType"])) {
if (AE\isColEncrypted()) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
echo "AE: Conversion from $sqlType to $dataType should not be supported\n";
} else {

View file

@ -53,10 +53,12 @@ foreach($dataTypes as $dataType) {
$stmt = AE\insertRow($conn, $tbname, array("c1" => $input), $r, AE\INSERT_PREPARE_PARAMS);
// check the case when SQLSRV_SQLTYPE length (n) is greater than the column length (m)
// with AE: should not works
// if SQLSRV_SQLTYPE_NVARCHAR(max) ($maxsqltype), no conversion is supported except if the column is also max ($maxcol)
// if column is max ($maxcol), all conversions are supported
// with AE: should not work
// without AE: should work
if (($n > $m || $maxsqltype) && !$maxcol) {
if (AE\isColEncrypted()) {
if (AE\isDataEncrypted()) {
if ($r !== false) {
echo "AE: Conversion from $sqltypeFull to $typeFull should not be supported\n";
} else {