mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-02-23 14:59:07 +08:00
Skip database page if config ok (fixes #25)
This commit is contained in:
parent
36f2e86a42
commit
34441f587e
@ -18,6 +18,15 @@ class SetupController extends Controller
|
||||
{
|
||||
public function database(Request $request)
|
||||
{
|
||||
if ($request->isMethod('get')) {
|
||||
try {
|
||||
DB::getPdo();
|
||||
return redirect('setup/info');
|
||||
} catch (\Exception $e) {
|
||||
return view('setup.wizard.database');
|
||||
}
|
||||
}
|
||||
|
||||
config([
|
||||
'database.connections.temp.driver' => $request->input('type'),
|
||||
'database.connections.temp.host' => $request->input('host'),
|
||||
@ -273,7 +282,7 @@ class SetupController extends Controller
|
||||
}
|
||||
|
||||
if (count($existingTables) == count($tables)) {
|
||||
return true;
|
||||
return $returnExistingTables ? $existingTables : true;
|
||||
} else {
|
||||
return $returnExistingTables ? $existingTables : false;
|
||||
}
|
||||
|
@ -17,8 +17,7 @@
|
||||
Route::group(['prefix' => 'setup'], function () {
|
||||
Route::group(['middleware' => 'setup'], function () {
|
||||
Route::view('/', 'setup.wizard.welcome');
|
||||
Route::view('/database', 'setup.wizard.database');
|
||||
Route::post('/database', 'SetupController@database');
|
||||
Route::any('/database', 'SetupController@database');
|
||||
Route::get('/info', 'SetupController@info');
|
||||
Route::post('/finish', 'SetupController@finish');
|
||||
});
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use DB;
|
||||
use Mockery;
|
||||
use Exception;
|
||||
use CreateAllTables;
|
||||
@ -61,6 +62,11 @@ class SetupControllerTest extends TestCase
|
||||
File::shouldReceive('get')->with('..'.DIRECTORY_SEPARATOR.'.env')->andReturn('');
|
||||
File::shouldReceive('put')->with('..'.DIRECTORY_SEPARATOR.'.env', '');
|
||||
$this->post('/setup/database', $fake)->assertRedirect('/setup/info');
|
||||
|
||||
$this->get('/setup/database')->assertRedirect('/setup/info');
|
||||
DB::shouldReceive('getPdo')->andThrow(new Exception());
|
||||
DB::shouldReceive('disconnect')->andReturn(true);
|
||||
$this->get('/setup/database')->assertViewIs('setup.wizard.database');
|
||||
}
|
||||
|
||||
public function testReportDatabaseConnectionError()
|
||||
|
Loading…
Reference in New Issue
Block a user