Merge pull request #458 from yitam/azureTests

Modified tests for Azure testing
This commit is contained in:
Jenny Tam 2017-06-28 14:46:45 -07:00 committed by GitHub
commit 418dad6fcd
10 changed files with 45 additions and 53 deletions

View file

@ -1,9 +1,9 @@
<?php
require_once("MsSetup.inc");
// Using the tempdb database for two tables specifically constructed
// Using the test database for two tables specifically constructed
// for the connection resiliency tests
$dbName = "tempdb";
$dbName = $databaseName;
$tableName1 = "test_connres1";
$tableName2 = "test_connres2";
@ -67,12 +67,14 @@ function BreakConnection( $conn, $conn_break )
// Remove any databases previously created by GenerateDatabase
function DropTables( $server, $uid, $pwd, $tableName1, $tableName2 )
{
$conn = new PDO( "sqlsrv:server = $server ; ", $uid, $pwd );
global $dbName;
$conn = new PDO( "sqlsrv:server = $server ; Database = $dbName ;", $uid, $pwd );
$query="IF OBJECT_ID('tempdb.dbo.$tableName1', 'U') IS NOT NULL DROP TABLE tempdb.dbo.$tableName1";
$query="IF OBJECT_ID('$tableName1', 'U') IS NOT NULL DROP TABLE $tableName1";
$stmt=$conn->query( $query );
$query="IF OBJECT_ID('tempdb.dbo.$tableName2', 'U') IS NOT NULL DROP TABLE tempdb.dbo.$tableName2";
$query="IF OBJECT_ID('$tableName2', 'U') IS NOT NULL DROP TABLE $tableName2";
$stmt=$conn->query( $query );
}

View file

@ -1,10 +1,10 @@
<?php
include 'MsSetup.inc';
$conn1 = new PDO("sqlsrv:Server=$server", $uid, $pwd);
$conn1 = new PDO("sqlsrv:Server=$server; database=$databaseName", $uid, $pwd);
$connId1 = ConnectionID($conn1);
$conn1 = null;
$conn2 = new PDO("sqlsrv:Server=$server", $uid, $pwd);
$conn2 = new PDO("sqlsrv:Server=$server; database=$databaseName", $uid, $pwd);
$connId2 = ConnectionID($conn2);
$conn2 = null;

View file

