File tree 2 files changed +26
-3
lines changed
src/Symfony/Component/Dotenv
2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -45,10 +45,11 @@ final class Dotenv
45
45
* @throws FormatException when a file has a syntax error
46
46
* @throws PathException when a file does not exist or is not readable
47
47
*/
48
- public function load ($ path/* , ...$paths*/ )
48
+ public function load ($ path , ...$ paths )
49
49
{
50
- // func_get_args() to be replaced by a variadic argument for Symfony 4.0
51
- foreach (func_get_args () as $ path ) {
50
+ array_unshift ($ paths , $ path );
51
+
52
+ foreach ($ paths as $ path ) {
52
53
if (!is_readable ($ path ) || is_dir ($ path )) {
53
54
throw new PathException ($ path );
54
55
}
Original file line number Diff line number Diff line change @@ -155,6 +155,28 @@ public function testLoadDirectory()
155
155
$ dotenv ->load (__DIR__ );
156
156
}
157
157
158
+ public function testLoad ()
159
+ {
160
+ @mkdir ($ tmpdir = sys_get_temp_dir ().'/dotenv ' );
161
+
162
+ $ path1 = tempnam ($ tmpdir , 'sf- ' );
163
+ $ path2 = tempnam ($ tmpdir , 'sf- ' );
164
+
165
+ file_put_contents ($ path1 , 'FOO=BAR ' );
166
+ file_put_contents ($ path2 , 'BAR=BAZ ' );
167
+
168
+ (new DotEnv ())->load ($ path1 , $ path2 );
169
+
170
+ $ this ->assertSame ('BAR ' , getenv ('FOO ' ));
171
+ $ this ->assertSame ('BAZ ' , getenv ('BAR ' ));
172
+
173
+ putenv ('FOO ' );
174
+ putenv ('BAR ' );
175
+ unlink ($ path1 );
176
+ unlink ($ path2 );
177
+ rmdir ($ tmpdir );
178
+ }
179
+
158
180
public function testServerSuperglobalIsNotOverriden ()
159
181
{
160
182
$ originalValue = $ _SERVER ['argc ' ];
You can’t perform that action at this time.
0 commit comments