From 720346f45927493536925f1a3a0e99602f90e07d Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 20 Dec 2017 09:31:44 -0800 Subject: [PATCH] Modified three tests to test with or without UTF-8 data --- test/functional/sqlsrv/TC42_FetchField.phpt | 40 +++++++++++++++---- test/functional/sqlsrv/TC45_FetchObject.phpt | 34 ++++++++++++---- .../sqlsrv/TC48_FetchScrollable.phpt | 39 ++++++++++++++---- 3 files changed, 90 insertions(+), 23 deletions(-) diff --git a/test/functional/sqlsrv/TC42_FetchField.phpt b/test/functional/sqlsrv/TC42_FetchField.phpt index b1395b5a..baddc6b9 100644 --- a/test/functional/sqlsrv/TC42_FetchField.phpt +++ b/test/functional/sqlsrv/TC42_FetchField.phpt @@ -6,20 +6,22 @@ retrieving fields from a table including rows with all supported SQL types (28 t --ENV-- PHPT_EXEC=true --SKIPIF-- - + --FILE-- 'UTF-8')); } else { $conn1 = AE\connect(); @@ -63,16 +65,38 @@ function fetchFields() dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } +// locale must be set before 1st connection +if (!isWindows()) { + setlocale(LC_ALL, "en_US.ISO-8859-1"); +} + +$testName = "Fetch - Field"; + +// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) +startTest($testName); +if (isLocaleSupported()) { + try { + setUTF8Data(false); + fetchFields(); + } catch (Exception $e) { + echo $e->getMessage(); + } +} +endTest($testName); + +// test utf8 +startTest($testName); try { + setUTF8Data(true); fetchFields(); } catch (Exception $e) { echo $e->getMessage(); } +endTest($testName); ?> --EXPECT-- Test "Fetch - Field" completed successfully. +Test "Fetch - Field" completed successfully. diff --git a/test/functional/sqlsrv/TC45_FetchObject.phpt b/test/functional/sqlsrv/TC45_FetchObject.phpt index ec20c417..26767834 100644 --- a/test/functional/sqlsrv/TC45_FetchObject.phpt +++ b/test/functional/sqlsrv/TC45_FetchObject.phpt @@ -5,7 +5,13 @@ Verifies data retrieval via "sqlsrv_fetch_object". --ENV-- PHPT_EXEC=true --SKIPIF-- - + --FILE-- 'UTF-8' )); } else { $conn1 = AE\connect(); @@ -73,8 +75,6 @@ function fetchRow($minFetchMode, $maxFetchMode) dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } @@ -127,12 +127,30 @@ function checkData($rows, $fields, $actualValues, $expectedValues) } } +$testName = "Fetch - Object"; +// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) +startTest($testName); +if (isLocaleSupported()) { + try { + setUTF8Data(false); + fetchRow(0, 2); + } catch (Exception $e) { + echo $e->getMessage(); + } +} +endTest($testName); + +// test utf8 +startTest($testName); try { + setUTF8Data(true); fetchRow(0, 2); } catch (Exception $e) { echo $e->getMessage(); } +endTest($testName); ?> --EXPECT-- Test "Fetch - Object" completed successfully. +Test "Fetch - Object" completed successfully. diff --git a/test/functional/sqlsrv/TC48_FetchScrollable.phpt b/test/functional/sqlsrv/TC48_FetchScrollable.phpt index 44090245..09012e67 100644 --- a/test/functional/sqlsrv/TC48_FetchScrollable.phpt +++ b/test/functional/sqlsrv/TC48_FetchScrollable.phpt @@ -5,19 +5,22 @@ Verifies data retrieval with scrollable result sets. --ENV-- PHPT_EXEC=true --SKIPIF-- - + --FILE-- 'UTF-8')); } else { $conn1 = AE\connect(); @@ -72,8 +75,6 @@ function fetchRow($noRows) dropTable($conn1, $tableName); sqlsrv_close($conn1); - - endTest($testName); } function fetchArray($stmt, $rows, $fields) @@ -135,12 +136,36 @@ 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 - Scrollable"; + +// test ansi only if windows or non-UTF8 locales are supported (ODBC 17 and above) +startTest($testName); +if (isLocaleSupported()) { + try { + setUTF8Data(false); + fetchRow(10); + } catch (Exception $e) { + echo $e->getMessage(); + } +} +endTest($testName); + +// test utf8 +startTest($testName); try { + setUTF8Data(true); fetchRow(10); } catch (Exception $e) { echo $e->getMessage(); } +endTest($testName); ?> --EXPECT-- Test "Fetch - Scrollable" completed successfully. +Test "Fetch - Scrollable" completed successfully.