From d8aa393b52bcfac195f12f85486f791f0b85a5ea Mon Sep 17 00:00:00 2001 From: Luca Longo Date: Tue, 25 Aug 2020 15:36:04 +0200 Subject: [PATCH 1/2] Migration commands parameters moved to methods --- .../Foundation/Testing/RefreshDatabase.php | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Foundation/Testing/RefreshDatabase.php b/src/Illuminate/Foundation/Testing/RefreshDatabase.php index e968ad90c9ac..94eb16d089d0 100644 --- a/src/Illuminate/Foundation/Testing/RefreshDatabase.php +++ b/src/Illuminate/Foundation/Testing/RefreshDatabase.php @@ -30,6 +30,16 @@ protected function usingInMemoryDatabase() return config("database.connections.$default.database") === ':memory:'; } + /** + * Parameters used on refresh in-memory database. + * + * @return array + */ + protected function migrateCommandParameters() + { + return [ ]; + } + /** * Refresh the in-memory database. * @@ -37,11 +47,24 @@ protected function usingInMemoryDatabase() */ protected function refreshInMemoryDatabase() { - $this->artisan('migrate'); + $this->artisan('migrate', $this->migrateCommandParameters()); $this->app[Kernel::class]->setArtisan(null); } + /** + * Parameters used on migrate fresh conventional database + * + * @return array + */ + protected function migrateFreshCommandParameters() + { + return [ + '--drop-views' => $this->shouldDropViews(), + '--drop-types' => $this->shouldDropTypes(), + ]; + } + /** * Refresh a conventional test database. * @@ -50,10 +73,7 @@ protected function refreshInMemoryDatabase() protected function refreshTestDatabase() { if (! RefreshDatabaseState::$migrated) { - $this->artisan('migrate:fresh', [ - '--drop-views' => $this->shouldDropViews(), - '--drop-types' => $this->shouldDropTypes(), - ]); + $this->artisan('migrate:fresh', $this->migrateFreshCommandParameters()); $this->app[Kernel::class]->setArtisan(null); From 623dccb6216f3da2a1ae1fa47aab768a47db4251 Mon Sep 17 00:00:00 2001 From: Luca Longo Date: Tue, 25 Aug 2020 15:42:45 +0200 Subject: [PATCH 2/2] Style fix --- src/Illuminate/Foundation/Testing/RefreshDatabase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Testing/RefreshDatabase.php b/src/Illuminate/Foundation/Testing/RefreshDatabase.php index 94eb16d089d0..dac1de0701bf 100644 --- a/src/Illuminate/Foundation/Testing/RefreshDatabase.php +++ b/src/Illuminate/Foundation/Testing/RefreshDatabase.php @@ -37,7 +37,7 @@ protected function usingInMemoryDatabase() */ protected function migrateCommandParameters() { - return [ ]; + return []; } /** @@ -53,7 +53,7 @@ protected function refreshInMemoryDatabase() } /** - * Parameters used on migrate fresh conventional database + * Parameters used on migrate fresh conventional database. * * @return array */