Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/v2 tests #32

Merged
merged 2 commits into from
Dec 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fixing tests
  • Loading branch information
Sammyjo20 committed Dec 4, 2022
commit a42493a0f12f429bdc0ec4fa97b27eac7dd7d822
2 changes: 1 addition & 1 deletion src/Casts/OAuthAuthenticatorCast.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Saloon\Laravel\Casts;

use InvalidArgumentException;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Saloon\Contracts\OAuthAuthenticator;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;

class OAuthAuthenticatorCast implements CastsAttributes
{
Expand Down
9 changes: 5 additions & 4 deletions src/Facades/Saloon.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Saloon\Laravel\Facades;

use Saloon\Contracts\SaloonResponse;
use Saloon\Contracts\Response;
use Saloon\Laravel\Http\Faking\MockClient;
use Illuminate\Support\Facades\Facade as BaseFacade;

/**
* @see \Sammyjo20\SaloonLaravel\Saloon
* @see \Saloon\Laravel\Saloon
*
* @method static MockClient fake(array $responses)
* @method static MockClient mockClient()
Expand All @@ -19,8 +19,9 @@
* @method static void record()
* @method static void stopRecording()
* @method static bool isRecording()
* @method static SaloonResponse[] getRecordedResponses()
* @method static SaloonResponse getLastRecordedResponse()
* @method static void recordResponse(Response $response)
* @method static \Saloon\Contracts\Response[] getRecordedResponses()
* @method static \Saloon\Contracts\Response getLastRecordedResponse()
*/
class Saloon extends BaseFacade
{
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Middleware/FrameworkMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function bootRecordingFeature(PendingRequest $pendingRequest): static

$pendingRequest->middleware()->onResponse(function (Response $response): void {
Saloon::recordResponse($response);
});
}, true);

return $this;
}
Expand All @@ -94,7 +94,7 @@ protected function bootEventTriggers(PendingRequest $pendingRequest): static

$pendingRequest->middleware()->onResponse(function (Response $response): void {
SentSaloonRequest::dispatch($response->getPendingRequest(), $response);
});
}, true);

return $this;
}
Expand Down
13 changes: 7 additions & 6 deletions src/Saloon.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Saloon\Laravel;

use Saloon\Contracts\Response;
use Saloon\Laravel\Http\Faking\MockClient;

class Saloon
Expand All @@ -24,8 +25,8 @@ class Saloon
* Start mocking!
*
* @param array $responses
* @return MockClient
* @throws \Sammyjo20\Saloon\Exceptions\SaloonInvalidMockResponseCaptureMethodException
* @return \Saloon\Laravel\Http\Faking\MockClient
* @throws \Saloon\Exceptions\InvalidMockResponseCaptureMethodException
*/
public static function fake(array $responses): MockClient
{
Expand Down Expand Up @@ -133,10 +134,10 @@ public function isRecording(): bool
/**
* Record a response.
*
* @param SaloonResponse $response
* @param Response $response
* @return void
*/
public function recordResponse(SaloonResponse $response): void
public function recordResponse(Response $response): void
{
$this->recordedResponses[] = $response;
}
Expand All @@ -154,9 +155,9 @@ public function getRecordedResponses(): array
/**
* Get the last response that Saloon recorded.
*
* @return SaloonResponse|null
* @return Response|null
*/
public function getLastRecordedResponse(): ?SaloonResponse
public function getLastRecordedResponse(): ?Response
{
if (empty($this->recordedResponses)) {
return null;
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/EventsTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php declare(strict_types=1);

use Saloon\Http\Faking\MockResponse;
use Saloon\Laravel\Events\SendingSaloonRequest;
use Saloon\Laravel\Facades\Saloon;
use Saloon\Http\Faking\MockResponse;
use Illuminate\Support\Facades\Event;
use Saloon\Laravel\Events\SentSaloonRequest;
use Saloon\Laravel\Tests\Fixtures\Connectors\TestConnector;
use Saloon\Laravel\Events\SendingSaloonRequest;
use Saloon\Laravel\Tests\Fixtures\Requests\UserRequest;
use Saloon\Laravel\Tests\Fixtures\Connectors\TestConnector;

test('events are fired when a request is being sent and when a request has been sent', function () {
Saloon::fake([
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/MockRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
use Saloon\Contracts\PendingRequest;
use Saloon\Http\Faking\MockResponse;
use Saloon\Exceptions\NoMockResponsesProvidedException;
use Saloon\Laravel\Tests\Fixtures\Connectors\DifferentServiceConnector;
use Saloon\Laravel\Tests\Fixtures\Requests\UserRequest;
use Saloon\Laravel\Tests\Fixtures\Requests\ErrorRequest;
use Saloon\Laravel\Tests\Fixtures\Connectors\TestConnector;
use Saloon\Laravel\Tests\Fixtures\Connectors\QueryParameterConnector;
use Saloon\Laravel\Tests\Fixtures\Connectors\DifferentServiceConnector;
use Saloon\Laravel\Tests\Fixtures\Requests\DifferentServiceUserRequest;
use Saloon\Laravel\Tests\Fixtures\Requests\QueryParameterConnectorRequest;

Expand Down
7 changes: 2 additions & 5 deletions tests/Feature/PoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

use Saloon\Http\PendingRequest;
use Saloon\Http\Faking\MockClient;
use Saloon\Contracts\SaloonResponse;
use Saloon\Http\Responses\Response;
use Saloon\Http\Faking\MockResponse;
use Saloon\Http\Responses\PsrResponse;
use GuzzleHttp\Promise\PromiseInterface;
use GuzzleHttp\Exception\ConnectException;
use Saloon\Exceptions\FatalRequestException;
use Saloon\Http\Responses\Response;
use Saloon\Http\Responses\SimulatedResponse;
use Saloon\Contracts\Response as ResponseContract;
use Saloon\Laravel\Tests\Fixtures\Requests\UserRequest;
use Saloon\Laravel\Tests\Fixtures\Requests\ErrorRequest;
use Saloon\Laravel\Tests\Fixtures\Connectors\TestConnector;
use Saloon\Laravel\Tests\Fixtures\Connectors\InvalidConnectionConnector;
use Saloon\Contracts\Response as ResponseContract;

test('you can create a pool on a connector', function () {
$connector = new TestConnector;
Expand Down