Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] RefreshDatabase migration commands parameters moved to methods #34007

Merged
merged 2 commits into from Aug 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 25 additions & 5 deletions src/Illuminate/Foundation/Testing/RefreshDatabase.php
Expand Up @@ -30,18 +30,41 @@ 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.
*
* @return void
*/
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.
*
Expand All @@ -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);

Expand Down