Skip to content

Commit

Permalink
Update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jenky committed Jun 19, 2023
1 parent 5e9b60d commit 13afd7f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
18 changes: 18 additions & 0 deletions tests/ConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace Jenky\Atlas\Tests;

use Jenky\Atlas\ConnectorConfigurator;
use Jenky\Atlas\Middleware\Interceptor;
use Jenky\Atlas\Mock\MockClient;
use Jenky\Atlas\Tests\Services\HTTPBin\Connector;
use Jenky\Atlas\Tests\Services\HTTPBin\GetHeadersRequest;
use Jenky\Atlas\Tests\Services\PostmanEcho\EchoConnector;
Expand Down Expand Up @@ -78,4 +80,20 @@ public function test_requests_resources(): void

$this->assertTrue($response->redirect());
}

public function test_connector_configurator(): void
{
$client = new MockClient();

$connector = (new EchoConnector())->withClient($client);

$response = (new ConnectorConfigurator())
->followRedirects()
->retry()
->configure($connector)
->get();

$this->assertCount(0, $connector->middleware());
$this->assertSame(200, $response->status());
}
}
12 changes: 12 additions & 0 deletions tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Jenky\Atlas\Mock\MockClient;
use Jenky\Atlas\Mock\MockResponse;
use Jenky\Atlas\Response;
use Jenky\Atlas\Tests\Services\HTTPBin\Connector;
use Jenky\Atlas\Tests\Services\HTTPBin\GetStatusRequest;

Expand Down Expand Up @@ -51,4 +52,15 @@ public function test_response_assertions(): void
$this->assertTrue($response->forbidden());
$this->assertTrue($response->failed());
}

public function test_response_macro(): void
{
$response = new Response(MockResponse::create(''));

$response->macro('foo', function () {
return 'bar';
});

$this->assertSame('bar', $response->foo());
}
}
10 changes: 0 additions & 10 deletions tests/Services/PostmanEcho/EchoConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

namespace Jenky\Atlas\Tests\Services\PostmanEcho;

use GuzzleHttp\Client;
use Jenky\Atlas\Response;
use Jenky\Atlas\Tests\Services\PostmanEcho\Cookie\CookieRequests;
use Jenky\Atlas\Traits\ConnectorTrait;
use Psr\Http\Client\ClientInterface;

final class EchoConnector implements EchoConnectorInterface
{
Expand All @@ -19,14 +17,6 @@ public function baseUri(): ?string
return 'https://postman-echo.com/';
}

protected function defaultClient(): ClientInterface
{
return new Client([
'base_uri' => $this->baseUri(),
'allow_redirects' => true,
]);
}

public function get(): Response
{
return $this->send(new EchoRequest('get'));
Expand Down

0 comments on commit 13afd7f

Please sign in to comment.