diff --git a/src/Illuminate/Foundation/Testing/RefreshDatabase.php b/src/Illuminate/Foundation/Testing/RefreshDatabase.php index f039c510f8c2..f70cdbd2809c 100644 --- a/src/Illuminate/Foundation/Testing/RefreshDatabase.php +++ b/src/Illuminate/Foundation/Testing/RefreshDatabase.php @@ -85,12 +85,31 @@ protected function refreshTestDatabase() $this->app[Kernel::class]->setArtisan(null); + $this->updateInMemoryConnections(); + RefreshDatabaseState::$migrated = true; } $this->beginDatabaseTransaction(); } + /** + * Update stored in-memory PDO connections after migration. + * + * @return void + */ + protected function updateInMemoryConnections() + { + $database = $this->app->make('db'); + + foreach ($this->connectionsToTransact() as $name) { + if ($this->usingInMemoryDatabase($name)) { + $connection = $database->connection($name); + RefreshDatabaseState::$inMemoryConnections[$name] = $connection->getPdo(); + } + } + } + /** * Migrate the database. *