locale_accept.phpt 985 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. locale_accept_from_http
  3. --SKIPIF--
  4. <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
  5. --FILE--
  6. <?php
  7. /*
  8. * Try parsing different Locales
  9. * with Procedural and Object methods.
  10. */
  11. function ut_main()
  12. {
  13. $res_str = "";
  14. $http_acc = array(
  15. 'en-us,en;q=0.5',
  16. 'da, en-gb;q=0.8, en;q=0.7',
  17. 'zh, en-us;q=0.8, en;q=0.7',
  18. 'xx, fr-FR;q=0.3, de-DE;q=0.5',
  19. 'none',
  20. array()
  21. );
  22. foreach($http_acc as $http) {
  23. $res = ut_loc_accept_http($http);
  24. $res_str .= @"Accepting $http: $res\n";
  25. }
  26. return $res_str;
  27. }
  28. include_once( 'ut_common.inc' );
  29. ut_run();
  30. ?>
  31. --EXPECTF--
  32. Warning: Locale::acceptFromHttp() expects parameter 1 to be string, array given in %s on line %d
  33. Warning: locale_accept_from_http() expects parameter 1 to be string, array given in %s on line %d
  34. Accepting en-us,en;q=0.5: en_US
  35. Accepting da, en-gb;q=0.8, en;q=0.7: da
  36. Accepting zh, en-us;q=0.8, en;q=0.7: zh
  37. Accepting xx, fr-FR;q=0.3, de-DE;q=0.5: de_DE
  38. Accepting none:
  39. Accepting Array: