Passed
Push — master ( 71ac2a...8d79cc )
by Dmitriy
02:35
created

HttpClientInterfaceProxyTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testSendRequest() 0 19 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Tests\Unit\Collector;
6
7
use GuzzleHttp\Psr7\Request;
8
use GuzzleHttp\Psr7\Response;
9
use PHPUnit\Framework\TestCase;
10
use Psr\Http\Client\ClientInterface;
11
use Yiisoft\Yii\Debug\Collector\HttpClientCollector;
12
use Yiisoft\Yii\Debug\Collector\HttpClientInterfaceProxy;
13
use Yiisoft\Yii\Debug\Collector\TimelineCollector;
14
15
final class HttpClientInterfaceProxyTest extends TestCase
16
{
17
    public function testSendRequest()
18
    {
19
        $request = new Request('GET', 'http://example.com');
20
        $response = new Response(200, [], 'test');
21
22
        $client = $this->createMock(ClientInterface::class);
23
        $client->expects($this->once())
24
            ->method('sendRequest')
25
            ->with($request)
26
            ->willReturn($response);
27
        $collector = new HttpClientCollector(new TimelineCollector());
28
        $collector->startup();
29
30
        $proxy = new HttpClientInterfaceProxy($client, $collector);
31
32
        $newResponse = $proxy->sendRequest($request);
33
34
        $this->assertSame($newResponse, $response);
35
        $this->assertCount(1, $collector->getCollected());
36
    }
37
}
38