Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Closure;
use Illuminate\Http\Request;
use Livewire\Exceptions\ComponentNotFoundException;
use Livewire\LivewireManager;
use Livewire\Livewire;

final class DropInvalidLivewireRequests
{
Expand Down Expand Up @@ -41,7 +41,7 @@ public function handle(Request $request, Closure $next)
private function isValidComponent(string $component) : bool
{
try {
return app(LivewireManager::class)->getClass($component) !== null;
return Livewire::getClass($component) !== null;
} catch (ComponentNotFoundException $e) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Livewire\Exceptions\ComponentNotFoundException;
use Livewire\LivewireManager;
use Livewire\Livewire;
use Symfony\Component\HttpKernel\Exception\HttpException;

function mockRequest(string $routeName = 'testing::dummy', array $payload = []) : Request
Expand Down Expand Up @@ -49,9 +49,7 @@ function mockRequest(string $routeName = 'testing::dummy', array $payload = [])
],
]);

$this->mock(LivewireManager::class, function ($mock) {
$mock->shouldReceive('getClass')->with('dummy-name')->andThrow(ComponentNotFoundException::class);
});
Livewire::shouldReceive('getClass')->with('dummy-name')->andThrow(ComponentNotFoundException::class);

try {
$response = (new DropInvalidLivewireRequests())->handle($request, fn () => 'Hello world');
Expand All @@ -77,9 +75,7 @@ function mockRequest(string $routeName = 'testing::dummy', array $payload = [])
],
]);

$this->mock(LivewireManager::class, function ($mock) {
$mock->shouldReceive('getClass')->with('dummy-name')->andReturn('done');
});
Livewire::shouldReceive('getClass')->with('dummy-name')->andReturn('done');

try {
$response = (new DropInvalidLivewireRequests())->handle($request, fn () => 'Hello world');
Expand All @@ -105,9 +101,7 @@ function mockRequest(string $routeName = 'testing::dummy', array $payload = [])
],
]);

$this->mock(LivewireManager::class, function ($mock) {
$mock->shouldReceive('getClass')->with('dummy-name')->andReturn('done');
});
Livewire::shouldReceive('getClass')->with('dummy-name')->andReturn('done');

try {
$response = (new DropInvalidLivewireRequests())->handle($request, fn () => 'Hello world');
Expand All @@ -133,9 +127,7 @@ function mockRequest(string $routeName = 'testing::dummy', array $payload = [])
],
]);

$this->mock(LivewireManager::class, function ($mock) {
$mock->shouldReceive('getClass')->with('dummy-name')->andReturn('done');
});
Livewire::shouldReceive('getClass')->with('dummy-name')->andReturn('done');

try {
$response = (new DropInvalidLivewireRequests())->handle($request, fn () => 'Hello world');
Expand All @@ -161,9 +153,7 @@ function mockRequest(string $routeName = 'testing::dummy', array $payload = [])
],
]);

$this->mock(LivewireManager::class, function ($mock) {
$mock->shouldReceive('getClass')->with('dummy-name')->andReturn('done');
});
Livewire::shouldReceive('getClass')->with('dummy-name')->andReturn('done');

try {
$response = (new DropInvalidLivewireRequests())->handle($request, fn () => 'Hello world');
Expand All @@ -189,9 +179,7 @@ function mockRequest(string $routeName = 'testing::dummy', array $payload = [])
],
]);

$this->mock(LivewireManager::class, function ($mock) {
$mock->shouldReceive('getClass')->with('dummy-name')->andReturn('done');
});
Livewire::shouldReceive('getClass')->with('dummy-name')->andReturn('done');

try {
$response = (new DropInvalidLivewireRequests())->handle($request, fn () => 'Hello world');
Expand All @@ -217,9 +205,7 @@ function mockRequest(string $routeName = 'testing::dummy', array $payload = [])
],
]);

$this->mock(LivewireManager::class, function ($mock) {
$mock->shouldReceive('getClass')->with('dummy-name')->andReturn('done');
});
Livewire::shouldReceive('getClass')->with('dummy-name')->andReturn('done');

try {
$response = (new DropInvalidLivewireRequests())->handle($request, fn () => 'Hello world');
Expand Down