1--TEST--
2Test ResourceBundle::get() and length() - existing/missing keys
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5--FILE--
6<?php
7    include "resourcebundle.inc";
8
9function ut_main() {
10    $str_res = '';
11    // fall back
12    $r = ut_resourcebundle_create( 'en_US', BUNDLE );
13
14    $str_res .= sprintf( "length: %d\n", ut_resourcebundle_count($r) );
15    $str_res .= sprintf( "teststring: %s\n", ut_resourcebundle_get($r,  'teststring' ) );
16    $str_res .= sprintf( "testint: %d\n", ut_resourcebundle_get($r, 'testint' ) );
17
18    $str_res .= print_r( ut_resourcebundle_get($r, 'testvector' ), true );
19
20    $str_res .= sprintf( "testbin: %s\n", bin2hex(ut_resourcebundle_get( $r,'testbin' )) );
21
22    $r2 = ut_resourcebundle_get($r, 'testtable' );
23    $str_res .= sprintf( "testtable: %d\n", ut_resourcebundle_get($r2, 'major' ) );
24
25    $r2 = ut_resourcebundle_get($r,'testarray' );
26    $str_res .= sprintf( "testarray: %s\n", ut_resourcebundle_get($r2, 2 ) );
27
28    $t = ut_resourcebundle_get( $r, 'nonexisting' );
29    $str_res .= debug( $t );
30
31    // Make sure accessing existing after non-existing works.
32    $t = ut_resourcebundle_get( $r, 'teststring' );
33    $str_res .= debug( $t );
34
35    return $str_res;
36}
37    include_once( 'ut_common.inc' );
38    ut_run();
39?>
40--EXPECT--
41length: 6
42teststring: Hello World!
43testint: 2
44Array
45(
46    [0] => 1
47    [1] => 2
48    [2] => 3
49    [3] => 4
50    [4] => 5
51    [5] => 6
52    [6] => 7
53    [7] => 8
54    [8] => 9
55    [9] => 0
56)
57testbin: a1b2c3d4e5f67890
58testtable: 3
59testarray: string 3
60NULL
61    2: Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR
62Hello World!
63    0: U_ZERO_ERROR
64