Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamlined two very similar large column name tests #815

Merged
merged 4 commits into from
Jul 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Updated PECL release packages. Here is the list of updates:
- Added support for Azure Key Vault for Always Encrypted for basic CRUD functionalities such that Always Encrypted feature is available to all supported Windows, Linux or macOS platforms
- Added support for macOS High Sierra (requires [MS ODBC Driver 17+](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017))
- Added support for Ubuntu 18.04 LTS (requires MS ODBC Driver 17.2)
- Added support for Linux and macOS to Connection Resiliency (requires MS ODBC Driver 17.2)
- Added support for Linux and macOS for Connection Resiliency (requires MS ODBC Driver 17.2)

### Fixed
- Issue [#577](https://github.com/Microsoft/msphpsql/issues/577) - Idle Connection Resiliency doesn't work with Column Encryption enabled connection (fixed in MS ODBC Driver 17.1)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/sqlsrv/TC52_StreamSend.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function sendStream($minType, $maxType, $atExec)
startTest($testName);

setup();
$tableName = "TC52test";
$tableName = "TC52test" . rand(0, 100);
$fileName = "TC52test.dat";
$conn1 = AE\connect();

Expand Down
2 changes: 1 addition & 1 deletion test/functional/sqlsrv/TC54_StreamPrepared.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function sendStream($minType, $maxType)
startTest($testName);

setup();
$tableName = "TC54test";
$tableName = "TC54test" . rand(0, 100);
$fileName = "TC53test.dat";
$conn1 = AE\connect();

Expand Down
49 changes: 27 additions & 22 deletions test/functional/sqlsrv/TC84_LargeColumnName.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PHPT_EXEC=true
<?php
require_once('MsCommon.inc');

function LargeColumnNameTest($columnName, $expectfail)
function largeColumnNameTest($columnName, $expectFail = false)
{
setup();

Expand All @@ -20,26 +20,32 @@ function LargeColumnNameTest($columnName, $expectfail)

dropTable($conn, $tableName);

sqlsrv_query($conn, "CREATE TABLE [$tableName] ([$columnName] int)");

sqlsrv_query($conn, "INSERT INTO [$tableName] ([$columnName]) VALUES (5)");
$stmt = sqlsrv_query($conn, "CREATE TABLE [$tableName] ([$columnName] int)");
if ($stmt == null) {
if (!$expectFail) {
fatalError("Possible regression: Unable to create test $tableName.");
} else {
$expected = 'is too long. Maximum length is 128.';
if (strpos(sqlsrv_errors()[0]['message'], $expected) === false) {
print_r(sqlsrv_errors());
}
echo "$";
echo "stmt = null";
echo "\n";
}
} else {
sqlsrv_query($conn, "INSERT INTO [$tableName] ([$columnName]) VALUES (5)");

$stmt = sqlsrv_query($conn, "SELECT * from [$tableName]");
$stmt = sqlsrv_query($conn, "SELECT * from [$tableName]");

if (null == $stmt) {
echo "$";
echo "stmt = null";
echo "\n";
} else {
if (null == sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
if (!$expectfail) {
if (!$expectFail) {
fatalError("Possible regression: Unable to retrieve inserted value.");
}
}
sqlsrv_free_stmt($stmt);
}


dropTable($conn, $tableName);

sqlsrv_close($conn);
Expand All @@ -56,17 +62,16 @@ function repro()

startTest($testName);

$columnName = "a";

try {
for ($a = 1; $a <= 129; $a++) {
LargeColumnNameTest($columnName, $a > 128);
$columnName .= "A";
}
} catch (Exception $e) {
echo $e->getMessage();
}
// The maximum size of a column name is 128 characters
$maxlen = 128;
$columnName = str_repeat('a', $maxlen);

largeColumnNameTest($columnName);

// Now add another character to the name
$columnName .= "A";

largeColumnNameTest($columnName, true);

endTest($testName);
}
Expand Down
51 changes: 30 additions & 21 deletions test/functional/sqlsrv/TC84_LargeColumnName_unicode.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,44 @@ PHPT_EXEC=true
<?php
require_once('MsCommon.inc');

function LargeColumnNameTest($columnName, $expectfail)
function largeColumnNameTest($columnName, $expectFail = false)
{
setup();

$conn = connect(array( 'CharacterSet'=>'UTF-8' ));
$conn = connect(array('CharacterSet'=>'UTF-8'));

$tableName = "LargeColumnNameTest";

dropTable($conn, $tableName);

sqlsrv_query($conn, "CREATE TABLE [$tableName] ([$columnName] int)");

sqlsrv_query($conn, "INSERT INTO [$tableName] ([$columnName]) VALUES (5)");
$stmt = sqlsrv_query($conn, "CREATE TABLE [$tableName] ([$columnName] int)");
if ($stmt == null) {
if (!$expectFail) {
fatalError("Possible regression: Unable to create test $tableName.");
} else {
$expected = 'is too long. Maximum length is 128.';
if (strpos(sqlsrv_errors()[0]['message'], $expected) === false) {
print_r(sqlsrv_errors());
}
echo "$";
echo "stmt = null";
echo "\n";
}
} else {
sqlsrv_query($conn, "INSERT INTO [$tableName] ([$columnName]) VALUES (5)");

$stmt = sqlsrv_query($conn, "SELECT * from [$tableName]");
$stmt = sqlsrv_query($conn, "SELECT * from [$tableName]");

if (null == $stmt) {
echo "$";
echo "stmt = null";
echo "\n";
} else {
if (null == sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
if (!$expectfail) {
if (!$expectFail) {
fatalError("Possible regression: Unable to retrieve inserted value.");
}
}
sqlsrv_free_stmt($stmt);
}

dropTable($conn, $tableName);

sqlsrv_close($conn);
}

Expand All @@ -53,16 +62,16 @@ function repro()

startTest($testName);

$columnName = "银";
// The maximum size of a column name is 128 characters
$maxlen = 128;
$columnName = str_repeat('银', $maxlen);

try {
for ($a = 1; $a <= 129; $a++) {
LargeColumnNameTest($columnName, $a > 128);
$columnName .= "银";
}
} catch (Exception $e) {
echo $e->getMessage();
}
largeColumnNameTest($columnName);

// Now add another character to the name
$columnName .= "银";

largeColumnNameTest($columnName, true);

endTest($testName);
}
Expand Down
75 changes: 0 additions & 75 deletions test/functional/sqlsrv/TC84_LargeColumnName_unicode_col_name.phpt

This file was deleted.