Skip to content

Commit 2cd4fd8

Browse files
[8.x] Allow a specific seeder to be used in tests (#35864)
* Allow a specific seeder to be used in tests * if $seeder is set within a test use it instead of the default. * Update RefreshDatabase.php Co-authored-by: Taylor Otwell <[email protected]>
1 parent 5c70991 commit 2cd4fd8

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/Illuminate/Foundation/Testing/RefreshDatabase.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,15 @@ protected function refreshTestDatabase()
7979
*/
8080
protected function migrateFreshUsing()
8181
{
82-
return [
83-
'--drop-views' => $this->shouldDropViews(),
84-
'--drop-types' => $this->shouldDropTypes(),
85-
'--seed' => $this->shouldSeed(),
86-
];
82+
$seeder = $this->seeder();
83+
84+
return array_merge(
85+
[
86+
'--drop-views' => $this->shouldDropViews(),
87+
'--drop-types' => $this->shouldDropTypes(),
88+
],
89+
$seeder ? ['--seeder' => $seeder] : ['--seed' => $this->shouldSeed()]
90+
);
8791
}
8892

8993
/**
@@ -157,4 +161,14 @@ protected function shouldSeed()
157161
{
158162
return property_exists($this, 'seed') ? $this->seed : false;
159163
}
164+
165+
/**
166+
* Determine the specific seeder class that should be used when refreshing the database.
167+
*
168+
* @return mixed
169+
*/
170+
protected function seeder()
171+
{
172+
return property_exists($this, 'seeder') ? $this->seeder : false;
173+
}
160174
}

0 commit comments

Comments
 (0)