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-- --ENV--
PHPT_EXEC=true PHPT_EXEC=true
--SKIPIF-- --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-- --FILE--
<?php <?php
require_once('MsCommon.inc'); require_once('MsCommon.inc');
function fetchFields() function fetchFields()
{ {
$testName = "Fetch - Field";
startTest($testName);
setup(); setup();
$tableName = 'TC42test'; $tableName = 'TC42test';
if (useUTF8Data()) {
if (! isWindows()) {
$conn1 = AE\connect(array('CharacterSet'=>'UTF-8')); $conn1 = AE\connect(array('CharacterSet'=>'UTF-8'));
} else { } else {
$conn1 = AE\connect(); $conn1 = AE\connect();
@ -63,16 +65,38 @@ function fetchFields()
dropTable($conn1, $tableName); dropTable($conn1, $tableName);
sqlsrv_close($conn1); 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 { try {
setUTF8Data(true);
fetchFields(); fetchFields();
} catch (Exception $e) { } catch (Exception $e) {
echo $e->getMessage(); echo $e->getMessage();
} }
endTest($testName);
?> ?>
--EXPECT-- --EXPECT--
Test "Fetch - Field" completed successfully. Test "Fetch - Field" completed successfully.
Test "Fetch - Field" completed successfully.

View file

@ -5,7 +5,13 @@ Verifies data retrieval via "sqlsrv_fetch_object".
--ENV-- --ENV--
PHPT_EXEC=true PHPT_EXEC=true
--SKIPIF-- --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-- --FILE--
<?php <?php
require_once('MsCommon.inc'); require_once('MsCommon.inc');
@ -19,13 +25,9 @@ class TestClass
function fetchRow($minFetchMode, $maxFetchMode) function fetchRow($minFetchMode, $maxFetchMode)
{ {
$testName = "Fetch - Object";
startTest($testName);
setup(); setup();
$tableName = 'TC45test'; $tableName = 'TC45test';
if (useUTF8Data()) {
if (! isWindows()) {
$conn1 = AE\connect(array( 'CharacterSet'=>'UTF-8' )); $conn1 = AE\connect(array( 'CharacterSet'=>'UTF-8' ));
} else { } else {
$conn1 = AE\connect(); $conn1 = AE\connect();
@ -73,8 +75,6 @@ function fetchRow($minFetchMode, $maxFetchMode)
dropTable($conn1, $tableName); dropTable($conn1, $tableName);
sqlsrv_close($conn1); 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 { try {
setUTF8Data(true);
fetchRow(0, 2); fetchRow(0, 2);
} catch (Exception $e) { } catch (Exception $e) {
echo $e->getMessage(); echo $e->getMessage();
} }
endTest($testName);
?> ?>
--EXPECT-- --EXPECT--
Test "Fetch - Object" completed successfully. Test "Fetch - Object" completed successfully.
Test "Fetch - Object" completed successfully.

View file

@ -5,19 +5,22 @@ Verifies data retrieval with scrollable result sets.
--ENV-- --ENV--
PHPT_EXEC=true PHPT_EXEC=true
--SKIPIF-- --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-- --FILE--
<?php <?php
require_once('MsCommon.inc'); require_once('MsCommon.inc');
function fetchRow($noRows) function fetchRow($noRows)
{ {
$testName = "Fetch - Scrollable";
startTest($testName);
setup(); setup();
$tableName = 'TC48test'; $tableName = 'TC48test';
if (! isWindows()) { if (useUTF8Data()) {
$conn1 = AE\connect(array('CharacterSet'=>'UTF-8')); $conn1 = AE\connect(array('CharacterSet'=>'UTF-8'));
} else { } else {
$conn1 = AE\connect(); $conn1 = AE\connect();
@ -72,8 +75,6 @@ function fetchRow($noRows)
dropTable($conn1, $tableName); dropTable($conn1, $tableName);
sqlsrv_close($conn1); sqlsrv_close($conn1);
endTest($testName);
} }
function fetchArray($stmt, $rows, $fields) 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 { try {
setUTF8Data(true);
fetchRow(10); fetchRow(10);
} catch (Exception $e) { } catch (Exception $e) {
echo $e->getMessage(); echo $e->getMessage();
} }
endTest($testName);
?> ?>
--EXPECT-- --EXPECT--
Test "Fetch - Scrollable" completed successfully. Test "Fetch - Scrollable" completed successfully.
Test "Fetch - Scrollable" completed successfully.