Passed
Push — master ( b091a1...a43e6f )
by Pavel
03:13
created

RpcClientTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 7
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testRpcRequestHandling() 0 10 1
A getStaticIdGenerator() 0 7 1
1
<?php
2
3
namespace ScayTrase\Api\JsonRpc\Tests;
4
5
use GuzzleHttp\Psr7\Uri;
6
use Prophecy\Argument;
7
use ScayTrase\Api\IdGenerator\IdGeneratorInterface;
8
use ScayTrase\Api\JsonRpc\JsonRpcClient;
9
use ScayTrase\Api\Rpc\Tests\RpcRequestTrait;
10
11
final class RpcClientTest extends AbstractJsonRpcClientTest
12
{
13
    use RpcRequestTrait;
14
15
    const REQUEST_ID = 'request_id';
16
17
    public function testRpcRequestHandling()
18
    {
19
        $request = $this->getRequestMock('test', ['param1' => 'value1']);
20
        $client = new JsonRpcClient($this->getClient(), new Uri(), $this->getStaticIdGenerator(self::REQUEST_ID));
21
22
        $this->pushResult((object)['success' => true], self::REQUEST_ID);
23
24
        $collection = $client->invoke($request);
25
        $response = $collection->getResponse($request);
0 ignored issues
show
Unused Code introduced by
$response is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
26
    }
27
28
    public function getStaticIdGenerator($id)
29
    {
30
        $generator = $this->prophesize(IdGeneratorInterface::class);
31
        $generator->getRequestIdentifier(Argument::any())->willReturn($id);
32
33
        return $generator->reveal();
34
    }
35
}
36