php-sqlsrv/test/functional/pdo_sqlsrv/pdo_ae_insert_datetime.phpt

74 lines
2.2 KiB
Plaintext
Raw Normal View History

--TEST--
2017-09-15 00:04:55 +02:00
Test for inserting and retrieving encrypted data of datetime types
--DESCRIPTION--
2017-09-14 18:47:40 +02:00
No PDO::PARAM_ type specified when binding parameters
--SKIPIF--
2017-11-07 02:30:11 +01:00
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
2017-11-07 02:30:11 +01:00
require_once("MsCommon_mid-refactor.inc");
require_once("AEData.inc");
$dataTypes = array( "date", "datetime", "datetime2", "smalldatetime", "time", "datetimeoffset" );
2017-11-07 02:30:11 +01:00
try {
$conn = connect();
2017-11-07 02:30:11 +01:00
foreach ($dataTypes as $dataType) {
echo "\nTesting $dataType:\n";
2017-11-07 02:30:11 +01:00
// create table
2017-11-07 02:30:11 +01:00
$tbname = getTableName();
$colMetaArr = array( new ColumnMeta($dataType, "c_det"), new ColumnMeta($dataType, "c_rand", null, "randomized"));
createTable($conn, $tbname, $colMetaArr);
// insert a row
2017-11-07 02:30:11 +01:00
$inputValues = array_slice(${explode("(", $dataType)[0] . "_params"}, 1, 2);
$r;
2017-11-07 02:30:11 +01:00
$stmt = insertRow($conn, $tbname, array("c_det" => $inputValues[0], "c_rand" => $inputValues[1] ), null, $r);
if ($r === false) {
isIncompatibleTypesError($stmt, $dataType, "default type");
} else {
echo "****Encrypted default type is compatible with encrypted $dataType****\n";
2017-11-07 02:30:11 +01:00
fetchAll($conn, $tbname);
}
2017-11-07 02:30:11 +01:00
dropTable($conn, $tbname);
}
2017-11-07 02:30:11 +01:00
unset($stmt);
unset($conn);
} catch (PDOException $e) {
echo $e->getMessage();
}
?>
--EXPECT--
Testing date:
****Encrypted default type is compatible with encrypted date****
c_det: 0001-01-01
c_rand: 9999-12-31
Testing datetime:
****Encrypted default type is compatible with encrypted datetime****
c_det: 1753-01-01 00:00:00.000
c_rand: 9999-12-31 23:59:59.997
Testing datetime2:
****Encrypted default type is compatible with encrypted datetime2****
c_det: 0001-01-01 00:00:00.0000000
c_rand: 9999-12-31 23:59:59.9999999
Testing smalldatetime:
****Encrypted default type is compatible with encrypted smalldatetime****
c_det: 1900-01-01 00:00:00
c_rand: 2079-06-05 23:59:00
Testing time:
****Encrypted default type is compatible with encrypted time****
c_det: 00:00:00.0000000
c_rand: 23:59:59.9999999
Testing datetimeoffset:
****Encrypted default type is compatible with encrypted datetimeoffset****
c_det: 0001-01-01 00:00:00.0000000 -14:00
c_rand: 9999-12-31 23:59:59.9999999 +14:00