dir_variation1.phpt [plain text]
--TEST--
Test dir() function : usage variations - unexpected value for 'dir' argument
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip.. Not valid for Windows');
}
?>
--FILE--
<?php
echo "*** Testing dir() : unexpected values for \$directory argument ***\n";
$unset_var = 10;
unset($unset_var);
class A
{
public $var;
public function init() {
$this->var = 10;
}
}
$fp = fopen(__FILE__, "r"); $dfp = opendir( dirname(__FILE__) );
$unexpected_values = array (
array(),
array(0),
array(1),
array(1, 2),
array('color' => 'red', 'item' => 'pen'),
NULL,
null,
true,
false,
TRUE,
FALSE,
"",
'',
@$undefined_var,
@$unset_var,
$fp,
$dfp,
new A()
);
$iterator = 1;
foreach( $unexpected_values as $unexpected_value ) {
echo "\n-- Iteration $iterator --\n";
var_dump( dir($unexpected_value) );
$iterator++;
}
fclose($fp);
closedir($dfp);
echo "Done";
?>
--EXPECTF--
*** Testing dir() : unexpected values for $directory argument ***
-- Iteration 1 --
Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 2 --
Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 3 --
Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 4 --
Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 5 --
Warning: dir() expects parameter 1 to be a valid path, array given in %s on line %d
NULL
-- Iteration 6 --
bool(false)
-- Iteration 7 --
bool(false)
-- Iteration 8 --
Warning: dir(1): failed to open dir: %s in %s on line %d
bool(false)
-- Iteration 9 --
bool(false)
-- Iteration 10 --
Warning: dir(1): failed to open dir: %s in %s on line %d
bool(false)
-- Iteration 11 --
bool(false)
-- Iteration 12 --
bool(false)
-- Iteration 13 --
bool(false)
-- Iteration 14 --
bool(false)
-- Iteration 15 --
bool(false)
-- Iteration 16 --
Warning: dir() expects parameter 1 to be a valid path, resource given in %s on line %d
NULL
-- Iteration 17 --
Warning: dir() expects parameter 1 to be a valid path, resource given in %s on line %d
NULL
-- Iteration 18 --
Warning: dir() expects parameter 1 to be a valid path, object given in %s on line %d
NULL
Done