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

49 lines
1.9 KiB
Plaintext
Raw Normal View History

--TEST--
Exception is thrown if the unsupported attribute ATTR_PERSISTENT is put into the connection options
--SKIPIF--
<?php require('skipif_mid-refactor.inc'); ?>
--FILE--
<?php
require_once("MsSetup.inc");
2017-10-11 00:56:41 +02:00
require_once("MsCommon_mid-refactor.inc");
2017-10-10 20:34:59 +02:00
// TODO: With and without column encryption in the connection string result in different behaviors
// without Column Encryption, no error is raised if PREFETCH is set before ERRMODE
// with Column Encyrption, error is raised even when PREFETCH is set before ERRMODE
// require investigation for the difference in behaviors
try {
echo "Testing a connection with ATTR_PERSISTENT...\n";
// setting PDO::ATTR_PERSISTENT in PDO constructor returns an exception
Dev (#820) * Fixed the potential error reported by Prefast code analysis * Use SQLSRV_ASSERT for checking NULL ptrs * For these AKV tests check env despite not AE connected * Added the driver option to run functional tests * Fixed connection pooling tests for more than one ODBC drivers * added driver option to pdo isPooled.php * Removed win32 ifdefs re connection resiliency (#802) * Set the driver argument for getDSN to null by default (#798) * Added the driver argument to getDSN * Dropped the driver argument but set to null as default * Removed the AE condition in locale support * Modified the AE condition for locale support * Changed int to SQLLEN to avoid infinite loop (#806) * Version 5.3.0 (#803) * Version 5.3.0 * Fixed the wrong replacements * Added comments block to m4 files * Use dnl for comments * Modified AE fetch phptypes test to insert only one row at a time and loop through php types (#801) * Modified AE fetch phptypes test to insert only one row at a time and loop through php types * Fixed formatting * Streamlined two very similar large column name tests (#807) * Streamlined two very similar large column name tests * Changed the EOL * Updates to change log and readme (#811) * Updates to change log and readme * Dropped support for Ubuntu 17 * Modified as per review comments * Fixed connection resiliency tests for Unix, updated AppVeyor for ODBC 17.2 * Fixed expected output * Fixed output and skipifs * Fixed skipifs and output * Fixed driver name * Updated installation instructions and sample script (#813) * Updated instructions and sample test for 5.3.0 RTW * Fixed sample code to adhere to php coding standard * Fixed cases and spaces * Modified NOTE for UB 18.04 based on review comments * Added 'exit' * Modified change log and readme based on review to PR 811 * Applied review comments * build output to debug appveyor failure * removed debug output * Streamlined two very similar large column name tests (#815) * Streamlined two very similar large column name tests * Added random number of test table names to avoid operand clash issues * Replaced to with for based on review * Changelog updated * changelog updated, test skipif changed to run on unix platforms * Fixed skipif typo * Fixed typo in skipif for pdo * Fixed some output for Travis * Moved error checking inside pdo connres tests * Added links back to changelog * Fixed output for sqlsrv connres tests * Fixed output * Fixed output again
2018-07-21 02:24:48 +02:00
$dsn = getDSN($server, $databaseName, $driver);
2017-10-10 20:34:59 +02:00
$attr = array(PDO::ATTR_PERSISTENT => true);
$conn = new PDO($dsn, $uid, $pwd, $attr);
//free the connection
unset($conn);
2017-10-10 20:34:59 +02:00
} catch (PDOException $e) {
echo "Exception from unsupported attribute (ATTR_PERSISTENT) is caught\n";
}
try {
echo "\nTesting new connection after exception thrown in previous connection...\n";
$tableName1 = getTableName('tab1');
$conn = connect();
createTable($conn, $tableName1, array("c1" => "int", "c2" => "varchar(10)"));
insertRow($conn, $tableName1, array("c1" => 1, "c2" => "column2"), "exec");
2017-10-10 20:34:59 +02:00
$result = selectRow($conn, $tableName1, "PDO::FETCH_ASSOC");
if ($result['c1'] == 1 && $result['c2'] == 'column2') {
2017-10-11 00:56:41 +02:00
echo "Test successfully completed\n";
}
2017-10-10 20:34:59 +02:00
//free the statement and connection
dropTable($conn, $tableName);
unset($stmt);
unset($conn);
2017-10-10 20:34:59 +02:00
} catch (PDOException $e) {
var_dump($e);
}
2017-10-10 20:34:59 +02:00
?>
--EXPECT--
Testing a connection with ATTR_PERSISTENT...
Exception from unsupported attribute (ATTR_PERSISTENT) is caught
Testing new connection after exception thrown in previous connection...
2017-05-02 21:00:53 +02:00
Test successfully completed