diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/standard/tests/file/file_variation5.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/standard/tests/file/file_variation5.phpt')
-rw-r--r-- | ext/standard/tests/file/file_variation5.phpt | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/ext/standard/tests/file/file_variation5.phpt b/ext/standard/tests/file/file_variation5.phpt new file mode 100644 index 0000000..1f15491 --- /dev/null +++ b/ext/standard/tests/file/file_variation5.phpt @@ -0,0 +1,94 @@ +--TEST-- +file() with various paths +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip non-windows only test'); +} +?> +--FILE-- +<?php + +$script_directory = dirname(__FILE__); +chdir($script_directory); +$test_dirname = basename(__FILE__, ".php") . "testdir"; +mkdir($test_dirname); + +$filepath = __FILE__ . ".tmp"; +$filename = basename($filepath); +$fd = fopen($filepath, "w+"); +fwrite($fd, "Line 1\nLine 2\nLine 3"); +fclose($fd); + +echo "file() on a path containing .. and .\n"; +var_dump(file("./$test_dirname/../$filename")); + +echo "\nfile() on a path containing .. with invalid directories\n"; +var_dump(file("./$test_dirname/bad_dir/../../$filename")); + +echo "\nfile() on a linked file\n"; +$linkname = "somelink"; +var_dump(symlink($filepath, $linkname)); +var_dump(file($linkname)); +var_dump(unlink($linkname)); + +echo "\nfile() on a relative path from a different working directory\n"; +chdir($test_dirname); +var_dump(file("../$filename")); +chdir($script_directory); + +chdir($script_directory); +rmdir($test_dirname); +unlink($filepath); + +?> +--EXPECT-- +file() on a path containing .. and . +array(3) { + [0]=> + string(7) "Line 1 +" + [1]=> + string(7) "Line 2 +" + [2]=> + string(6) "Line 3" +} + +file() on a path containing .. with invalid directories +array(3) { + [0]=> + string(7) "Line 1 +" + [1]=> + string(7) "Line 2 +" + [2]=> + string(6) "Line 3" +} + +file() on a linked file +bool(true) +array(3) { + [0]=> + string(7) "Line 1 +" + [1]=> + string(7) "Line 2 +" + [2]=> + string(6) "Line 3" +} +bool(true) + +file() on a relative path from a different working directory +array(3) { + [0]=> + string(7) "Line 1 +" + [1]=> + string(7) "Line 2 +" + [2]=> + string(6) "Line 3" +} |