added test for setting invalid encoding attributes
This commit is contained in:
parent
a2f16cb575
commit
fe0f48151b
40
test/pdo_sqlsrv/pdo_set_attr_invalid_encoding.phpt
Normal file
40
test/pdo_sqlsrv/pdo_set_attr_invalid_encoding.phpt
Normal file
|
@ -0,0 +1,40 @@
|
|||
--TEST--
|
||||
Test setting invalid encoding attributes
|
||||
--SKIPIF--
|
||||
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("autonomous_setup.php");
|
||||
|
||||
try{
|
||||
$database = "tempdb";
|
||||
$dsn = "sqlsrv:Server = $serverName; Database = $database";
|
||||
|
||||
$conn = new PDO( $dsn, $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
|
||||
|
||||
// valid option: should have no error
|
||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_DEFAULT );
|
||||
print_r (($conn->errorInfo())[2]);
|
||||
echo "\n";
|
||||
|
||||
// PDO::SQLSRV_ENCODING_UTF8 should not be quoted
|
||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_ENCODING, "PDO::SQLSRV_ENCODING_UTF8" );
|
||||
print_r (($conn->errorInfo())[2]);
|
||||
echo "\n";
|
||||
|
||||
// PDO::SQLSRV_ENCODING_BINARY is not supported
|
||||
@$conn->setAttribute( PDO::SQLSRV_ATTR_ENCODING, PDO::SQLSRV_ENCODING_BINARY );
|
||||
print_r (($conn->errorInfo())[2]);
|
||||
echo "\n";
|
||||
}
|
||||
catch ( PDOException $e ){
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
--EXPECT--
|
||||
|
||||
An invalid encoding was specified for SQLSRV_ATTR_ENCODING.
|
||||
An invalid encoding was specified for SQLSRV_ATTR_ENCODING.
|
Loading…
Reference in a new issue