diff --git a/src/Illuminate/Foundation/Testing/DatabaseTruncation.php b/src/Illuminate/Foundation/Testing/DatabaseTruncation.php index 811b56e20952..cea2d8d09250 100644 --- a/src/Illuminate/Foundation/Testing/DatabaseTruncation.php +++ b/src/Illuminate/Foundation/Testing/DatabaseTruncation.php @@ -24,6 +24,8 @@ trait DatabaseTruncation */ protected function truncateDatabaseTables(): void { + $this->beforeTruncatingDatabase(); + // Migrate and seed the database on first run... if (! RefreshDatabaseState::$migrated) { $this->artisan('migrate:fresh', $this->migrateFreshUsing()); @@ -45,6 +47,8 @@ protected function truncateDatabaseTables(): void // Use the default seeder class... $this->artisan('db:seed'); } + + $this->afterTruncatingDatabase(); } /** @@ -144,4 +148,24 @@ protected function exceptTables(?string $connectionName): array return [$this->app['config']->get('database.migrations')]; } + + /** + * Perform any work that should take place before the database has started truncating. + * + * @return void + */ + protected function beforeTruncatingDatabase(): void + { + // + } + + /** + * Perform any work that should take place once the database has finished truncating. + * + * @return void + */ + protected function afterTruncatingDatabase(): void + { + // + } }