Skip to content

Commit 788dbef

Browse files
committed
gh9498.phpt: fix test so that it works on windows too
Work around the fact that Windows does not use UTF-8 by doing the comparison within the PHP test code. Also, add a few more tests of plain ASCII strings to make sure those aren't impacted by this change. Fixes: e053712
1 parent e053712 commit 788dbef

File tree

1 file changed

+70
-29
lines changed

1 file changed

+70
-29
lines changed

ext/pdo_odbc/tests/gh9498_1.phpt

Lines changed: 70 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,75 @@ require 'ext/pdo/tests/pdo_test.inc';
1313
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
1414
$db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
1515

16-
$select_test = "SELECT
17-
CAST(0x72006f017e016f007600fd00 AS nvarchar(6)) AS pink_in_czech_binary_encoded_utf16le
18-
, CAST(0x6b26 AS nvarchar(1)) AS beamed_eighth_notes_binary_encoded_utf16le
19-
, NCHAR(0x266b) AS beamed_eighth_notes_nchar
20-
, N'♫' AS \"beamed_eighth_notes_u+266b_constant\"
21-
, N'růžový' AS pink_in_czech_unicode_string_constant
22-
, NCHAR(0xfb01) AS ligature_fi_nchar
23-
, N'𝄋' AS \"segno_u+1d10b_constant\"
24-
;";
25-
var_dump($db->query($select_test, \PDO::FETCH_ASSOC)->fetchAll());
16+
$tests = [
17+
[
18+
"name" => "beamed_eighth_notes_binary_encoded_utf16le",
19+
"expr" => "CAST(0x6b26 AS nvarchar(1))",
20+
"expected_answer" => "",
21+
],
22+
[
23+
"name" => "beamed_eighth_notes_nchar",
24+
"expr" => "NCHAR(0x266b)",
25+
"expected_answer" => "",
26+
],
27+
[
28+
"name" => "beamed_eighth_notes_u+266b_constant",
29+
"expr" => "N'♫'",
30+
"expected_answer" => "",
31+
],
32+
[
33+
"name" => "ligature_fi_nchar",
34+
"expr" => "NCHAR(0xfb01)",
35+
"expected_answer" => "",
36+
],
37+
[
38+
"name" => "php_ascii_string_constant",
39+
"expr" => "'php'",
40+
"expected_answer" => "php",
41+
],
42+
[
43+
"name" => "php_unicode_string_constant",
44+
"expr" => "N'php'",
45+
"expected_answer" => "php",
46+
],
47+
[
48+
"name" => "pink_in_czech_binary_encoded_utf16le",
49+
"expr" => "CAST(0x72006f017e016f007600fd00 AS nvarchar(6))",
50+
"expected_answer" => "růžový",
51+
],
52+
[
53+
"name" => "pink_in_czech_unicode_string_constant",
54+
"expr" => "N'růžový'",
55+
"expected_answer" => "růžový",
56+
],
57+
[
58+
"name" => "segno_u+1d10b_constant",
59+
"expr" => "N'𝄋'",
60+
"expected_answer" => "𝄋",
61+
],
62+
];
63+
64+
foreach ($tests as $t) {
65+
print $t["name"] . ": ";
66+
$sql = "SELECT " . $t["expr"] . ' AS "' . $t["name"] . '";';
67+
$results = $db->query($sql, \PDO::FETCH_NUM)->fetch();
68+
if ( $results[0] == $t["expected_answer"] ) {
69+
print "PASS";
70+
} else {
71+
print "FAIL!";
72+
print "\tresult: '" . $results[0] . "'";
73+
print "\texpected: '" . $t["expected_answer"] . "'";
74+
}
75+
print "\n";
76+
}
2677
?>
2778
--EXPECT--
28-
array(1) {
29-
[0]=>
30-
array(7) {
31-
["pink_in_czech_binary_encoded_utf16le"]=>
32-
string(9) "růžový"
33-
["beamed_eighth_notes_binary_encoded_utf16le"]=>
34-
string(3) "♫"
35-
["beamed_eighth_notes_nchar"]=>
36-
string(3) "♫"
37-
["beamed_eighth_notes_u+266b_constant"]=>
38-
string(3) "♫"
39-
["pink_in_czech_unicode_string_constant"]=>
40-
string(9) "růžový"
41-
["ligature_fi_nchar"]=>
42-
string(3) "fi"
43-
["segno_u+1d10b_constant"]=>
44-
string(4) "𝄋"
45-
}
46-
}
79+
beamed_eighth_notes_binary_encoded_utf16le: PASS
80+
beamed_eighth_notes_nchar: PASS
81+
beamed_eighth_notes_u+266b_constant: PASS
82+
ligature_fi_nchar: PASS
83+
php_ascii_string_constant: PASS
84+
php_unicode_string_constant: PASS
85+
pink_in_czech_binary_encoded_utf16le: PASS
86+
pink_in_czech_unicode_string_constant: PASS
87+
segno_u+1d10b_constant: PASS

0 commit comments

Comments
 (0)