1--TEST--
2Test parse_ini_file() function : variation - various absolute and relative paths
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--SKIPIF--
6<?php
7if(substr(PHP_OS, 0, 3) != "WIN")
8  die("skip Only run on Windows");
9?>
10--FILE--
11<?php
12/* Prototype  : array parse_ini_file(string filename [, bool process_sections])
13 * Description: Parse configuration file
14 * Source code: ext/standard/basic_functions.c
15 * Alias to functions:
16 */
17
18echo "*** Testing parse_ini_file() : variation ***\n";
19$mainDir = "parseIniFileVar私はガラスを食べられます.dir";
20$subDir = "parseIniFileVar私はガラスを食べられますSub";
21$absMainDir = dirname(__FILE__)."\\".$mainDir;
22mkdir($absMainDir);
23$absSubDir = $absMainDir."\\".$subDir;
24mkdir($absSubDir);
25
26$old_dir_path = getcwd();
27chdir(dirname(__FILE__));
28$unixifiedDir = '/'.substr(str_replace('\\','/',$absSubDir),3);
29
30$allDirs = array(
31  // absolute paths
32  "$absSubDir\\",
33  "$absSubDir\\..\\".$subDir,
34  "$absSubDir\\\\..\\.\\".$subDir,
35  "$absSubDir\\..\\..\\".$mainDir."\\.\\".$subDir,
36  "$absSubDir\\..\\\\\\".$subDir."\\\\..\\\\..\\".$subDir,
37  "$absSubDir\\BADDIR",
38
39  // relative paths
40  $mainDir."\\".$subDir,
41  $mainDir."\\\\".$subDir,
42   $mainDir."\\\\\\".$subDir,
43  ".\\".$mainDir."\\..\\".$mainDir."\\".$subDir,
44  "BADDIR",
45
46  // unixifed path
47  $unixifiedDir,
48);
49
50$filename = 'parseIniFileVar私はガラスを食べられます.ini';
51$content="a=test";
52$absFile = $absSubDir.'/'.$filename;
53$h = fopen($absFile,"w");
54fwrite($h, $content);
55fclose($h);
56
57for($i = 0; $i<count($allDirs); $i++) {
58  $j = $i+1;
59  $dir = $allDirs[$i];
60  echo "\n-- Iteration $j --\n";
61  var_dump(parse_ini_file($dir."\\".$filename));
62}
63
64unlink($absFile);
65chdir($old_dir_path);
66rmdir($absSubDir);
67rmdir($absMainDir);
68
69echo "\n*** Done ***\n";
70?>
71--EXPECTF--
72*** Testing parse_ini_file() : variation ***
73
74-- Iteration 1 --
75array(1) {
76  ["a"]=>
77  string(4) "test"
78}
79
80-- Iteration 2 --
81array(1) {
82  ["a"]=>
83  string(4) "test"
84}
85
86-- Iteration 3 --
87array(1) {
88  ["a"]=>
89  string(4) "test"
90}
91
92-- Iteration 4 --
93array(1) {
94  ["a"]=>
95  string(4) "test"
96}
97
98-- Iteration 5 --
99
100Warning: parse_ini_file(%sparseIniFileVar私はガラスを食べられます.dir\parseIniFileVar私はガラスを食べられますSub\..\\\parseIniFileVar私はガラスを食べられますSub\\..\\..\parseIniFileVar私はガラスを食べられますSub\parseIniFileVar私はガラスを食べられます.ini): failed to open stream: No such file or directory in %s on line %d
101bool(false)
102
103-- Iteration 6 --
104
105Warning: parse_ini_file(%sparseIniFileVar私はガラスを食べられます.dir\parseIniFileVar私はガラスを食べられますSub\BADDIR\parseIniFileVar私はガラスを食べられます.ini): failed to open stream: No such file or directory in %s on line %d
106bool(false)
107
108-- Iteration 7 --
109array(1) {
110  ["a"]=>
111  string(4) "test"
112}
113
114-- Iteration 8 --
115array(1) {
116  ["a"]=>
117  string(4) "test"
118}
119
120-- Iteration 9 --
121array(1) {
122  ["a"]=>
123  string(4) "test"
124}
125
126-- Iteration 10 --
127array(1) {
128  ["a"]=>
129  string(4) "test"
130}
131
132-- Iteration 11 --
133
134Warning: parse_ini_file(BADDIR\parseIniFileVar私はガラスを食べられます.ini): failed to open stream: No such file or directory in %s on line %d
135bool(false)
136
137-- Iteration 12 --
138array(1) {
139  ["a"]=>
140  string(4) "test"
141}
142
143*** Done ***
144