From 6b209526cd80453defa6c7363ae8929268600727 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 20 Dec 2017 10:18:46 -0800 Subject: [PATCH] Added skipif and modified the check of isLocaleSupported() --- test/functional/sqlsrv/MsCommon.inc | 2 + test/functional/sqlsrv/TC34_PrepAndExec.phpt | 43 +++++++++++++++---- test/functional/sqlsrv/TC42_FetchField.phpt | 4 +- test/functional/sqlsrv/TC43_FetchData.phpt | 5 ++- test/functional/sqlsrv/TC44_FetchArray.phpt | 5 ++- test/functional/sqlsrv/TC45_FetchObject.phpt | 14 ++++-- .../sqlsrv/TC46_FetchNextResult.phpt | 5 ++- test/functional/sqlsrv/TC51_StreamRead.phpt | 5 ++- .../sqlsrv/TC55_StreamScrollable.phpt | 5 ++- .../sqlsrv/test_stream_large_data.phpt | 6 +-- 10 files changed, 66 insertions(+), 28 deletions(-) diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index e01802e1..14fe90ee 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -98,6 +98,8 @@ function startTest($testName) */ function endTest($testName) { + // reset the utf-8 flag + setUTF8Data(false); echo "Test \"$testName\" completed successfully.\n"; } diff --git a/test/functional/sqlsrv/TC34_PrepAndExec.phpt b/test/functional/sqlsrv/TC34_PrepAndExec.phpt index d8e5d210..d77fef2c 100644 --- a/test/functional/sqlsrv/TC34_PrepAndExec.phpt +++ b/test/functional/sqlsrv/TC34_PrepAndExec.phpt @@ -6,18 +6,25 @@ Validates that a prepared statement can be successfully executed more than once. --ENV-- PHPT_EXEC=true --SKIPIF-- - + --FILE-- 'UTF-8')); + } else { + $conn1 = AE\connect(); + } $tableName = 'TC34test'; AE\createTestTable($conn1, $tableName); @@ -80,20 +87,38 @@ function prepareAndExecute($noPasses) dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } +// locale must be set before 1st connection if (!isWindows()) { - setUTF8Data(true); + setlocale(LC_ALL, "en_US.ISO-8859-1"); } + +$testName = "Statement - Prepare and Execute"; + +// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) +startTest($testName); +if (isLocaleSupported()) { + try { + setUTF8Data(false); + prepareAndExecute(5); + } catch (Exception $e) { + echo $e->getMessage(); + } +} +endTest($testName); + +// test utf8 +startTest($testName); try { + setUTF8Data(true); prepareAndExecute(5); } catch (Exception $e) { echo $e->getMessage(); } -setUTF8Data(false); +endTest($testName); ?> --EXPECT-- Test "Statement - Prepare and Execute" completed successfully. +Test "Statement - Prepare and Execute" completed successfully. diff --git a/test/functional/sqlsrv/TC42_FetchField.phpt b/test/functional/sqlsrv/TC42_FetchField.phpt index baddc6b9..dc715b19 100644 --- a/test/functional/sqlsrv/TC42_FetchField.phpt +++ b/test/functional/sqlsrv/TC42_FetchField.phpt @@ -8,10 +8,10 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- --FILE-- --FILE-- --FILE-- 'UTF-8' )); + $conn1 = AE\connect(array('CharacterSet'=>'UTF-8')); } else { $conn1 = AE\connect(); } @@ -89,7 +89,7 @@ function fetchObject($stmt, $rows, $fields, $useClass) $obj = sqlsrv_fetch_object($stmt); } if ($obj === false) { - fatalError("Row $i is missing"); + fatalError("In fetchObject: Row $i is missing"); } $values[$i] = $obj; } @@ -103,7 +103,7 @@ function fetchArray($stmt, $rows, $fields) for ($i = 0; $i < $rows; $i++) { $row = sqlsrv_fetch_array($stmt); if ($row === false) { - fatalError("Row $i is missing"); + fatalError("In fetchArray: Row $i is missing"); } $values[$i] = $row; } @@ -127,7 +127,13 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } } +// locale must be set before 1st connection +if (!isWindows()) { + setlocale(LC_ALL, "en_US.ISO-8859-1"); +} + $testName = "Fetch - Object"; + // test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) startTest($testName); if (isLocaleSupported()) { diff --git a/test/functional/sqlsrv/TC46_FetchNextResult.phpt b/test/functional/sqlsrv/TC46_FetchNextResult.phpt index 6848d2e6..bcd5e9e8 100644 --- a/test/functional/sqlsrv/TC46_FetchNextResult.phpt +++ b/test/functional/sqlsrv/TC46_FetchNextResult.phpt @@ -7,9 +7,10 @@ PHPT_EXEC=true --SKIPIF-- --FILE-- --FILE-- --FILE-- --FILE--