-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #110 Inject sylius.http_client rather than http_client to Generic…
…Api (Zales0123) This PR was merged into the 1.0-dev branch. Discussion ---------- Commits ------- 190b2b3 Inject sylius.http_client rather than http_client to GenericApi
- Loading branch information
Showing
3 changed files
with
59 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\Sylius\PayPalPlugin\Api; | ||
|
||
use GuzzleHttp\ClientInterface; | ||
use PhpSpec\ObjectBehavior; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\StreamInterface; | ||
use Sylius\PayPalPlugin\Api\GenericApiInterface; | ||
|
||
final class GenericApiSpec extends ObjectBehavior | ||
{ | ||
function let(ClientInterface $client): void | ||
{ | ||
$this->beConstructedWith($client); | ||
} | ||
|
||
function it_implements_generic_api_interface(): void | ||
{ | ||
$this->shouldImplement(GenericApiInterface::class); | ||
} | ||
|
||
function it_calls_api_by_url( | ||
ClientInterface $client, | ||
ResponseInterface $response, | ||
StreamInterface $body | ||
): void { | ||
$client->request('GET', 'http://url.com/', [ | ||
'headers' => [ | ||
'Authorization' => 'Bearer TOKEN', | ||
'Content-Type' => 'application/json', | ||
'Accept' => 'application/json', | ||
], | ||
])->willReturn($response); | ||
|
||
$response->getBody()->willReturn($body); | ||
$body->getContents()->willReturn('{ "parameter": "VALUE" }'); | ||
|
||
$this->get('TOKEN', 'http://url.com/')->shouldReturn(['parameter' => 'VALUE']); | ||
} | ||
} |
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