kraghuba Sat Jul 21 17:31:43 2007 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/standard/tests/file is_dir_variation4.phpt
is_dir_variation3.phpt
is_dir_variation2.phpt
is_dir_variation1.phpt
Log:
New testcases for is_dir() function
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/is_dir_variation4.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/is_dir_variation4.phpt
+++ php-src/ext/standard/tests/file/is_dir_variation4.phpt
--TEST--
Test is_dir() function: usage variations - diff. path notations
--FILE--
<?php
/* Prototype: bool is_dir ( string $dirname );
Description: Tells whether the dirname is a directory
Returns TRUE if the dirname exists and is a directory, FALSE otherwise.
*/
/* Passing dir names with different notations, using slashes, wild-card chars */
$file_path = dirname(__FILE__);
echo "*** Testing is_dir() with different notations of dir names ***";
$dir_name = "/is_dir_variation4";
mkdir($file_path.$dir_name);
$dirs_arr = array(
"is_dir_variation4",
"./is_dir_variation4",
/* Testing a file trailing slash */
"is_dir_variation4/",
"./is_dir_variation4/",
/* Testing file with double trailing slashes */
"is_dir_variation4//",
"./is_dir_variation4//",
".//is_dir_variation4//",
"is_dir_vari*",
/* Testing Binary safe */
"./is_dir_variation4/".chr(0),
"is_dir_variation4\0"
);
$count = 1;
/* loop through to test each element the above array */
foreach($dirs_arr as $dir) {
echo "\n-- Iteration $count --\n";
var_dump( is_dir($file_path."/".$dir ) );
$count++;
}
echo "\n*** Done ***";
?>
--CLEAN--
<?php
$file_path = dirname(__FILE__);
$dir_name = $file_path."/is_dir_variation4";
rmdir($dir_name);
?>
--EXPECTF--
*** Testing is_dir() with different notations of dir names ***
-- Iteration 1 --
bool(true)
-- Iteration 2 --
bool(true)
-- Iteration 3 --
bool(true)
-- Iteration 4 --
bool(true)
-- Iteration 5 --
bool(true)
-- Iteration 6 --
bool(true)
-- Iteration 7 --
bool(true)
-- Iteration 8 --
bool(false)
-- Iteration 9 --
bool(true)
-- Iteration 10 --
bool(true)
*** Done ***
--UEXPECTF--
*** Testing is_dir() with different notations of dir names ***
-- Iteration 1 --
bool(true)
-- Iteration 2 --
bool(true)
-- Iteration 3 --
bool(true)
-- Iteration 4 --
bool(true)
-- Iteration 5 --
bool(true)
-- Iteration 6 --
bool(true)
-- Iteration 7 --
bool(true)
-- Iteration 8 --
bool(false)
-- Iteration 9 --
bool(true)
-- Iteration 10 --
bool(true)
*** Done ***
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/is_dir_variation3.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/is_dir_variation3.phpt
+++ php-src/ext/standard/tests/file/is_dir_variation3.phpt
--TEST--
Test is_dir() function: usage variations - invalid arguments
--FILE--
<?php
/* Prototype: bool is_dir ( string $dirname );
Description: Tells whether the dirname is a directory
Returns TRUE if the dirname exists and is a directory, FALSE otherwise.
*/
/* Passing invalid arguments to is_dir() */
$dir_handle = opendir( dirname(__FILE__) );
echo "*** Testing is_dir() with Invalid arguments: expected bool(false) ***\n";
$dirnames = array(
/* Invalid dirnames */
-2.34555,
TRUE,
FALSE,
NULL,
$dir_handle,
/* Non-existing dirnames */
0,
1234
);
/* loop through to test each element the above array */
foreach($dirnames as $dirname) {
var_dump( is_dir($dirname) );
}
closedir($dir_handle);
echo "\n*** Done ***";
?>
--EXPECTF--
*** Testing is_dir() with Invalid arguments: expected bool(false) ***
bool(false)
bool(false)
bool(false)
bool(false)
Warning: is_dir() expects parameter 1 to be string (Unicode or binary),
resource given in %s on line %d
NULL
bool(false)
bool(false)
*** Done ***
--UEXPECTF--
*** Testing is_dir() with Invalid arguments: expected bool(false) ***
bool(false)
bool(false)
bool(false)
bool(false)
Warning: is_dir() expects parameter 1 to be string (Unicode or binary),
resource given in %s on line %d
NULL
bool(false)
bool(false)
*** Done ***
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/is_dir_variation2.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/is_dir_variation2.phpt
+++ php-src/ext/standard/tests/file/is_dir_variation2.phpt
--TEST--
Test is_dir() function: usage variations - links
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Do not run on Windows');
}
--FILE--
<?php
/* Prototype: bool is_dir ( string $dirname );
Description: Tells whether the dirname is a directory
Returns TRUE if the dirname exists and is a directory, FALSE otherwise.
*/
/* Testing is_dir() with dir, soft & hard link to dir,
and with file, soft & hard link to file */
$file_path = dirname(__FILE__);
echo "*** Testing is_dir() with dir and links to dir ***\n";
echo "-- With dir --\n";
$dirname = $file_path."/is_dir_variation2";
mkdir($dirname);
var_dump( is_dir($dirname) );
clearstatcache();
echo "-- With symlink --\n";
symlink($file_path."/is_dir_variation2",
$file_path."/is_dir_variation2_symlink");
var_dump( is_dir($file_path."/is_dir_variation2_symlink") ); //is_dir()
resolves symlinks
clearstatcache();
echo "-- With hardlink --";
link($file_path."/is_dir_variation2", $file_path."/is_dir_variation2_link");
//Not permitted to create hard-link to a dir
var_dump( is_dir($file_path."/is_dir_variation2_link") );
clearstatcache();
echo "\n*** Testing is_dir() with file and links to a file ***\n";
echo "-- With file --\n";
$filename = $file_path."/is_dir_variation2.tmp";
fclose( fopen($filename, "w") );
var_dump( is_dir($filename) );
clearstatcache();
echo "-- With symlink --\n";
symlink($file_path."/is_dir_variation2.tmp",
$file_path."/is_dir_variation2_symlink.tmp");
var_dump( is_dir($file_path."/is_dir_variation2_symlink.tmp") );
clearstatcache();
echo "-- With hardlink --\n";
link($file_path."/is_dir_variation2.tmp",
$file_path."/is_dir_variation2_link.tmp");
var_dump( is_dir($file_path."/is_dir_variation2_link.tmp") );
clearstatcache();
echo "\n*** Done ***";
?>
--CLEAN--
<?php
$file_path = dirname(__FILE__);
unlink($file_path."/is_dir_variation2_symlink");
unlink($file_path."/is_dir_variation2_link");
unlink($file_path."/is_dir_variation2_symlink.tmp");
unlink($file_path."/is_dir_variation2_link.tmp");
unlink($file_path."/is_dir_variation2.tmp");
rmdir($file_path."/is_dir_variation2");
?>
--EXPECTF--
*** Testing is_dir() with dir and links to dir ***
-- With dir --
bool(true)
-- With symlink --
bool(true)
-- With hardlink --
Warning: link(): Operation not permitted in %s on line %d
bool(false)
*** Testing is_dir() with file and links to a file ***
-- With file --
bool(false)
-- With symlink --
bool(false)
-- With hardlink --
bool(false)
*** Done ***
--UEXPECTF--
*** Testing is_dir() with dir and links to dir ***
-- With dir --
bool(true)
-- With symlink --
bool(true)
-- With hardlink --
Warning: link(): Operation not permitted in %s on line %d
bool(false)
*** Testing is_dir() with file and links to a file ***
-- With file --
bool(false)
-- With symlink --
bool(false)
-- With hardlink --
bool(false)
*** Done ***
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/is_dir_variation1.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/file/is_dir_variation1.phpt
+++ php-src/ext/standard/tests/file/is_dir_variation1.phpt
--TEST--
Test is_dir() function: usage variations - dir/subdir
--FILE--
<?php
/* Prototype: bool is_dir ( string $dirname );
Description: Tells whether the dirname is a directory
Returns TRUE if the dirname exists and is a directory, FALSE otherwise.
*/
/* Testing is_dir() with base and sub dirs */
$file_path = dirname(__FILE__);
echo "-- Testing is_dir() with an empty dir --\n";
$dirname = $file_path."/is_dir_variation1";
mkdir($dirname);
var_dump( is_dir($dirname) );
clearstatcache();
echo "-- Testing is_dir() with a subdir in base dir --\n";
$subdirname = $dirname."/is_dir_variation1_sub";
mkdir($subdirname);
var_dump( is_dir($subdirname) );
var_dump( is_dir($dirname) );
echo "\n*** Done ***";
?>
--CLEAN--
<?php
$file_path = dirname(__FILE__);
$dir_name = $file_path."/is_dir_variation1";
unlink($file_path."/is_dir_variation1.tmp");
rmdir($dir_name."/is_dir_variation1_sub");
rmdir($dir_name);
?>
--EXPECTF--
-- Testing is_dir() with an empty dir --
bool(true)
-- Testing is_dir() with a subdir in base dir --
bool(true)
bool(true)
*** Done ***
--UEXPECTF--
-- Testing is_dir() with an empty dir --
bool(true)
-- Testing is_dir() with a subdir in base dir --
bool(true)
bool(true)
*** Done ***
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php