Skip to content

Commit

Permalink
Clears resolve instances of Vite when using withoutVite (#47091)
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro authored May 15, 2023
1 parent 3dfe181 commit 89e549d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()
Expand Down
20 changes: 20 additions & 0 deletions tests/Integration/Testing/TestCaseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Illuminate\Tests\Integration\Testing;

use Illuminate\Support\Facades\Vite;
use Orchestra\Testbench\TestCase;

class TestCaseTest extends TestCase
{
public function test_without_vite_clear_facade_resolved_instance()
{
Vite::useScriptTagAttributes([
'crossorigin' => 'anonymous',
]);

$this->withoutVite();

Vite::asset('foo.png');
}
}

0 comments on commit 89e549d

Please sign in to comment.