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

[8.x] Allow a specific seeder to be used in tests #35864

Merged
merged 2 commits into from Jan 13, 2021
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
24 changes: 19 additions & 5 deletions src/Illuminate/Foundation/Testing/RefreshDatabase.php
Expand Up @@ -79,11 +79,15 @@ protected function refreshTestDatabase()
*/
protected function migrateFreshUsing()
{
return [
'--drop-views' => $this->shouldDropViews(),
'--drop-types' => $this->shouldDropTypes(),
'--seed' => $this->shouldSeed(),
];
$seeder = $this->seeder();

return array_merge(
[
'--drop-views' => $this->shouldDropViews(),
'--drop-types' => $this->shouldDropTypes(),
],
$seeder ? ['--seeder' => $seeder] : ['--seed' => $this->shouldSeed()]
);
}

/**
Expand Down Expand Up @@ -157,4 +161,14 @@ protected function shouldSeed()
{
return property_exists($this, 'seed') ? $this->seed : false;
}

/**
* Determine the specific seeder class that should be used when refreshing the database.
*
* @return mixed
*/
protected function seeder()
{
return property_exists($this, 'seeder') ? $this->seeder : false;
}
}