Skip to content

Commit

Permalink
[11.x] Flush RegisterProviders bootstrapper state between tests (#4…
Browse files Browse the repository at this point in the history
…9719)

* [11.x] Flush `RegisterProviders` bootstrapper state between tests.

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* Update RegisterProviders.php

* Update TestCase.php

---------

Signed-off-by: Mior Muhammad Zaki <[email protected]>
Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
crynobone and taylorotwell authored Jan 17, 2024
1 parent f630b39 commit 53e3246
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Illuminate/Foundation/Bootstrap/RegisterProviders.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,16 @@ public static function merge(array $providers, ?string $bootstrapProviderPath =
array_merge(static::$merge, $providers)
)));
}

/**
* Flush the bootstrapper's global state.
*
* @return void
*/
public static function flushState()
{
static::$bootstrapProviderPath = null;

static::$merge = [];
}
}
2 changes: 2 additions & 0 deletions src/Illuminate/Foundation/Testing/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Bootstrap\HandleExceptions;
use Illuminate\Foundation\Bootstrap\RegisterProviders;
use Illuminate\Foundation\Console\AboutCommand;
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
use Illuminate\Foundation\Http\Middleware\TrimStrings;
Expand Down Expand Up @@ -248,6 +249,7 @@ protected function tearDown(): void
ConvertEmptyStringsToNull::flushState();
HandleExceptions::flushState();
Queue::createPayloadUsing(null);
RegisterProviders::flushState();
Sleep::fake(false);
TrimStrings::flushState();

Expand Down

0 comments on commit 53e3246

Please sign in to comment.