Passed
Pull Request — master (#4)
by Darío
01:31
created

AbstractClientTest::itExecutesAPreparedRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
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 itPreparesARequestForExecution()
14
    {
15
        $client = new SomeClient();
16
        $client->prepareRequest('GET', 'http://example.com/api');
17
18
        $this->assertSame('GET', $client->getRequest()->getMethod());
19
        $this->assertSame('http://example.com/api', $client->getRequest()->getUri());
20
    }
21
22
    /**
23
     * @test
24
     */
25
    public function itExecutesAPreparedRequest()
26
    {
27
        $client = new SomeClient();
28
        $client->prepareRequest('GET', 'http://example.com/api');
29
30
        $response = $client->execute();
31
32
        $this->assertSame(200, $response->getStatusCode());
33
        $this->assertSame(['key' => 'value'], $response->toJson());
34
        $this->assertSame(['Server' => 'Apache/2.4.38 (Debian)'], $response->getHeaders());
35
    }
36
}