Passed
Push — master ( 5319ee...e6b641 )
by Dani
02:13
created

GuzzleClientTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 10

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 10
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testSend() 0 16 1
1
<?php
2
3
namespace Postpay\Tests\HttpClients;
4
5
use GuzzleHttp\Client;
6
use GuzzleHttp\HandlerStack;
7
use GuzzleHttp\Exception\RequestException;
8
use GuzzleHttp\Handler\MockHandler;
9
use GuzzleHttp\Psr7\Response as GuzzleResponse;
10
use GuzzleHttp\Psr7\Request as GuzzleRequest;
11
use PHPUnit\Framework\TestCase;
12
use Postpay\Exceptions\PostpayException;
13
use Postpay\Http\Request;
14
use Postpay\HttpClients\GuzzleClient;
15
16
class GuzzleClientTest extends TestCase
17
{
18
    public function testSend()
19
    {
20
        $mock = new MockHandler([
21
            new GuzzleResponse(200),
22
            new RequestException('error', new GuzzleRequest('GET', ''))
23
        ]);
24
        $guzzleClient = new Client(['handler' => HandlerStack::create($mock)]);
25
        $client = new GuzzleClient($guzzleClient);
26
        $request = new Request('GET');
27
28
        $response = $client->send($request);
29
        self::assertSame(200, $response->getStatusCode());
30
31
        $this->expectException(PostpayException::class);
32
        $client->send($request);
33
    }
34
}
35