Fixed tests that failed in php 7.4 (#1006)
This commit is contained in:
parent
d4387a9ec9
commit
c0cf381d6c
|
@ -46,6 +46,14 @@ function CheckInterface($conn)
|
||||||
'__sleep' => true,
|
'__sleep' => true,
|
||||||
'inTransaction' => true,
|
'inTransaction' => true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$phpver = substr(phpversion(), 0, 3);
|
||||||
|
if ($phpver >= '7.4') {
|
||||||
|
// Reference: https://wiki.php.net/rfc/custom_object_serialization
|
||||||
|
unset($expected['__wakeup']);
|
||||||
|
unset($expected['__sleep']);
|
||||||
|
}
|
||||||
|
|
||||||
$classname = get_class($conn);
|
$classname = get_class($conn);
|
||||||
$methods = get_class_methods($classname);
|
$methods = get_class_methods($classname);
|
||||||
foreach ($methods as $k => $method)
|
foreach ($methods as $k => $method)
|
||||||
|
|
|
@ -49,6 +49,14 @@ function checkInterface($stmt)
|
||||||
'__wakeup' => true,
|
'__wakeup' => true,
|
||||||
'__sleep' => true,
|
'__sleep' => true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$phpver = substr(phpversion(), 0, 3);
|
||||||
|
if ($phpver >= '7.4') {
|
||||||
|
// Reference: https://wiki.php.net/rfc/custom_object_serialization
|
||||||
|
unset($expected['__wakeup']);
|
||||||
|
unset($expected['__sleep']);
|
||||||
|
}
|
||||||
|
|
||||||
$classname = get_class($stmt);
|
$classname = get_class($stmt);
|
||||||
$methods = get_class_methods($classname);
|
$methods = get_class_methods($classname);
|
||||||
foreach ($methods as $k => $method) {
|
foreach ($methods as $k => $method) {
|
||||||
|
|
|
@ -15,11 +15,24 @@ require_once("MsCommon_mid-refactor.inc");
|
||||||
function checkStringValues($obj, $columns, $values)
|
function checkStringValues($obj, $columns, $values)
|
||||||
{
|
{
|
||||||
$size = count($values);
|
$size = count($values);
|
||||||
$objArray = (array)$obj; // turn the object into an associated array
|
|
||||||
|
|
||||||
for ($i = 0; $i < $size; $i++) {
|
for ($i = 0; $i < $size; $i++) {
|
||||||
$col = $columns[$i];
|
$col = $columns[$i];
|
||||||
$val = $objArray[$col];
|
switch ($i) {
|
||||||
|
case 0:
|
||||||
|
$val = $obj->c1; break;
|
||||||
|
case 1:
|
||||||
|
$val = $obj->c2; break;
|
||||||
|
case 2:
|
||||||
|
$val = $obj->c3; break;
|
||||||
|
case 3:
|
||||||
|
$val = $obj->c4; break;
|
||||||
|
case 4:
|
||||||
|
$val = $obj->c5; break;
|
||||||
|
case 5:
|
||||||
|
$val = $obj->c6; break;
|
||||||
|
default:
|
||||||
|
echo "Something went wrong!\n";
|
||||||
|
}
|
||||||
|
|
||||||
if ($val != $values[$i]) {
|
if ($val != $values[$i]) {
|
||||||
echo "Expected $values[$i] for column $col but got: ";
|
echo "Expected $values[$i] for column $col but got: ";
|
||||||
|
|
|
@ -200,7 +200,7 @@ function fetchColumns($conn, $tableName, $numRows, $numCols)
|
||||||
$res = $stmtTmp->execute();
|
$res = $stmtTmp->execute();
|
||||||
|
|
||||||
if (! $res) {
|
if (! $res) {
|
||||||
echo "Failed to insert data from column ". $j +1 ."\n";
|
echo "Failed to insert data from column ". ($j + 1) ."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,12 @@ function verifyResult($result)
|
||||||
$expectedLen = ($i % 2 == 0) ? $fullLen : $trimmedLen;
|
$expectedLen = ($i % 2 == 0) ? $fullLen : $trimmedLen;
|
||||||
$len = strlen($result[$i]);
|
$len = strlen($result[$i]);
|
||||||
if ($len != $expectedLen) {
|
if ($len != $expectedLen) {
|
||||||
echo "String length $len for column ". $i + 1 . " is unexpected!\n";
|
echo "String length $len for column ". ($i + 1) . " is unexpected!\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = rtrim($result[$i]);
|
$data = rtrim($result[$i]);
|
||||||
if ($data !== $input) {
|
if ($data !== $input) {
|
||||||
echo "Result for column ". $i + 1 . " is unexpected:";
|
echo "Result for column ". ($i + 1) . " is unexpected:";
|
||||||
var_dump($result[$i]);
|
var_dump($result[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,18 +29,20 @@ foreach ($dataTypes as $dataType) {
|
||||||
is_incompatible_types_error($dataType, "default type");
|
is_incompatible_types_error($dataType, "default type");
|
||||||
} else {
|
} else {
|
||||||
echo "****Encrypted default type is compatible with encrypted $dataType****\n";
|
echo "****Encrypted default type is compatible with encrypted $dataType****\n";
|
||||||
if ($dataType != "time") {
|
$sql = "SELECT * FROM $tbname";
|
||||||
AE\fetchAll($conn, $tbname);
|
$stmt = sqlsrv_query($conn, $sql);
|
||||||
} else {
|
$row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);
|
||||||
$sql = "SELECT * FROM $tbname";
|
foreach ($row as $key => $value) {
|
||||||
$stmt = sqlsrv_query($conn, $sql);
|
if ($dataType == "time") {
|
||||||
$row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);
|
|
||||||
foreach ($row as $key => $value) {
|
|
||||||
//var_dump( $row );
|
|
||||||
$t = $value->format('H:i:s');
|
$t = $value->format('H:i:s');
|
||||||
print "$key: $t\n";
|
print "$key: $t\n";
|
||||||
|
} else {
|
||||||
|
$t = date_format($value, "Y-m-d H:i:s.u");
|
||||||
|
$tz = $value->getTimezone()->getName();
|
||||||
|
print "$key: $t $tz\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
dropTable($conn, $tbname);
|
dropTable($conn, $tbname);
|
||||||
}
|
}
|
||||||
|
@ -51,47 +53,23 @@ sqlsrv_close($conn);
|
||||||
|
|
||||||
Testing date:
|
Testing date:
|
||||||
****Encrypted default type is compatible with encrypted date****
|
****Encrypted default type is compatible with encrypted date****
|
||||||
c_det:
|
c_det: 0001-01-01 00:00:00.000000 Canada/Pacific
|
||||||
date: 0001-01-01 00:00:00.000000
|
c_rand: 9999-12-31 00:00:00.000000 Canada/Pacific
|
||||||
timezone_type: 3
|
|
||||||
timezone: Canada/Pacific
|
|
||||||
c_rand:
|
|
||||||
date: 9999-12-31 00:00:00.000000
|
|
||||||
timezone_type: 3
|
|
||||||
timezone: Canada/Pacific
|
|
||||||
|
|
||||||
Testing datetime:
|
Testing datetime:
|
||||||
****Encrypted default type is compatible with encrypted datetime****
|
****Encrypted default type is compatible with encrypted datetime****
|
||||||
c_det:
|
c_det: 1753-01-01 00:00:00.000000 Canada/Pacific
|
||||||
date: 1753-01-01 00:00:00.000000
|
c_rand: 9999-12-31 23:59:59.997000 Canada/Pacific
|
||||||
timezone_type: 3
|
|
||||||
timezone: Canada/Pacific
|
|
||||||
c_rand:
|
|
||||||
date: 9999-12-31 23:59:59.997000
|
|
||||||
timezone_type: 3
|
|
||||||
timezone: Canada/Pacific
|
|
||||||
|
|
||||||
Testing datetime2:
|
Testing datetime2:
|
||||||
****Encrypted default type is compatible with encrypted datetime2****
|
****Encrypted default type is compatible with encrypted datetime2****
|
||||||
c_det:
|
c_det: 0001-01-01 00:00:00.000000 Canada/Pacific
|
||||||
date: 0001-01-01 00:00:00.000000
|
c_rand: 9999-12-31 23:59:59.123456 Canada/Pacific
|
||||||
timezone_type: 3
|
|
||||||
timezone: Canada/Pacific
|
|
||||||
c_rand:
|
|
||||||
date: 9999-12-31 23:59:59.123456
|
|
||||||
timezone_type: 3
|
|
||||||
timezone: Canada/Pacific
|
|
||||||
|
|
||||||
Testing smalldatetime:
|
Testing smalldatetime:
|
||||||
****Encrypted default type is compatible with encrypted smalldatetime****
|
****Encrypted default type is compatible with encrypted smalldatetime****
|
||||||
c_det:
|
c_det: 1900-01-01 00:00:00.000000 Canada/Pacific
|
||||||
date: 1900-01-01 00:00:00.000000
|
c_rand: 2079-06-05 23:59:00.000000 Canada/Pacific
|
||||||
timezone_type: 3
|
|
||||||
timezone: Canada/Pacific
|
|
||||||
c_rand:
|
|
||||||
date: 2079-06-05 23:59:00.000000
|
|
||||||
timezone_type: 3
|
|
||||||
timezone: Canada/Pacific
|
|
||||||
|
|
||||||
Testing time:
|
Testing time:
|
||||||
****Encrypted default type is compatible with encrypted time****
|
****Encrypted default type is compatible with encrypted time****
|
||||||
|
@ -100,11 +78,5 @@ c_rand: 23:59:59
|
||||||
|
|
||||||
Testing datetimeoffset:
|
Testing datetimeoffset:
|
||||||
****Encrypted default type is compatible with encrypted datetimeoffset****
|
****Encrypted default type is compatible with encrypted datetimeoffset****
|
||||||
c_det:
|
c_det: 0001-01-01 00:00:00.000000 -14:00
|
||||||
date: 0001-01-01 00:00:00.000000
|
c_rand: 9999-12-31 23:59:59.123456 +14:00
|
||||||
timezone_type: 1
|
|
||||||
timezone: -14:00
|
|
||||||
c_rand:
|
|
||||||
date: 9999-12-31 23:59:59.123456
|
|
||||||
timezone_type: 1
|
|
||||||
timezone: +14:00
|
|
||||||
|
|
|
@ -34,10 +34,13 @@ foreach ($decrypted_row as $key => $value) {
|
||||||
if (!is_object($value)) {
|
if (!is_object($value)) {
|
||||||
print "$key: $value\n";
|
print "$key: $value\n";
|
||||||
} else {
|
} else {
|
||||||
print "$key:\n";
|
// print "$key:\n";
|
||||||
foreach ($value as $dateKey => $dateValue) {
|
// foreach ($value as $dateKey => $dateValue) {
|
||||||
print " $dateKey: $dateValue\n";
|
// print " $dateKey: $dateValue\n";
|
||||||
}
|
// }
|
||||||
|
$t = date_format($value, "Y-m-d H:i:s.u");
|
||||||
|
$tz = $value->getTimezone()->getName();
|
||||||
|
print "$key: $t $tz\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sqlsrv_free_stmt($stmt);
|
sqlsrv_free_stmt($stmt);
|
||||||
|
@ -70,10 +73,7 @@ Retrieving plaintext data:
|
||||||
SSN: 795-73-9838
|
SSN: 795-73-9838
|
||||||
FirstName: Catherine
|
FirstName: Catherine
|
||||||
LastName: Abel
|
LastName: Abel
|
||||||
BirthDate:
|
BirthDate: 1996-10-19 00:00:00.000000 Canada/Pacific
|
||||||
date: 1996-10-19 00:00:00.000000
|
|
||||||
timezone_type: 3
|
|
||||||
timezone: Canada/Pacific
|
|
||||||
|
|
||||||
Checking ciphertext data:
|
Checking ciphertext data:
|
||||||
Done
|
Done
|
||||||
|
|
|
@ -38,7 +38,20 @@ if ($r === false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
print "Decrypted values:\n";
|
print "Decrypted values:\n";
|
||||||
AE\fetchAll($conn, $tbname);
|
|
||||||
|
$stmt = selectFromTable($conn, $tbname);
|
||||||
|
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
|
||||||
|
foreach ($row as $key => $value) {
|
||||||
|
if (is_object($value)) {
|
||||||
|
// datetime objects
|
||||||
|
$t = date_format($value,"Y-m-d H:i:s.u");
|
||||||
|
$tz = $value->getTimezone()->getName();
|
||||||
|
print("$key: $t $tz\n");
|
||||||
|
} else {
|
||||||
|
print("$key: $value\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sqlsrv_free_stmt($stmt);
|
sqlsrv_free_stmt($stmt);
|
||||||
|
|
||||||
|
@ -75,12 +88,6 @@ IntData: 2147483647
|
||||||
BigIntData: 92233720368547
|
BigIntData: 92233720368547
|
||||||
DecimalData: 79228162514264
|
DecimalData: 79228162514264
|
||||||
BitData: 1
|
BitData: 1
|
||||||
DateTimeData:
|
DateTimeData: 9999-12-31 23:59:59.997000 Canada/Pacific
|
||||||
date: 9999-12-31 23:59:59.997000
|
DateTime2Data: 9999-12-31 23:59:59.123456 Canada/Pacific
|
||||||
timezone_type: 3
|
|
||||||
timezone: Canada/Pacific
|
|
||||||
DateTime2Data:
|
|
||||||
date: 9999-12-31 23:59:59.123456
|
|
||||||
timezone_type: 3
|
|
||||||
timezone: Canada/Pacific
|
|
||||||
Done
|
Done
|
||||||
|
|
Loading…
Reference in a new issue