resourcebundle_individual.phpt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --TEST--
  2. Test 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. function ut_main() {
  9. $str_res = '';
  10. // fall back
  11. $r = ut_resourcebundle_create( 'en_US', BUNDLE );
  12. $str_res .= sprintf( "length: %d\n", ut_resourcebundle_count($r) );
  13. $str_res .= sprintf( "teststring: %s\n", ut_resourcebundle_get($r, 'teststring' ) );
  14. $str_res .= sprintf( "testint: %d\n", ut_resourcebundle_get($r, 'testint' ) );
  15. $str_res .= print_r( ut_resourcebundle_get($r, 'testvector' ), true );
  16. $str_res .= sprintf( "testbin: %s\n", bin2hex(ut_resourcebundle_get( $r,'testbin' )) );
  17. $r2 = ut_resourcebundle_get($r, 'testtable' );
  18. $str_res .= sprintf( "testtable: %d\n", ut_resourcebundle_get($r2, 'major' ) );
  19. $r2 = ut_resourcebundle_get($r,'testarray' );
  20. $str_res .= sprintf( "testarray: %s\n", ut_resourcebundle_get($r2, 2 ) );
  21. $t = ut_resourcebundle_get( $r, 'nonexisting' );
  22. $str_res .= debug( $t );
  23. return $str_res;
  24. }
  25. include_once( 'ut_common.inc' );
  26. ut_run();
  27. ?>
  28. --EXPECT--
  29. length: 6
  30. teststring: Hello World!
  31. testint: 2
  32. Array
  33. (
  34. [0] => 1
  35. [1] => 2
  36. [2] => 3
  37. [3] => 4
  38. [4] => 5
  39. [5] => 6
  40. [6] => 7
  41. [7] => 8
  42. [8] => 9
  43. [9] => 0
  44. )
  45. testbin: a1b2c3d4e5f67890
  46. testtable: 3
  47. testarray: string 3
  48. NULL
  49. 2: Cannot load resource element 'nonexisting': U_MISSING_RESOURCE_ERROR