modified tests to read cd_info

This commit is contained in:
yitam 2017-05-10 08:35:40 -07:00
parent 707bd41428
commit 8112a8458c
2 changed files with 48 additions and 68 deletions

View file

@ -4,13 +4,13 @@ Test the Authentication keyword with options SqlPassword and ActiveDirectoryInte
--FILE--
<?php
require_once("autonomous_setup.php");
require_once("MsSetup.inc");
$connectionInfo = " Authentication = SqlPassword; TrustServerCertificate = true;";
$connectionInfo = "Database = $databaseName; Authentication = SqlPassword; TrustServerCertificate = true;";
try
{
$conn = new PDO( "sqlsrv:server = $serverName ; $connectionInfo", $username, $password );
$conn = new PDO( "sqlsrv:server = $server ; $connectionInfo", $uid, $pwd );
echo "Connected successfully with Authentication=SqlPassword.\n";
}
catch( PDOException $e )
@ -20,15 +20,15 @@ catch( PDOException $e )
echo "\n";
}
$stmt = $conn->query( "SELECT name FROM master.dbo.sysdatabases" );
$stmt = $conn->query( "SELECT count(*) FROM cd_info" );
if ( $stmt === false )
{
echo "Query failed.\n";
}
else
{
$first_db = $stmt->fetch();
var_dump( $first_db );
$result = $stmt->fetch();
var_dump( $result );
}
$conn = null;
@ -39,7 +39,7 @@ $connectionInfo = "Authentication = ActiveDirectoryIntegrated; TrustServerCertif
try
{
$conn = new PDO( "sqlsrv:server = $serverName ; $connectionInfo" );
$conn = new PDO( "sqlsrv:server = $server ; $connectionInfo" );
echo "Connected successfully with Authentication=ActiveDirectoryIntegrated.\n";
$conn = null;
}
@ -54,10 +54,10 @@ catch( PDOException $e )
--EXPECT--
Connected successfully with Authentication=SqlPassword.
array(2) {
["name"]=>
string(6) "master"
[""]=>
string(1) "7"
[0]=>
string(6) "master"
string(1) "7"
}
Could not connect with Authentication=ActiveDirectoryIntegrated.
SQLSTATE[IMSSP]: Invalid option for the Authentication keyword. Only SqlPassword or ActiveDirectoryPassword is supported.

View file

@ -4,70 +4,47 @@ Test the Authentication keyword with options SqlPassword and ActiveDirectoryInte
--FILE--
<?php
require_once("autonomous_setup.php");
/*
$connectionInfo = array( "UID"=>$username, "PWD"=>$password );
require_once("MsSetup.inc");
$conn = sqlsrv_connect( $serverName, $connectionInfo );
$connectionInfo = array( "Database"=>$databaseName, "UID"=>$uid, "PWD"=>$pwd,
"Authentication"=>'SqlPassword', "TrustServerCertificate"=>true);
$conn = sqlsrv_connect( $server, $connectionInfo );
if( $conn === false )
{
echo "Could not connect.\n";
print_r( sqlsrv_errors() );
echo "Could not connect with Authentication=SqlPassword.\n";
var_dump( sqlsrv_errors() );
}
$connectionInfo = array( "UID"=>$username, "PWD"=>$password,
"TrustServerCertificate"=>true );
$conn = sqlsrv_connect( $serverName, $connectionInfo );
if( $conn === false )
else
{
echo "Could not connect with TrustServerCertificate.\n";
print_r( sqlsrv_errors() );
echo "Connected successfully with Authentication=SqlPassword.\n";
}
*/
//if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN')
$stmt = sqlsrv_query( $conn, "SELECT count(*) FROM cd_info" );
if ( $stmt === false )
{
$connectionInfo = array( "Database"=>"master", "UID"=>$username, "PWD"=>$password,
"Authentication"=>"SqlPassword", "TrustServerCertificate"=>true );
$conn = sqlsrv_connect( $serverName, $connectionInfo );
if( $conn === false )
{
echo "Could not connect with Authentication=SqlPassword.\n";
var_dump( sqlsrv_errors() );
}
// else
// {
// echo "Connected successfully with Authentication=SqlPassword.\n";
// }
$stmt = sqlsrv_query( $conn, "SELECT name FROM master.dbo.sysdatabases" );
if ( $stmt === false )
{
echo "Query failed.\n";
}
// else
// {
// $first_db = sqlsrv_fetch_array( $stmt );
// var_dump( $first_db );
// }
sqlsrv_free_stmt( $stmt );
sqlsrv_close( $conn );
echo "Query failed.\n";
}
else
{
$first_db = sqlsrv_fetch_array( $stmt );
var_dump( $first_db );
}
sqlsrv_free_stmt( $stmt );
sqlsrv_close( $conn );
////////////////////////////////////////
$connectionInfo = array( "Authentication"=>"ActiveDirectoryIntegrated", "TrustServerCertificate"=>true );
$conn = sqlsrv_connect( $serverName, $connectionInfo );
$conn = sqlsrv_connect( $server, $connectionInfo );
if( $conn === false )
{
echo "Could not connect with Authentication=ActiveDirectoryIntegrated.\n";
print_r( sqlsrv_errors() );
$errors = sqlsrv_errors();
print_r($errors[0]);
}
else
{
@ -77,17 +54,20 @@ else
?>
--EXPECT--
Connected successfully with Authentication=SqlPassword.
array(2) {
[0]=>
int(7)
[""]=>
int(7)
}
Could not connect with Authentication=ActiveDirectoryIntegrated.
Array
(
[0] => Array
(
[0] => IMSSP
[SQLSTATE] => IMSSP
[1] => -62
[code] => -62
[2] => Invalid option for the Authentication keyword. Only SqlPassword or ActiveDirectoryPassword is supported.
[message] => Invalid option for the Authentication keyword. Only SqlPassword or ActiveDirectoryPassword is supported.
)
)
[0] => IMSSP
[SQLSTATE] => IMSSP
[1] => -62
[code] => -62
[2] => Invalid option for the Authentication keyword. Only SqlPassword or ActiveDirectoryPassword is supported.
[message] => Invalid option for the Authentication keyword. Only SqlPassword or ActiveDirectoryPassword is supported.
)