formatter_get_locale.phpt 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --TEST--
  2. numfmt_get_locale()
  3. --SKIPIF--
  4. <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
  5. <?php if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?>
  6. --FILE--
  7. <?php
  8. /*
  9. * Get locale.
  10. */
  11. function ut_main()
  12. {
  13. $locales = array(
  14. 'en_UK',
  15. 'en_US@California',
  16. 'fr_CA',
  17. );
  18. $loc_types = array(
  19. Locale::ACTUAL_LOCALE => 'actual',
  20. Locale::VALID_LOCALE => 'valid',
  21. );
  22. $res_str = '';
  23. foreach( $locales as $locale )
  24. {
  25. $fmt = ut_nfmt_create( $locale, NumberFormatter::DECIMAL );
  26. $res_str .= "$locale: ";
  27. foreach( $loc_types as $loc_type => $loc_type_name )
  28. $res_str .= sprintf( " %s=%s",
  29. $loc_type_name,
  30. dump( ut_nfmt_get_locale( $fmt, $loc_type ) ) );
  31. $res_str .= "\n";
  32. }
  33. return $res_str;
  34. }
  35. include_once( 'ut_common.inc' );
  36. // Run the test
  37. ut_run();
  38. ?>
  39. --EXPECT--
  40. en_UK: actual='en' valid='en'
  41. en_US@California: actual='en' valid='en'
  42. fr_CA: actual='fr_CA' valid='fr_CA'