File: glob_error.phpt

package info (click to toggle)
php5 5.6.33%2Bdfsg-0%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 157,872 kB
  • sloc: ansic: 756,065; php: 22,030; sh: 12,311; cpp: 8,771; xml: 6,179; yacc: 1,564; exp: 1,514; makefile: 1,467; pascal: 1,147; awk: 538; perl: 315; sql: 22
file content (53 lines) | stat: -rw-r--r-- 1,455 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--TEST--
Test glob() function: error conditions
--FILE--
<?php
/* Prototype: array glob ( string $pattern [, int $flags] );
   Description: Find pathnames matching a pattern
*/

$file_path = dirname(__FILE__);

// temp dir created
mkdir("$file_path/glob_error");
// temp file created
$fp = fopen("$file_path/glob_error/wonder12345", "w");
fclose($fp);

echo "*** Testing glob() : error conditions ***\n";

echo "-- Testing glob() with unexpected no. of arguments --\n";
var_dump( glob() );  // args < expected
var_dump( glob(dirname(__FILE__)."/glob_error/wonder12345", GLOB_ERR, 3) );  // args > expected

echo "\n-- Testing glob() with invalid arguments --\n";
var_dump( glob(dirname(__FILE__)."/glob_error/wonder12345", '') );
var_dump( glob(dirname(__FILE__)."/glob_error/wonder12345", "string") );

echo "Done\n";
?>
--CLEAN--
<?php
// temp file deleted
unlink(dirname(__FILE__)."/glob_error/wonder12345");
// temp dir deleted
rmdir(dirname(__FILE__)."/glob_error");
?>
--EXPECTF--
*** Testing glob() : error conditions ***
-- Testing glob() with unexpected no. of arguments --

Warning: glob() expects at least 1 parameter, 0 given in %s on line %d
NULL

Warning: glob() expects at most 2 parameters, 3 given in %s on line %d
NULL

-- Testing glob() with invalid arguments --

Warning: glob() expects parameter 2 to be long, string given in %s on line %d
NULL

Warning: glob() expects parameter 2 to be long, string given in %s on line %d
NULL
Done