Annotation of embedaddon/php/ext/pcre/tests/preg_replace_callback_error.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test preg_replace_callback() function : error 
                      3: --FILE--
                      4: <?php
                      5: /*
                      6: * proto string preg_replace(mixed regex, mixed replace, mixed subject [, int limit [, count]])
                      7: * Function is implemented in ext/pcre/php_pcre.c
                      8: */
                      9: echo "***Testing preg_replace_callback() : error conditions***\n";
                     10: //Zero arguments
                     11: echo "\n-- Testing preg_replace_callback() function with Zero arguments --\n";
                     12: var_dump(preg_replace_callback());
                     13: //Test preg_replace_callback() with one more than the expected number of arguments
                     14: echo "\n-- Testing preg_replace_callback() function with more than expected no. of arguments --\n";
                     15: $replacement = array('zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine');
                     16: function integer_word($matches) {
                     17:     global $replacement;
                     18:     return $replacement[$matches[0]];
                     19: }
                     20: $regex = '/\d/';
                     21: $subject = 'there are 7 words in this sentence.';
                     22: $limit = 10;
                     23: $extra_arg = 10;
                     24: var_dump(preg_replace_callback($regex, 'integer_word', $subject, $limit, $count, $extra_arg));
                     25: //Testing preg_replace_callback() with one less than the expected number of arguments
                     26: echo "\n-- Testing preg_replace_callback() function with less than expected no. of arguments --\n";
                     27: $regex = '/\d/';
                     28: var_dump(preg_replace_callback($regex, 'integer word'));
                     29: echo "Done";
                     30: ?>
                     31: --EXPECTF--
                     32: ***Testing preg_replace_callback() : error conditions***
                     33: 
                     34: -- Testing preg_replace_callback() function with Zero arguments --
                     35: 
                     36: Warning: preg_replace_callback() expects at least 3 parameters, 0 given in %s on line %d
                     37: NULL
                     38: 
                     39: -- Testing preg_replace_callback() function with more than expected no. of arguments --
                     40: 
                     41: Warning: preg_replace_callback() expects at most 5 parameters, 6 given in %s on line %d
                     42: NULL
                     43: 
                     44: -- Testing preg_replace_callback() function with less than expected no. of arguments --
                     45: 
                     46: Warning: preg_replace_callback() expects at least 3 parameters, 2 given in %s on line %d
                     47: NULL
                     48: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>