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

61 lines
2.3 KiB
Plaintext
Raw Normal View History

--TEST--
2017-09-15 00:04:55 +02:00
Test for inserting and retrieving encrypted data of string 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("char(5)", "varchar(max)", "nchar(5)", "nvarchar(max)");
try {
$conn = connect();
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();
2017-11-08 02:12:43 +01:00
$colMetaArr = array(new ColumnMeta($dataType, "c_det"), new ColumnMeta($dataType, "c_rand", null, "randomized"));
2017-11-07 02:30:11 +01:00
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 char(5):
****Encrypted default type is compatible with encrypted char(5)****
c_det: -leng
c_rand: th, n
Testing varchar(max):
****Encrypted default type is compatible with encrypted varchar(max)****
c_det: Use varchar(max) when the sizes of the column data entries vary considerably, and the size might exceed 8,000 bytes.
c_rand: Each non-null varchar(max) or nvarchar(max) column requires 24 bytes of additional fixed allocation which counts against the 8,060 byte row limit during a sort operation.
Testing nchar(5):
****Encrypted default type is compatible with encrypted nchar(5)****
c_det: -leng
c_rand: th Un
Testing nvarchar(max):
****Encrypted default type is compatible with encrypted nvarchar(max)****
c_det: When prefixing a string constant with the letter N, the implicit conversion will result in a Unicode string if the constant to convert does not exceed the max length for a Unicode string data type (4,000).
c_rand: Otherwise, the implicit conversion will result in a Unicode large-value (max).