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

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

merged 2 commits into from Jan 13, 2021

Conversation

patrickomeara
Copy link
Contributor

It is quite common to have a seeder filled with dummy data that makes the developer experience closer to the production app, and a separate test suite seeder that provides the basics needed to get the app started; languages, permissions levels, oauth apps etc.

This PR enables the developer to specify a seeder to be used in the RefreshDatabase trait.

class TasksApiTest extends TestCase 
{
    use RefreshDatabase;

    protected $seeder = TestSuiteSeeder::class;

    // ...
}

* if $seeder is set within a test use it instead of the default.
@GrahamCampbell GrahamCampbell changed the title Allow a specific seeder to be used in tests [8.x] \Allow a specific seeder to be used in tests Jan 13, 2021
@GrahamCampbell GrahamCampbell changed the title [8.x] \Allow a specific seeder to be used in tests [8.x] Allow a specific seeder to be used in tests Jan 13, 2021
@taylorotwell taylorotwell merged commit 2cd4fd8 into laravel:8.x Jan 13, 2021
@driesvints
Copy link
Member

@patrickomeara thanks. Can you send in a PR to the docs as well?

@jasonmccreary
Copy link
Contributor

jasonmccreary commented Jan 19, 2021

I wonder if $seeders = [...] would have been more robust. While I appreciate you could make a seeder which runs the necessary seeders, keeping them separate provides greater flexibility through combination.

@driesvints
Copy link
Member

@jasonmccreary the FreshCommand only allows for one seeder atm

@jasonmccreary
Copy link
Contributor

I see. My bad. I didn't really look at the internals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants