@@ -109,7 +109,13 @@ public function testFindWithOpenBaseDir()
109
109
$ this ->markTestSkipped ('Cannot test when open_basedir is set ' );
110
110
}
111
111
112
- $ initialOpenBaseDir = ini_set ('open_basedir ' , \dirname (\PHP_BINARY ).\PATH_SEPARATOR .'/ ' );
112
+ $ openBaseDir = \dirname (\PHP_BINARY ).\PATH_SEPARATOR .sys_get_temp_dir ().\PATH_SEPARATOR .getcwd ();
113
+
114
+ if ($ _SERVER ['SYMFONY_PHPUNIT_DIR ' ] ?? null ) {
115
+ $ openBaseDir .= \PATH_SEPARATOR .$ _SERVER ['SYMFONY_PHPUNIT_DIR ' ];
116
+ }
117
+
118
+ $ initialOpenBaseDir = ini_set ('open_basedir ' , $ openBaseDir );
113
119
114
120
try {
115
121
$ finder = new ExecutableFinder ();
@@ -121,6 +127,38 @@ public function testFindWithOpenBaseDir()
121
127
}
122
128
}
123
129
130
+ /**
131
+ * @runInSeparateProcess
132
+ */
133
+ public function testFindWithSubdirectoryOfOpenBaseDir ()
134
+ {
135
+ if (\ini_get ('open_basedir ' )) {
136
+ $ this ->markTestSkipped ('Cannot test when open_basedir is set ' );
137
+ }
138
+
139
+ $ paths = explode (\PATH_SEPARATOR , getenv ('PATH ' ));
140
+ $ phpBinaryPath = \dirname (\PHP_BINARY );
141
+
142
+ if (!in_array ($ phpBinaryPath , $ paths , true )) {
143
+ $ paths [] = $ phpBinaryPath ;
144
+ }
145
+
146
+ $ this ->setPath (implode (\PATH_SEPARATOR , $ paths ));
147
+
148
+ $ openBaseDir = \dirname (\dirname (\PHP_BINARY )).\PATH_SEPARATOR .sys_get_temp_dir ().\PATH_SEPARATOR .getcwd ();
149
+
150
+ if ($ _SERVER ['SYMFONY_PHPUNIT_DIR ' ] ?? null ) {
151
+ $ openBaseDir .= \PATH_SEPARATOR .$ _SERVER ['SYMFONY_PHPUNIT_DIR ' ];
152
+ }
153
+
154
+ ini_set ('open_basedir ' , $ openBaseDir );
155
+
156
+ $ finder = new ExecutableFinder ();
157
+ $ result = $ finder ->find ($ this ->getPhpBinaryName ());
158
+
159
+ $ this ->assertSamePath (\PHP_BINARY , $ result );
160
+ }
161
+
124
162
/**
125
163
* @runInSeparateProcess
126
164
*/
0 commit comments