/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
src/Illuminate/Foundation/Testing/LazilyRefreshDatabase.php
49 строк
1 KB
Džuris
[13.x] Register the lazy refresh hook on all connections (#60359)
03 июн 2026, 04:35
Не верифицирован
03 июн 2026, 04:35
2456501
Код
Авторство
О чём код?
<?php namespace Illuminate\Foundation\Testing; trait LazilyRefreshDatabase { use RefreshDatabase { refreshDatabase as baseRefreshDatabase; } /** * Define hooks to migrate the database before and after each test. * * @return void */ public function refreshDatabase() { $database = $this->app->make('db'); $callback = function () { if (RefreshDatabaseState::$lazilyRefreshed) { return; } RefreshDatabaseState::$lazilyRefreshed = true; if (property_exists($this, 'mockConsoleOutput')) { $shouldMockOutput = $this->mockConsoleOutput; $this->mockConsoleOutput = false; } $this->baseRefreshDatabase(); if (property_exists($this, 'mockConsoleOutput')) { $this->mockConsoleOutput = $shouldMockOutput; } }; foreach ($this->connectionsToTransact() as $connection) { $database->connection($connection)->beforeStartingTransaction($callback); $database->connection($connection)->beforeExecuting($callback); } $this->beforeApplicationDestroyed(function () { RefreshDatabaseState::$lazilyRefreshed = false; }); } }