Skip to content

Commit

Permalink
Fixed broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammyjo20 committed Aug 14, 2023
1 parent ad2c4f4 commit 9f0dc52
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/Feature/MockRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Saloon\Exceptions\FixtureException;
use Saloon\Tests\Fixtures\Mocking\UserFixture;
use Saloon\Exceptions\Request\RequestException;
use Saloon\Tests\Fixtures\Requests\PagedSuperheroRequest;
use Saloon\Tests\Fixtures\Requests\UserRequest;
use Saloon\Tests\Fixtures\Requests\ErrorRequest;
use League\Flysystem\Local\LocalFilesystemAdapter;
Expand All @@ -25,7 +26,6 @@
use Saloon\Tests\Fixtures\Requests\FileDownloadRequest;
use Saloon\Tests\Fixtures\Mocking\BeforeSaveUserFixture;
use Saloon\Tests\Fixtures\Connectors\QueryParameterConnector;
use Saloon\Tests\Fixtures\Requests\PageGetSuperHeroesRequest;
use Saloon\Tests\Fixtures\Connectors\DifferentServiceConnector;
use Saloon\Tests\Fixtures\Requests\DifferentServiceUserRequest;
use Saloon\Tests\Fixtures\Requests\QueryParameterConnectorRequest;
Expand Down Expand Up @@ -606,8 +606,8 @@ function (PendingRequest $pendingRequest): MockResponse {
expect($responseA->header('Server'))->toEqual('cloudflare');
expect($responseA->header('Cache-Control'))->toEqual('no-cache, private');

expect($responseA->isSimulated())->toBeFalse();
expect($responseB->isSimulated())->toBeTrue();
expect($responseA->isFaked())->toBeFalse();
expect($responseB->isFaked())->toBeTrue();

expect($responseB->json())->toEqual([
'name' => 'Sxxx',
Expand Down Expand Up @@ -635,8 +635,8 @@ function (PendingRequest $pendingRequest): MockResponse {
new SuperheroFixture,
]);

$responseA = connector()->send(new PageGetSuperHeroesRequest, $mockClient);
$responseB = connector()->send(new PageGetSuperHeroesRequest, $mockClient);
$responseA = connector()->send(new PagedSuperheroRequest, $mockClient);
$responseB = connector()->send(new PagedSuperheroRequest, $mockClient);

expect($responseA->json()['data'])->each->toHaveKey('publisher', 'DC Comics');
expect($responseB->json()['data'])->each->toHaveKey('publisher', 'REDACTED');
Expand Down Expand Up @@ -670,8 +670,8 @@ function (PendingRequest $pendingRequest): MockResponse {
'twitter' => '@carre_sam',
]);

expect($responseA->isSimulated())->toBeFalse();
expect($responseB->isSimulated())->toBeTrue();
expect($responseA->isFaked())->toBeFalse();
expect($responseB->isFaked())->toBeTrue();

expect($responseB->json())->toEqual([
'name' => 'Sxxxmyjo20',
Expand Down
16 changes: 16 additions & 0 deletions tests/Fixtures/Requests/PagedSuperheroRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Saloon\Tests\Fixtures\Requests;

use Saloon\Enums\Method;
use Saloon\Http\Request;

class PagedSuperheroRequest extends Request
{
protected Method $method = Method::GET;

public function resolveEndpoint(): string
{
return '/superheroes/per-page';
}
}

0 comments on commit 9f0dc52

Please sign in to comment.