Annotation of embedaddon/php/ext/standard/tests/file/file_variation5.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: file() with various paths
3: --SKIPIF--
4: <?php
5: if (substr(PHP_OS, 0, 3) == 'WIN') {
6: die('skip non-windows only test');
7: }
8: ?>
9: --FILE--
10: <?php
11:
12: $script_directory = dirname(__FILE__);
13: chdir($script_directory);
14: $test_dirname = basename(__FILE__, ".php") . "testdir";
15: mkdir($test_dirname);
16:
17: $filepath = __FILE__ . ".tmp";
18: $filename = basename($filepath);
19: $fd = fopen($filepath, "w+");
20: fwrite($fd, "Line 1\nLine 2\nLine 3");
21: fclose($fd);
22:
23: echo "file() on a path containing .. and .\n";
24: var_dump(file("./$test_dirname/../$filename"));
25:
26: echo "\nfile() on a path containing .. with invalid directories\n";
27: var_dump(file("./$test_dirname/bad_dir/../../$filename"));
28:
29: echo "\nfile() on a linked file\n";
30: $linkname = "somelink";
31: var_dump(symlink($filepath, $linkname));
32: var_dump(file($linkname));
33: var_dump(unlink($linkname));
34:
35: echo "\nfile() on a relative path from a different working directory\n";
36: chdir($test_dirname);
37: var_dump(file("../$filename"));
38: chdir($script_directory);
39:
40: chdir($script_directory);
41: rmdir($test_dirname);
42: unlink($filepath);
43:
44: ?>
45: --EXPECT--
46: file() on a path containing .. and .
47: array(3) {
48: [0]=>
49: string(7) "Line 1
50: "
51: [1]=>
52: string(7) "Line 2
53: "
54: [2]=>
55: string(6) "Line 3"
56: }
57:
58: file() on a path containing .. with invalid directories
59: array(3) {
60: [0]=>
61: string(7) "Line 1
62: "
63: [1]=>
64: string(7) "Line 2
65: "
66: [2]=>
67: string(6) "Line 3"
68: }
69:
70: file() on a linked file
71: bool(true)
72: array(3) {
73: [0]=>
74: string(7) "Line 1
75: "
76: [1]=>
77: string(7) "Line 2
78: "
79: [2]=>
80: string(6) "Line 3"
81: }
82: bool(true)
83:
84: file() on a relative path from a different working directory
85: array(3) {
86: [0]=>
87: string(7) "Line 1
88: "
89: [1]=>
90: string(7) "Line 2
91: "
92: [2]=>
93: string(6) "Line 3"
94: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>