Skip to content

Commit

Permalink
Added documentation for a specific seeder in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickomeara committed Jan 15, 2021
1 parent 9a08e72 commit 3caf2ef
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions database-testing.md
Expand Up @@ -520,9 +520,9 @@ If you would like to use [database seeders](/docs/{{version}}/seeding) to popula

namespace Tests\Feature;

use Database\Seeders\OrderStatusSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use OrderStatusSeeder;
use Tests\TestCase;

class ExampleTest extends TestCase
Expand All @@ -546,24 +546,32 @@ If you would like to use [database seeders](/docs/{{version}}/seeding) to popula
}
}

Alternatively, you may instruct the `RefreshDatabase` trait to automatically seed the database before each test. You may accomplish this by defining a `$seed` property on your test class:
Alternatively, you may instruct the `RefreshDatabase` trait to automatically seed the database before each test. You may accomplish this by defining a `$seed` property on your test class, or use a specific seeder using the `$seeder` property:

<?php

namespace Tests\Feature;

use Database\Seeders\OrderStatusSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class ExampleTest extends TestCase
{
/**
* Indicates whether the database should be seeded before each test.
* Indicates whether the default seeder should run before each test.
*
* @var bool
*/
protected $seed = true;

/**
* Run a specific seeder before each test.
*
* @var string
*/
protected $seeder = OrderStatusSeeder::class;

// ...
}

Expand Down

0 comments on commit 3caf2ef

Please sign in to comment.