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,
|
||||
'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);
|
||||
$methods = get_class_methods($classname);
|
||||
foreach ($methods as $k => $method)
|
||||
|
|
|
@ -49,6 +49,14 @@ function checkInterface($stmt)
|
|||
'__wakeup' => 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);
|
||||
$methods = get_class_methods($classname);
|
||||
foreach ($methods as $k => $method) {
|
||||
|
|
|
@ -15,11 +15,24 @@ require_once("MsCommon_mid-refactor.inc");
|
|||
function checkStringValues($obj, $columns, $values)
|
||||
{
|
||||
$size = count($values);
|
||||
$objArray = (array)$obj; // turn the object into an associated array
|
||||
|
||||
for ($i = 0; $i < $size; $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]) {
|
||||
echo "Expected $values[$i] for column $col but got: ";
|
||||
|
|
|
@ -200,7 +200,7 @@ function fetchColumns($conn, $tableName, $numRows, $numCols)
|
|||
$res = $stmtTmp->execute();
|
||||
|
||||
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;
|
||||
$len = strlen($result[$i]);
|
||||
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]);
|
||||
if ($data !== $input) {
|
||||
echo "Result for column ". $i + 1 . " is unexpected:";
|
||||
echo "Result for column ". ($i + 1) . " is unexpected:";
|
||||
var_dump($result[$i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,18 +29,20 @@ foreach ($dataTypes as $dataType) {
|
|||
is_incompatible_types_error($dataType, "default type");
|
||||
} else {
|
||||
echo "****Encrypted default type is compatible with encrypted $dataType****\n";
|
||||
if ($dataType != "time") {
|
||||
AE\fetchAll($conn, $tbname);
|
||||
} else {
|
||||
$sql = "SELECT * FROM $tbname";
|
||||
$stmt = sqlsrv_query($conn, $sql);
|
||||
$row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);
|
||||
foreach ($row as $key => $value) {
|
||||
//var_dump( $row );
|
||||
$sql = "SELECT * FROM $tbname";
|
||||
$stmt = sqlsrv_query($conn, $sql);
|
||||
$row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);
|
||||
foreach ($row as $key => $value) {
|
||||
if ($dataType == "time") {
|
||||
$t = $value->format('H:i:s');
|
||||
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);
|
||||
}
|
||||
|
@ -51,47 +53,23 @@ sqlsrv_close($conn);
|
|||
|
||||
Testing date:
|
||||
****Encrypted default type is compatible with encrypted date****
|
||||
c_det:
|
||||
date: 0001-01-01 00:00:00.000000
|
||||
timezone_type: 3
|
||||
timezone: Canada/Pacific
|
||||
c_rand:
|
||||
date: 9999-12-31 00:00:00.000000
|
||||
timezone_type: 3
|
||||
timezone: Canada/Pacific
|
||||
c_det: 0001-01-01 00:00:00.000000 Canada/Pacific
|
||||
c_rand: 9999-12-31 00:00:00.000000 Canada/Pacific
|
||||
|
||||
Testing datetime:
|
||||
****Encrypted default type is compatible with encrypted datetime****
|
||||
c_det:
|
||||
date: 1753-01-01 00:00:00.000000
|
||||
timezone_type: 3
|
||||
timezone: Canada/Pacific
|
||||
c_rand:
|
||||
date: 9999-12-31 23:59:59.997000
|
||||
timezone_type: 3
|
||||
timezone: Canada/Pacific
|
||||
c_det: 1753-01-01 00:00:00.000000 Canada/Pacific
|
||||
c_rand: 9999-12-31 23:59:59.997000 Canada/Pacific
|
||||
|
||||
Testing datetime2:
|
||||
****Encrypted default type is compatible with encrypted datetime2****
|
||||
c_det:
|
||||
date: 0001-01-01 00:00:00.000000
|
||||
timezone_type: 3
|
||||
timezone: Canada/Pacific
|
||||
c_rand:
|
||||
date: 9999-12-31 23:59:59.123456
|
||||
timezone_type: 3
|
||||
timezone: Canada/Pacific
|
||||
c_det: 0001-01-01 00:00:00.000000 Canada/Pacific
|
||||
c_rand: 9999-12-31 23:59:59.123456 Canada/Pacific
|
||||
|
||||
Testing smalldatetime:
|
||||
****Encrypted default type is compatible with encrypted smalldatetime****
|
||||
c_det:
|
||||
date: 1900-01-01 00:00:00.000000
|
||||
timezone_type: 3
|
||||
timezone: Canada/Pacific
|
||||
c_rand:
|
||||
date: 2079-06-05 23:59:00.000000
|
||||
timezone_type: 3
|
||||
timezone: Canada/Pacific
|
||||
c_det: 1900-01-01 00:00:00.000000 Canada/Pacific
|
||||
c_rand: 2079-06-05 23:59:00.000000 Canada/Pacific
|
||||
|
||||
Testing time:
|
||||
****Encrypted default type is compatible with encrypted time****
|
||||
|
@ -100,11 +78,5 @@ c_rand: 23:59:59
|
|||
|
||||
Testing datetimeoffset:
|
||||
****Encrypted default type is compatible with encrypted datetimeoffset****
|
||||
c_det:
|
||||
date: 0001-01-01 00:00:00.000000
|
||||
timezone_type: 1
|
||||
timezone: -14:00
|
||||
c_rand:
|
||||
date: 9999-12-31 23:59:59.123456
|
||||
timezone_type: 1
|
||||
timezone: +14:00
|
||||
c_det: 0001-01-01 00:00:00.000000 -14:00
|
||||
c_rand: 9999-12-31 23:59:59.123456 +14:00
|
||||
|
|
|
@ -34,10 +34,13 @@ foreach ($decrypted_row as $key => $value) {
|
|||
if (!is_object($value)) {
|
||||
print "$key: $value\n";
|
||||
} else {
|
||||
print "$key:\n";
|
||||
foreach ($value as $dateKey => $dateValue) {
|
||||
print " $dateKey: $dateValue\n";
|
||||
}
|
||||
// print "$key:\n";
|
||||
// foreach ($value as $dateKey => $dateValue) {
|
||||
// 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);
|
||||
|
@ -70,10 +73,7 @@ Retrieving plaintext data:
|
|||
SSN: 795-73-9838
|
||||
FirstName: Catherine
|
||||
LastName: Abel
|
||||
BirthDate:
|
||||
date: 1996-10-19 00:00:00.000000
|
||||
timezone_type: 3
|
||||
timezone: Canada/Pacific
|
||||
BirthDate: 1996-10-19 00:00:00.000000 Canada/Pacific
|
||||
|
||||
Checking ciphertext data:
|
||||
Done
|
||||
|
|
|
@ -38,7 +38,20 @@ if ($r === false) {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -75,12 +88,6 @@ IntData: 2147483647
|
|||
BigIntData: 92233720368547
|
||||
DecimalData: 79228162514264
|
||||
BitData: 1
|
||||
DateTimeData:
|
||||
date: 9999-12-31 23:59:59.997000
|
||||
timezone_type: 3
|
||||
timezone: Canada/Pacific
|
||||
DateTime2Data:
|
||||
date: 9999-12-31 23:59:59.123456
|
||||
timezone_type: 3
|
||||
timezone: Canada/Pacific
|
||||
DateTimeData: 9999-12-31 23:59:59.997000 Canada/Pacific
|
||||
DateTime2Data: 9999-12-31 23:59:59.123456 Canada/Pacific
|
||||
Done
|
||||
|
|
Loading…
Reference in a new issue