Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Nov 28, 2023
1 parent 597c515 commit 41ddc98
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions src/Illuminate/Foundation/Testing/DatabaseMigrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,46 @@ trait DatabaseMigrations
*/
public function runDatabaseMigrations()
{
$this->artisan('migrate:fresh', $this->migrateFreshUsing());

$this->app[Kernel::class]->setArtisan(null);
$this->beforeRefreshingDatabase();
$this->refreshTestDatabase();
$this->afterRefreshingDatabase();

$this->beforeApplicationDestroyed(function () {
$this->artisan('migrate:rollback');

RefreshDatabaseState::$migrated = false;
});
}

/**
* Refresh a conventional test database.
*
* @return void
*/
protected function refreshTestDatabase()
{
$this->artisan('migrate:fresh', $this->migrateFreshUsing());

$this->app[Kernel::class]->setArtisan(null);
}

/**
* Perform any work that should take place before the database has started refreshing.
*
* @return void
*/
protected function beforeRefreshingDatabase()
{
// ...
}

/**
* Perform any work that should take place once the database has finished refreshing.
*
* @return void
*/
protected function afterRefreshingDatabase()
{
// ...
}
}

0 comments on commit 41ddc98

Please sign in to comment.