Annotation of embedaddon/php/ext/intl/tests/idn_uts46_errors.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: IDN UTS #46 API error tests
! 3: --SKIPIF--
! 4: <?php
! 5: if (!extension_loaded('intl'))
! 6: die('skip');
! 7: if (!defined('INTL_IDNA_VARIANT_UTS46'))
! 8: die('skip no UTS #46 API');
! 9: --FILE--
! 10: <?php
! 11: ini_set("intl.error_level", E_WARNING);
! 12: echo "=> PHP level errors", "\n";
! 13:
! 14: echo "bad args:", "\n";
! 15: var_dump(idn_to_ascii("", 0, array()));
! 16: var_dump(idn_to_ascii("", 0, INTL_IDNA_VARIANT_UTS46, $foo, null));
! 17:
! 18: echo "bad variant:", "\n";
! 19: var_dump(idn_to_ascii("", 0, INTL_IDNA_VARIANT_UTS46 + 10));
! 20:
! 21: echo "empty domain:", "\n";
! 22: var_dump(idn_to_ascii("", 0, INTL_IDNA_VARIANT_UTS46));
! 23:
! 24: echo "fourth arg for 2003 variant (only notice raised):", "\n";
! 25: var_dump(idn_to_ascii("foo.com", 0, INTL_IDNA_VARIANT_2003, $foo));
! 26:
! 27: echo "with error, but no details arg:", "\n";
! 28: var_dump(idn_to_ascii("www.fußball.com-", 0, INTL_IDNA_VARIANT_UTS46));
! 29:
! 30: echo "with error, with details arg:", "\n";
! 31: var_dump(idn_to_ascii("www.fußball.com-", IDNA_NONTRANSITIONAL_TO_ASCII,
! 32: INTL_IDNA_VARIANT_UTS46, $foo));
! 33: var_dump($foo);
! 34:
! 35: echo "with error, with details arg, contextj:", "\n";
! 36: var_dump(idn_to_ascii(
! 37: html_entity_decode("www.a‍b.com", 0, "UTF-8"),
! 38: IDNA_NONTRANSITIONAL_TO_ASCII | IDNA_CHECK_CONTEXTJ,
! 39: INTL_IDNA_VARIANT_UTS46, $foo));
! 40: var_dump($foo);
! 41: var_dump($foo["errors"]==IDNA_ERROR_CONTEXTJ);
! 42: --EXPECTF--
! 43: => PHP level errors
! 44: bad args:
! 45:
! 46: Warning: idn_to_ascii() expects parameter 3 to be long, array given in %s on line %d
! 47:
! 48: Warning: idn_to_ascii(): idn_to_ascii: bad arguments in %s on line %d
! 49: NULL
! 50:
! 51: Warning: idn_to_ascii() expects at most 4 parameters, 5 given in %s on line %d
! 52:
! 53: Warning: idn_to_ascii(): idn_to_ascii: bad arguments in %s on line %d
! 54: NULL
! 55: bad variant:
! 56:
! 57: Warning: idn_to_ascii(): idn_to_ascii: invalid variant, must be one of {INTL_IDNA_VARIANT_2003, INTL_IDNA_VARIANT_UTS46} in %s on line %d
! 58: bool(false)
! 59: empty domain:
! 60:
! 61: Warning: idn_to_ascii(): idn_to_ascii: empty domain name in %s on line %d
! 62: bool(false)
! 63: fourth arg for 2003 variant (only notice raised):
! 64:
! 65: Notice: idn_to_ascii(): 4 arguments were provided, but INTL_IDNA_VARIANT_2003 only takes 3 - extra argument ignored in %s on line %d
! 66: string(7) "foo.com"
! 67: with error, but no details arg:
! 68: bool(false)
! 69: with error, with details arg:
! 70: bool(false)
! 71: array(3) {
! 72: ["result"]=>
! 73: string(23) "www.xn--fuball-cta.com-"
! 74: ["isTransitionalDifferent"]=>
! 75: bool(true)
! 76: ["errors"]=>
! 77: int(16)
! 78: }
! 79: with error, with details arg, contextj:
! 80: bool(false)
! 81: array(3) {
! 82: ["result"]=>
! 83: string(18) "www.xn--ab-m1t.com"
! 84: ["isTransitionalDifferent"]=>
! 85: bool(true)
! 86: ["errors"]=>
! 87: int(4096)
! 88: }
! 89: bool(true)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>