From 895d7bb542a18d4e29a44d5c869237d69d3b28d9 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Mon, 15 May 2023 08:11:58 -0500 Subject: [PATCH] Clears resolve instances of Vite when using `withoutVite` --- .../Concerns/InteractsWithContainer.php | 3 +++ tests/Integration/Testing/TestCaseTest.php | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/Integration/Testing/TestCaseTest.php diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php index b19a57124489..49b688cf200f 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php @@ -5,6 +5,7 @@ use Closure; use Illuminate\Foundation\Mix; use Illuminate\Foundation\Vite; +use Illuminate\Support\Facades\Facade; use Illuminate\Support\HtmlString; use Mockery; @@ -110,6 +111,8 @@ protected function withoutVite() $this->originalVite = app(Vite::class); } + Facade::clearResolvedInstance(Vite::class); + $this->swap(Vite::class, new class { public function __invoke() diff --git a/tests/Integration/Testing/TestCaseTest.php b/tests/Integration/Testing/TestCaseTest.php new file mode 100644 index 000000000000..b6886cf49c52 --- /dev/null +++ b/tests/Integration/Testing/TestCaseTest.php @@ -0,0 +1,20 @@ + 'anonymous', + ]); + + $this->withoutVite(); + + Vite::asset('foo.png'); + } +}