Modified three tests to test with or without UTF-8 data

This commit is contained in:
Jenny Tam 2017-12-20 09:31:44 -08:00
parent f3d04343aa
commit 720346f459
3 changed files with 90 additions and 23 deletions

View file

@ -6,20 +6,22 @@ retrieving fields from a table including rows with all supported SQL types (28 t
--ENV--
PHPT_EXEC=true
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php
// locale must be set before 1st connection
if ( !isWindows() ) {
setlocale(LC_ALL, "en_US.ISO-8859-1");
}
require('skipif_versions_old.inc');
?>
--FILE--
<?php
require_once('MsCommon.inc');
function fetchFields()
{
$testName = "Fetch - Field";
startTest($testName);
setup();
$tableName = 'TC42test';
if (! isWindows()) {
if (useUTF8Data()) {
$conn1 = AE\connect(array('CharacterSet'=>'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.

View file

@ -5,7 +5,13 @@ Verifies data retrieval via "sqlsrv_fetch_object".
--ENV--
PHPT_EXEC=true
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php
// locale must be set before 1st connection
if (!isWindows()) {
setlocale(LC_ALL, "en_US.ISO-8859-1");
}
require('skipif_versions_old.inc');
?>
--FILE--
<?php
require_once('MsCommon.inc');
@ -19,13 +25,9 @@ class TestClass
function fetchRow($minFetchMode, $maxFetchMode)
{
$testName = "Fetch - Object";
startTest($testName);
setup();
$tableName = 'TC45test';
if (! isWindows()) {
if (useUTF8Data()) {
$conn1 = AE\connect(array( 'CharacterSet'=>'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.

View file

@ -5,19 +5,22 @@ Verifies data retrieval with scrollable result sets.
--ENV--
PHPT_EXEC=true
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php
// locale must be set before 1st connection
if (!isWindows()) {
setlocale(LC_ALL, "en_US.ISO-8859-1");
}
require('skipif_versions_old.inc');
?>
--FILE--
<?php
require_once('MsCommon.inc');
function fetchRow($noRows)
{
$testName = "Fetch - Scrollable";
startTest($testName);
setup();
$tableName = 'TC48test';
if (! isWindows()) {
if (useUTF8Data()) {
$conn1 = AE\connect(array('CharacterSet'=>'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.