xref: /PHP-7.1/ext/pcre/tests/preg_grep_error.phpt (revision 113213f0)
1--TEST--
2Test preg_grep() function : error conditions - wrong numbers of parameters
3--FILE--
4<?php
5/*
6* proto array preg_grep(string regex, array input [, int flags])
7* Function is implemented in ext/pcre/php_pcre.c
8*/
9echo "*** Testing preg_grep() : error conditions ***\n";
10// Zero arguments
11echo "\n-- Testing preg_grep() function with Zero arguments --\n";
12var_dump(preg_grep());
13//Test preg_grep with one more than the expected number of arguments
14echo "\n-- Testing preg_grep() function with more than expected no. of arguments --\n";
15$regex = '/\d/';
16$input = array(1, 2);
17$flags = 0;
18$extra_arg = 10;
19var_dump(preg_grep($regex, $input, $flags, $extra_arg));
20// Testing preg_grep withone less than the expected number of arguments
21echo "\n-- Testing preg_grep() function with less than expected no. of arguments --\n";
22$regex = 'string_val';
23var_dump(preg_grep($regex));
24echo "Done"
25?>
26--EXPECTF--
27*** Testing preg_grep() : error conditions ***
28
29-- Testing preg_grep() function with Zero arguments --
30
31Warning: preg_grep() expects at least 2 parameters, 0 given in %spreg_grep_error.php on line %d
32NULL
33
34-- Testing preg_grep() function with more than expected no. of arguments --
35
36Warning: preg_grep() expects at most 3 parameters, 4 given in %spreg_grep_error.php on line %d
37NULL
38
39-- Testing preg_grep() function with less than expected no. of arguments --
40
41Warning: preg_grep() expects at least 2 parameters, 1 given in %spreg_grep_error.php on line %d
42NULL
43Done
44