Skip to content

Commit 6bf0367

Browse files
committed
fix test
1 parent 3841a82 commit 6bf0367

1 file changed

Lines changed: 35 additions & 13 deletions

File tree

ext/intl/tests/resourcebundle_get_without_fallback.phpt

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,45 @@ ResourceBundle::get() rejects fallback results when fallback is disabled with co
44
intl
55
--FILE--
66
<?php
7-
function debug($res) {
8-
if (is_null($res)) {
9-
$ret = "NULL\n";
10-
} else {
11-
$ret = print_r($res, true) . "\n";
12-
}
13-
return $ret . sprintf("%5d: %s\n", intl_get_error_code(), intl_get_error_message());
7+
require_once "resourcebundle.inc";
8+
9+
$fixture = __DIR__ . '/resourcebundle_get_without_fallback_tmp';
10+
if (!is_dir($fixture)) {
11+
mkdir($fixture);
12+
}
13+
copy(BUNDLE . '/root.res', $fixture . '/root.res');
14+
15+
$resIndex = file_get_contents(BUNDLE . '/res_index.res');
16+
$resIndex = str_replace("\0es\0root", "\0en\0root", $resIndex, $replacementCount);
17+
if ($replacementCount !== 1) {
18+
die("Failed to prepare resource bundle index\n");
1419
}
20+
file_put_contents($fixture . '/res_index.res', $resIndex);
1521

16-
$bundle = new ResourceBundle('de_DE', 'ICUDATA');
17-
echo debug($bundle->get('Version', false));
22+
// Keep the binary layout intact while making this key fall back to root.res.
23+
$enBundle = file_get_contents(BUNDLE . '/es.res');
24+
$enBundle = str_replace('teststring', 'teststrinh', $enBundle, $replacementCount);
25+
if ($replacementCount !== 1) {
26+
die("Failed to prepare resource bundle fixture\n");
27+
}
28+
file_put_contents($fixture . '/en.res', $enBundle);
1829

19-
$bundle = resourcebundle_create('de_DE', 'ICUDATA');
20-
echo debug(resourcebundle_get($bundle, 'Version', false));
30+
$bundle = new ResourceBundle('en', $fixture);
31+
echo debug($bundle->get('teststring', false));
32+
33+
$bundle = resourcebundle_create('en', $fixture);
34+
echo debug(resourcebundle_get($bundle, 'teststring', false));
2135
?>
2236
--EXPECTF--
2337
NULL
24-
%i: ResourceBundle::get(): Cannot load element 'Version' without fallback to %s: U_USING_%s_WARNING
38+
%i: ResourceBundle::get(): Cannot load element 'teststring' without fallback to %s: U_USING_%s_WARNING
2539
NULL
26-
%i: resourcebundle_get(): Cannot load element 'Version' without fallback to %s: U_USING_%s_WARNING
40+
%i: resourcebundle_get(): Cannot load element 'teststring' without fallback to %s: U_USING_%s_WARNING
41+
--CLEAN--
42+
<?php
43+
$fixture = __DIR__ . '/resourcebundle_get_without_fallback_tmp';
44+
@unlink($fixture . '/en.res');
45+
@unlink($fixture . '/root.res');
46+
@unlink($fixture . '/res_index.res');
47+
@rmdir($fixture);
48+
?>

0 commit comments

Comments
 (0)