Skip to content

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.

4 participants