Fix reading .env file

This commit is contained in:
Pig Fang 2018-10-19 21:43:25 +08:00
parent 12539d5f9d
commit 1e120d3ec7
2 changed files with 4 additions and 4 deletions

View File

@ -41,7 +41,7 @@ class SetupController extends Controller
);
}
$content = File::get('.env');
$content = File::get('..' . DIRECTORY_SEPARATOR . '.env');
$content = str_replace(
'DB_CONNECTION = '.env('DB_CONNECTION'),
'DB_CONNECTION = '.$request->input('type'),
@ -77,7 +77,7 @@ class SetupController extends Controller
'DB_PREFIX = '.$request->input('prefix'),
$content
);
File::put('.env', $content);
File::put('..' . DIRECTORY_SEPARATOR . '.env', $content);
return redirect('setup/info');
}

View File

@ -59,8 +59,8 @@ class SetupControllerTest extends TestCase
'password' => env('DB_PASSWORD'),
'prefix' => '',
];
File::shouldReceive('get')->with('.env')->andReturn('');
File::shouldReceive('put')->with('.env', '');
File::shouldReceive('get')->with('..' . DIRECTORY_SEPARATOR . '.env')->andReturn('');
File::shouldReceive('put')->with('..' . DIRECTORY_SEPARATOR . '.env', '');
$this->post('/setup/database', $fake)->assertRedirect('/setup/info');
}