@ -3,8 +3,7 @@ Test password with non alphanumeric characters
--DESCRIPTION--
The first three cases should have no problem connecting. Only the last case fails because the
right curly brace should be escaped with another right brace.
In Azure we can't set DEFAULT_DATABASE for a login user. For this test to psss must connect
to the test database defined in MsSetup.inc
In Azure for this test to pass do not specify any particular database when connecting
--SKIPIF--
<?php require('skipif.inc'); ?>
--FILE--
@ -14,7 +13,7 @@ require 'MsSetup.inc';
try{
// Test 1
$conn = new PDO( "sqlsrv:Server=$server;Database=$databaseName;ConnectionPooling=false;" , "test_password", "! ;4triou");
$conn = new PDO( "sqlsrv:Server=$server;ConnectionPooling=false;" , "test_password", "! ;4triou");
if(!$conn)
{
echo "Test 1: Should have connected.";
@ -26,7 +25,7 @@ catch(PDOException $e){
}
try{
// Test 2
$conn = new PDO( "sqlsrv:Server=$server;Database=$databaseName;ConnectionPooling=false;" , "test_password2", "!}} ;4triou");
$conn = new PDO( "sqlsrv:Server=$server;ConnectionPooling=false;" , "test_password2", "!}} ;4triou");
if(!$conn)
{
echo "Test 2: Should have connected.";
@ -38,7 +37,7 @@ catch(PDOException $e){
}
try{
// Test 3
$conn = new PDO( "sqlsrv:Server=$server;Database=$databaseName;ConnectionPooling=false;" , "test_password3", "! ;4triou}}");
$conn = new PDO( "sqlsrv:Server=$server;ConnectionPooling=false;" , "test_password3", "! ;4triou}}");
if(!$conn)
{
echo "Test 3: Should have connected.";
@ -52,7 +51,7 @@ catch(PDOException $e){
try
{
// Test 4
$conn = new PDO( "sqlsrv:Server=$server;Database=$databaseName;ConnectionPooling=false;" , "test_password3", "! ;4triou}");
$conn = new PDO( "sqlsrv:Server=$server;ConnectionPooling=false;" , "test_password3", "! ;4triou}");
}
catch( PDOException $e ) {
print_r( $e->getMessage() );

View file

@ -2,9 +2,7 @@
if (!extension_loaded("pdo") || !extension_loaded('pdo_sqlsrv'))
die("PDO driver cannot be loaded; skipping test.\n");
include 'MsCommon.inc';
if ( IsDaasMode() ) {
die("skip test in Azure");
}
require 'MsSetup.inc';
if ($daasMode) die("skip test not applicable in Azure\n");
?>

View file

@ -159,22 +159,6 @@ function Connect($options = array())
return ($conn);
}
function ConnectSpecial($options = array())
{
require 'MsSetup.inc';
if (!isset($options['UID']) && !isset($options['uid'])) {
$options['UID'] = $uid;
}
if (!isset($options['pwd']) && !isset($options['PWD'])) {
$options['pwd'] = $pwd;
}
if (!isset($options['Database'])) {
$options['Database'] = $database;
}
return sqlsrv_connect($server, $options);
}
function GetTempTableName($table = '', $temporary = true)
{
// A temporary table name with the '#' prefix will be automatically

View file

@ -1,9 +1,9 @@
<?php
require_once("MsSetup.inc");
// Using the tempdb database for two tables specifically constructed
// Using the test database for two tables specifically constructed
// for the connection resiliency tests
$dbName = "tempdb";
$dbName = $databaseName;
$tableName1 = "test_connres1";
$tableName2 = "test_connres2";
@ -72,13 +72,15 @@ function BreakConnection( $conn, $conn_break )
// Remove the tables generated by GenerateTables
function DropTables( $server, $uid, $pwd, $tableName1, $tableName2 )
{
$connectionInfo = array( "UID"=>$uid, "PWD"=>$pwd );
global $dbName;
$connectionInfo = array( "Database"=>$dbName, "UID"=>$uid, "PWD"=>$pwd );
$conn = sqlsrv_connect( $server, $connectionInfo );
$query="IF OBJECT_ID('tempdb.dbo.$tableName1', 'U') IS NOT NULL DROP TABLE tempdb.dbo.$tableName1";
$query="IF OBJECT_ID('$tableName1', 'U') IS NOT NULL DROP TABLE $tableName1";
$stmt=sqlsrv_query( $conn, $query );
$query="IF OBJECT_ID('tempdb.dbo.$tableName2', 'U') IS NOT NULL DROP TABLE tempdb.dbo.$tableName2";
$query="IF OBJECT_ID('$tableName2', 'U') IS NOT NULL DROP TABLE $tableName2";
$stmt=sqlsrv_query( $conn, $query );
}

View file

@ -4,9 +4,7 @@ if (!extension_loaded("sqlsrv")) {
die("skip extension not loaded");
}
include 'MsCommon.inc';
if ( IsDaasMode() ) {
die("skip test in Azure");
}
require 'MsSetup.inc';
if ($daasMode) die("skip test not applicable in Azure\n");
?>

View file

@ -1,7 +1,10 @@
--TEST--
variety of connection parameters.
--SKIPIF--
<?php require('skipif_unix.inc'); ?>
<?php
require('skipif_unix.inc');
require('skipif_azure.inc');
?>
--FILE--
<?php

View file

@ -11,7 +11,7 @@ Test MultipleActiveResultSets connection setting off
require( 'MsCommon.inc' );
$conn = ConnectSpecial(array( 'MultipleActiveResultSets' => false ));
$conn = Connect(array( 'MultipleActiveResultSets' => false ));
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true ));
}

View file

@ -3,8 +3,7 @@ password with non alphanumeric characters
--DESCRIPTION--
The first three cases should have no problem connecting. Only the last case fails because the
right curly brace should be escaped with another right brace.
In Azure we can't set DEFAULT_DATABASE for a login user. For this test to psss must connect
to the test database defined in MsSetup.inc
In Azure for this test to pass do not specify any particular database when connecting
--SKIPIF--
<?php require('skipif.inc'); ?>
--FILE--
@ -12,9 +11,16 @@ to the test database defined in MsSetup.inc
sqlsrv_configure( 'WarningsReturnAsErrors', 0 );
sqlsrv_configure( 'LogSeverity', SQLSRV_LOG_SEVERITY_ALL );
require( 'MsCommon.inc' );
require 'MsSetup.inc';
function toConnect($options = array())
{
global $server;
// this function makes a connection to the server WITHOUT specifying the database
return sqlsrv_connect($server, $options);
}
$conn = ConnectSpecial(array( "UID" => "test_password", "pwd" => "! ;4triou" ));
$conn = toConnect(array( "UID" => "test_password", "pwd" => "! ;4triou" ));
if (!$conn)
{
$errors = sqlsrv_errors();
@ -22,7 +28,7 @@ if (!$conn)
}
sqlsrv_close( $conn );
$conn = ConnectSpecial(array( "UID" => "test_password2", "pwd" => "!}} ;4triou" ));
$conn = toConnect(array( "UID" => "test_password2", "pwd" => "!}} ;4triou" ));
if (!$conn)
{
$errors = sqlsrv_errors();
@ -30,7 +36,7 @@ if (!$conn)
}
sqlsrv_close( $conn );
$conn = ConnectSpecial(array( "UID" => "test_password3", "pwd" => "! ;4triou}}" ));
$conn = toConnect(array( "UID" => "test_password3", "pwd" => "! ;4triou}}" ));
if (!$conn)
{
$errors = sqlsrv_errors();
@ -38,7 +44,7 @@ if (!$conn)
}
sqlsrv_close( $conn );
$conn = ConnectSpecial(array( "UID" => "test_password3", "pwd" => "! ;4triou}" ));
$conn = toConnect(array( "UID" => "test_password3", "pwd" => "! ;4triou}" ));
if ($conn)
{
echo( "Shouldn't have connected" );
@ -51,5 +57,5 @@ print "Test successful";
?>
--EXPECTREGEX--
An unescaped right brace \(}\) was found in either the user name or password. All right braces must be escaped with another right brace \(}}\)\.
Warning: sqlsrv_close\(\) expects parameter 1 to be resource, boolean given in .+(\/|\\)test_non_alpha_password\.php on line 38
Warning: sqlsrv_close\(\) expects parameter 1 to be resource, boolean given in .+(\/|\\)test_non_alpha_password\.php on line 45
Test successful