@@ -29,9 +29,9 @@ public function testFileIsCreated()
2929 @unlink ($ envLocal );
3030
3131 $ envContent = <<<EOF
32- APP_ENV=dev
33- APP_SECRET=abcdefgh123456789
34- EOF ;
32+ APP_ENV=dev
33+ APP_SECRET=abcdefgh123456789
34+ EOF ;
3535 file_put_contents ($ env , $ envContent );
3636
3737 $ command = $ this ->createCommandDumpEnv ();
@@ -60,9 +60,9 @@ public function testEmptyOptionMustIgnoreContent()
6060 @unlink ($ envLocal );
6161
6262 $ envContent = <<<EOF
63- APP_ENV=dev
64- APP_SECRET=abcdefgh123456789
65- EOF ;
63+ APP_ENV=dev
64+ APP_SECRET=abcdefgh123456789
65+ EOF ;
6666 file_put_contents ($ env , $ envContent );
6767
6868 $ command = $ this ->createCommandDumpEnv ();
@@ -94,9 +94,9 @@ public function testEnvCanBeReferenced()
9494 @unlink ($ envLocal );
9595
9696 $ envContent = <<<'EOF'
97- BAR=$FOO
98- FOO=123
99- EOF;
97+ BAR=$FOO
98+ FOO=123
99+ EOF;
100100 file_put_contents ($ env , $ envContent );
101101
102102 $ _SERVER ['FOO ' ] = 'Foo ' ;
@@ -179,9 +179,9 @@ public function testLoadLocalEnvWhenTestEnvIsNotEqual()
179179
180180 file_put_contents ($ env , 'APP_ENV=dev ' );
181181 file_put_contents ($ envLocal , <<<EOF
182- APP_ENV=test
183- APP_SECRET=abcdefgh123456789
184- EOF
182+ APP_ENV=test
183+ APP_SECRET=abcdefgh123456789
184+ EOF
185185 );
186186
187187 $ command = $ this ->createCommandDumpEnv (['runtime ' => ['test_envs ' => []]]);
@@ -202,6 +202,39 @@ public function testLoadLocalEnvWhenTestEnvIsNotEqual()
202202 unlink ($ envLocalPhp );
203203 }
204204
205+ public function testEnvVarReferenceInDumpedFile ()
206+ {
207+ @mkdir (FLEX_TEST_DIR );
208+ $ env = FLEX_TEST_DIR .'/.env ' ;
209+ $ envLocal = FLEX_TEST_DIR .'/.env.local.php ' ;
210+
211+ @unlink ($ env );
212+ @unlink ($ envLocal );
213+
214+ $ envContent = <<<'EOF'
215+ APP_ENV=prod
216+ APP_SHARE_DIR=$APP_PROJECT_DIR/var/share
217+ EOF;
218+ file_put_contents ($ env , $ envContent );
219+
220+ $ command = $ this ->createCommandDumpEnv ();
221+ $ command ->execute (['env ' => 'prod ' ]);
222+
223+ $ dumpedContent = file_get_contents ($ envLocal );
224+ $ this ->assertStringContainsString ("\$_ENV['APP_PROJECT_DIR'] " , $ dumpedContent );
225+ $ this ->assertStringContainsString ("\$_SERVER['APP_PROJECT_DIR'] " , $ dumpedContent );
226+
227+ $ _ENV ['APP_PROJECT_DIR ' ] = '/path/to/project ' ;
228+ $ vars = require $ envLocal ;
229+ $ this ->assertSame ([
230+ 'APP_ENV ' => 'prod ' ,
231+ 'APP_SHARE_DIR ' => '/path/to/project/var/share ' ,
232+ ], $ vars );
233+
234+ unlink ($ env );
235+ unlink ($ envLocal );
236+ }
237+
205238 private function createCommandDumpEnv (array $ options = [])
206239 {
207240 $ command = new DumpEnvCommand (
0 commit comments