Annotation of embedaddon/php/ext/json/tests/json_encode_error.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test json_encode() function : error conditions
! 3: --SKIPIF--
! 4: <?php
! 5: if (!extension_loaded("json")) {
! 6: die('skip JSON extension not available in this build');
! 7: }
! 8: ?>
! 9: --FILE--
! 10: <?php
! 11: /* Prototype : string json_encode ( mixed $value [, int $options=0 ] )
! 12: * Description: Returns the JSON representation of a value
! 13: * Source code: ext/json/php_json.c
! 14: * Alias to functions:
! 15: */
! 16:
! 17: echo "*** Testing json_encode() : error conditions ***\n";
! 18:
! 19: echo "\n-- Testing json_encode() function with no arguments --\n";
! 20: var_dump( json_encode() );
! 21:
! 22: echo "\n-- Testing json_encode() function with more than expected no. of arguments --\n";
! 23: $extra_arg = 10;
! 24: var_dump( json_encode("abc", 0, $extra_arg) );
! 25:
! 26: ?>
! 27: ===Done===
! 28: --EXPECTF--
! 29: *** Testing json_encode() : error conditions ***
! 30:
! 31: -- Testing json_encode() function with no arguments --
! 32:
! 33: Warning: json_encode() expects at least 1 parameter, 0 given in %s on line %d
! 34: NULL
! 35:
! 36: -- Testing json_encode() function with more than expected no. of arguments --
! 37:
! 38: Warning: json_encode() expects at most 2 parameters, 3 given in %s on line %d
! 39: NULL
! 40: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>