Passed
Push — master ( 06646a...1e9aa0 )
by Darío
04:01 queued 01:55
created

AbstractClientTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
eloc 16
c 2
b 0
f 2
dl 0
loc 41
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A itExecutesAPreparedRequest() 0 10 1
A itPreparesARequestForExecution() 0 7 1
A itExecutesARequest() 0 9 1
1
<?php
2
3
namespace EasyHttp\LayerContracts\Tests\Unit;
4
5
use EasyHttp\LayerContracts\Tests\Unit\Example\SomeClient;
6
use PHPUnit\Framework\TestCase;
7
8
class AbstractClientTest extends TestCase
9
{
10
    /**
11
     * @test
12
     */
13
    public function itExecutesARequest()
14
    {
15
        $client = new SomeClient();
16
17
        $response = $client->call('GET', 'http://example.com/api');
18
19
        $this->assertSame(200, $response->getStatusCode());
20
        $this->assertSame(['key' => 'value'], $response->toJson());
21
        $this->assertSame(['Server' => 'Apache/2.4.38 (Debian)'], $response->getHeaders());
22
    }
23
24
    /**
25
     * @test
26
     */
27
    public function itPreparesARequestForExecution()
28
    {
29
        $client = new SomeClient();
30
        $client->prepareRequest('GET', 'http://example.com/api');
31
32
        $this->assertSame('GET', $client->getRequest()->getMethod());
33
        $this->assertSame('http://example.com/api', $client->getRequest()->getUri());
34
    }
35
36
    /**
37
     * @test
38
     */
39
    public function itExecutesAPreparedRequest()
40
    {
41
        $client = new SomeClient();
42
        $client->prepareRequest('GET', 'http://example.com/api');
43
44
        $response = $client->execute();
45
46
        $this->assertSame(200, $response->getStatusCode());
47
        $this->assertSame(['key' => 'value'], $response->toJson());
48
        $this->assertSame(['Server' => 'Apache/2.4.38 (Debian)'], $response->getHeaders());
49
    }
50
}
51