Annotation of embedaddon/php/ext/standard/tests/file/parse_ini_file_variation6.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test parse_ini_file() function : variation - various absolute and relative paths
3: --CREDITS--
4: Dave Kelsey <d_kelsey@uk.ibm.com>
5: --FILE--
6: <?php
7: /* Prototype : array parse_ini_file(string filename [, bool process_sections])
8: * Description: Parse configuration file
9: * Source code: ext/standard/basic_functions.c
10: * Alias to functions:
11: */
12:
13: echo "*** Testing parse_ini_file() : variation ***\n";
14: $mainDir = "parseIniFileVar6.dir";
15: $subDir = "parseIniFileVar6Sub";
16: $absMainDir = dirname(__FILE__)."/".$mainDir;
17: mkdir($absMainDir);
18: $absSubDir = $absMainDir."/".$subDir;
19: mkdir($absSubDir);
20:
21: $old_dir_path = getcwd();
22: chdir(dirname(__FILE__));
23:
24: $allDirs = array(
25: // absolute paths
26: "$absSubDir/",
27: "$absSubDir/../".$subDir,
28: "$absSubDir//.././".$subDir,
29: "$absSubDir/../../".$mainDir."/./".$subDir,
30: "$absSubDir/..///".$subDir."//..//../".$subDir,
31: "$absSubDir/BADDIR",
32:
33: // relative paths
34: $mainDir."/".$subDir,
35: $mainDir."//".$subDir,
36: $mainDir."///".$subDir,
37: "./".$mainDir."/../".$mainDir."/".$subDir,
38: "BADDIR",
39:
40: );
41:
42: $filename = 'ParseIniFileVar6.ini';
43: $content="a=test";
44: $absFile = $absSubDir.'/'.$filename;
45: $h = fopen($absFile,"w");
46: fwrite($h, $content);
47: fclose($h);
48:
49: for($i = 0; $i<count($allDirs); $i++) {
50: $j = $i+1;
51: $dir = $allDirs[$i];
52: echo "\n-- Iteration $j --\n";
53: var_dump(parse_ini_file($dir."/".$filename));
54: }
55:
56: unlink($absFile);
57: chdir($old_dir_path);
58: rmdir($absSubDir);
59: rmdir($absMainDir);
60:
61: echo "\n*** Done ***\n";
62: ?>
63: --EXPECTF--
64: *** Testing parse_ini_file() : variation ***
65:
66: -- Iteration 1 --
67: array(1) {
68: ["a"]=>
69: string(4) "test"
70: }
71:
72: -- Iteration 2 --
73: array(1) {
74: ["a"]=>
75: string(4) "test"
76: }
77:
78: -- Iteration 3 --
79: array(1) {
80: ["a"]=>
81: string(4) "test"
82: }
83:
84: -- Iteration 4 --
85: array(1) {
86: ["a"]=>
87: string(4) "test"
88: }
89:
90: -- Iteration 5 --
91:
92: Warning: parse_ini_file(%sparseIniFileVar6.dir/parseIniFileVar6Sub/..///parseIniFileVar6Sub//..//../parseIniFileVar6Sub/ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d
93: bool(false)
94:
95: -- Iteration 6 --
96:
97: Warning: parse_ini_file(%sparseIniFileVar6.dir/parseIniFileVar6Sub/BADDIR/ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d
98: bool(false)
99:
100: -- Iteration 7 --
101: array(1) {
102: ["a"]=>
103: string(4) "test"
104: }
105:
106: -- Iteration 8 --
107: array(1) {
108: ["a"]=>
109: string(4) "test"
110: }
111:
112: -- Iteration 9 --
113: array(1) {
114: ["a"]=>
115: string(4) "test"
116: }
117:
118: -- Iteration 10 --
119: array(1) {
120: ["a"]=>
121: string(4) "test"
122: }
123:
124: -- Iteration 11 --
125:
126: Warning: parse_ini_file(BADDIR/ParseIniFileVar6.ini): failed to open stream: No such file or directory in %s on line %d
127: bool(false)
128:
129: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>