Skip to content

Commit

Permalink
flush middleware callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 13, 2023
1 parent d97b526 commit bb49a72
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,14 @@ public static function skipWhen(Closure $callback)
{
static::$skipCallbacks[] = $callback;
}

/**
* Flush the middleware's global state.
*
* @return void
*/
public static function flushState()
{
static::$skipCallbacks = [];
}
}
10 changes: 10 additions & 0 deletions src/Illuminate/Foundation/Http/Middleware/TrimStrings.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,14 @@ public static function skipWhen(Closure $callback)
{
static::$skipCallbacks[] = $callback;
}

/**
* Flush the middleware's global state.
*
* @return void
*/
public static function flushState()
{
static::$skipCallbacks = [];
}
}
6 changes: 5 additions & 1 deletion src/Illuminate/Foundation/Testing/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Illuminate\Console\Application as Artisan;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Bootstrap\HandleExceptions;
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
use Illuminate\Foundation\Http\Middleware\TrimStrings;
use Illuminate\Queue\Queue;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Facade;
Expand Down Expand Up @@ -244,9 +246,11 @@ protected function tearDown(): void
Component::flushCache();
Component::forgetComponentsResolver();
Component::forgetFactory();
Queue::createPayloadUsing(null);
ConvertEmptyStringsToNull::flushState();
HandleExceptions::forgetApp();
Queue::createPayloadUsing(null);
Sleep::fake(false);
TrimStrings::flushState();

if ($this->callbackException) {
throw $this->callbackException;
Expand Down

0 comments on commit bb49a72

Please sign in to comment.