Skip to content

Commit

Permalink
re-refresh database if transaction has been committed (#53997)
Browse files Browse the repository at this point in the history
  • Loading branch information
SjorsO authored Dec 26, 2024
1 parent f826d0f commit 8636996
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Illuminate/Foundation/Testing/RefreshDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ public function beginDatabaseTransaction()
$dispatcher = $connection->getEventDispatcher();

$connection->unsetEventDispatcher();

if (! $connection->getPdo()->inTransaction()) {
RefreshDatabaseState::$migrated = false;
}

$connection->rollBack();
$connection->setEventDispatcher($dispatcher);
$connection->disconnect();
Expand Down

2 comments on commit 8636996

@trovster
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My test suite runtime has changed from ~10 minutes to over 25 minutes between v11.36.1 and v11.37. I assume it is because of this change…

@troccoli
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask why was this change introduced?

A test of mine is now failing because the database does not exist (which is what I am testing) and the tearDown process throws a SQLiteDatabaseDoesNotExistException exception.

To be clear, my test does not fail, i.e. my code works correctly when the database does not exist. But the test fails because an exception is thrown.

Please sign in to comment.