Skip to content

Commit ec5a083

Browse files
committed
Add before/after database truncation methods to DatabaseTruncation trait
1 parent 00894b8 commit ec5a083

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/Illuminate/Foundation/Testing/DatabaseTruncation.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ trait DatabaseTruncation
2424
*/
2525
protected function truncateDatabaseTables(): void
2626
{
27+
$this->beforeTruncatingDatabase();
28+
2729
// Migrate and seed the database on first run...
2830
if (! RefreshDatabaseState::$migrated) {
2931
$this->artisan('migrate:fresh', $this->migrateFreshUsing());
@@ -45,6 +47,8 @@ protected function truncateDatabaseTables(): void
4547
// Use the default seeder class...
4648
$this->artisan('db:seed');
4749
}
50+
51+
$this->afterTruncatingDatabase();
4852
}
4953

5054
/**
@@ -144,4 +148,24 @@ protected function exceptTables(?string $connectionName): array
144148

145149
return [$this->app['config']->get('database.migrations')];
146150
}
151+
152+
/**
153+
* Perform any work that should take place before the database has started truncating.
154+
*
155+
* @return void
156+
*/
157+
protected function beforeTruncatingDatabase(): void
158+
{
159+
//
160+
}
161+
162+
/**
163+
* Perform any work that should take place once the database has finished truncating.
164+
*
165+
* @return void
166+
*/
167+
protected function afterTruncatingDatabase(): void
168+
{
169+
//
170+
}
147171
}

0 commit comments

Comments
 (0)