1--TEST--
2Test stristr() function : error conditions
3--FILE--
4<?php
5
6/* Prototype: string stristr  ( string $haystack  , mixed $needle  [, bool $before_needle  ] )
7   Description: Case-insensitive strstr()
8*/
9echo "*** Testing stristr() : error conditions ***\n";
10
11echo "\n-- Testing stristr() function with no arguments --\n";
12var_dump( stristr() );
13var_dump( stristr("") );
14
15echo "\n-- Testing stristr() function with no needle --\n";
16var_dump( stristr("Hello World") );  // without "needle"
17
18echo "\n-- Testing stristr() function with more than expected no. of arguments --\n";
19$extra_arg = 10;
20var_dump( stristr("Hello World",  "World", true, $extra_arg) );
21
22echo "\n-- Testing stristr() function with empty haystack --\n";
23var_dump( stristr(NULL, "") );
24
25echo "\n-- Testing stristr() function with empty needle --\n";
26var_dump( stristr("Hello World", "") );
27
28?>
29===DONE===
30--EXPECTF--
31*** Testing stristr() : error conditions ***
32
33-- Testing stristr() function with no arguments --
34
35Warning: stristr() expects at least 2 parameters, 0 given in %s on line %d
36NULL
37
38Warning: stristr() expects at least 2 parameters, 1 given in %s on line %d
39NULL
40
41-- Testing stristr() function with no needle --
42
43Warning: stristr() expects at least 2 parameters, 1 given in %s on line %d
44NULL
45
46-- Testing stristr() function with more than expected no. of arguments --
47
48Warning: stristr() expects at most 3 parameters, 4 given in %s on line %d
49NULL
50
51-- Testing stristr() function with empty haystack --
52
53Warning: stristr(): Empty delimiter in %s on line %d
54bool(false)
55
56-- Testing stristr() function with empty needle --
57
58Warning: stristr(): Empty delimiter in %s on line %d
59bool(false)
60===DONE===
61