forked from devpark/laravel-paybox-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuzzleHttpClientTest.php
33 lines (25 loc) · 933 Bytes
/
GuzzleHttpClientTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
namespace Tests\HttpClient;
use Matthv\PayboxGateway\HttpClient\GuzzleHttpClient;
use GuzzleHttp\Client;
use stdClass;
use Tests\UnitTestCase;
use Mockery as m;
class GuzzleHttpClientTest extends UnitTestCase
{
/** @test */
public function it_runs_valid_request()
{
$client = m::mock(Client::class);
$response = m::mock(stdClass::class);
$url = 'http://example.com';
$parameters = ['a' => 'b', 'c' => 'd'];
$responseBody = 'foo=bar&baz=foo';
$guzzleClient = m::mock(GuzzleHttpClient::class, [$client])->makePartial();
$client->shouldReceive('request')->with('POST', $url, ['form_params' => $parameters])
->once()->andReturn($response);
$response->shouldReceive('getBody')->once()->andReturn($responseBody);
$response = $guzzleClient->request($url, $parameters);
$this->assertSame($responseBody, $response);
}
}