generated from Sammyjo20/package-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from pascalbaljet/global-middleware-fix
Apply global middleware also to Saloon requests
- Loading branch information
Showing
5 changed files
with
39 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Saloon\HttpSender\HttpSender; | ||
use Illuminate\Support\Facades\Http; | ||
use Illuminate\Support\Facades\Config; | ||
use Saloon\HttpSender\Tests\Fixtures\Requests\UserRequest; | ||
use Saloon\HttpSender\Tests\Fixtures\Connectors\HttpSenderConnector; | ||
|
||
test('the global middleware of the http client factory is also applied to saloon requests', function () { | ||
Config::set('saloon.default_sender', HttpSender::class); | ||
|
||
$globalMiddlewareWasCalled = false; | ||
|
||
Http::globalRequestMiddleware(function ($request) use (&$globalMiddlewareWasCalled) { | ||
$globalMiddlewareWasCalled = true; | ||
|
||
return $request; | ||
}); | ||
|
||
$connector = new HttpSenderConnector; | ||
$connector->send(new UserRequest); | ||
|
||
expect($globalMiddlewareWasCalled)->toBeTrue(); | ||
}); |