diff --git a/src/Illuminate/Foundation/Testing/CachedState.php b/src/Illuminate/Foundation/Testing/CachedState.php index 4ecb14cbb9b0..79d333c0d3ef 100644 --- a/src/Illuminate/Foundation/Testing/CachedState.php +++ b/src/Illuminate/Foundation/Testing/CachedState.php @@ -4,6 +4,6 @@ class CachedState { - public static array $cachedRoutes; - public static array $cachedConfig; + public static ?array $cachedRoutes = null; + public static ?array $cachedConfig = null; } diff --git a/src/Illuminate/Foundation/Testing/WithCachedConfig.php b/src/Illuminate/Foundation/Testing/WithCachedConfig.php index e1ed65a8da7d..342af1fa6e81 100644 --- a/src/Illuminate/Foundation/Testing/WithCachedConfig.php +++ b/src/Illuminate/Foundation/Testing/WithCachedConfig.php @@ -38,4 +38,19 @@ protected function markConfigCached(Application $app): void LoadConfiguration::alwaysUse(static fn () => CachedState::$cachedConfig); } + + /** + * Disable the configuration cache for the current test. + * + * @return $this + */ + protected function disableConfigCache() + { + $this->app->instance('config_loaded_from_cache', false); + + CachedState::$cachedConfig = null; + LoadConfiguration::alwaysUse(null); + + return $this; + } }