From 413d10b59a8ecee5e9e7a291087991dd0bc0c8ef Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 25 Mar 2024 08:58:45 +0800 Subject: [PATCH] wip Signed-off-by: Mior Muhammad Zaki --- src/Concerns/InteractsWithMigrations.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Concerns/InteractsWithMigrations.php b/src/Concerns/InteractsWithMigrations.php index 63ebe9378..6cd5a0db9 100644 --- a/src/Concerns/InteractsWithMigrations.php +++ b/src/Concerns/InteractsWithMigrations.php @@ -24,6 +24,20 @@ trait InteractsWithMigrations */ protected $cachedTestSchemaMigrators = []; + /** + * Setup the test environment. + * + * @return void + */ + protected function setUpInteractsWithMigrations(): void + { + $this->afterApplicationCreated(function () { + if (static::usesSqliteInMemoryDatabaseConnection()) { + static::usesTestingFeature(new ResetRefreshDatabaseState()); + } + }); + } + /** * Teardown the test environment. * @@ -31,10 +45,7 @@ trait InteractsWithMigrations */ protected function tearDownInteractsWithMigrations(): void { - if ( - \count($this->cachedTestSchemaMigrators) > 0 - && (static::usesRefreshDatabaseTestingConcern() || static::usesSqliteInMemoryDatabaseConnection()) - ) { + if (\count($this->cachedTestSchemaMigrators) > 0 && static::usesRefreshDatabaseTestingConcern()) { ResetRefreshDatabaseState::run(); }