RequestFactoryMiddlewareTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 1
A testApplyResponse() 0 3 1
A testApplyRequest() 0 6 1
1
<?php
2
/*
3
 * This file is part of Guzzle HTTP JSON-RPC
4
 *
5
 * Copyright (c) 2014 Nature Delivered Ltd. <http://graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @see  http://github.com/graze/guzzle-jsonrpc/blob/master/LICENSE
11
 * @link http://github.com/graze/guzzle-jsonrpc
12
 */
13
namespace Graze\GuzzleHttp\JsonRpc\Middleware;
14
15
use Graze\GuzzleHttp\JsonRpc\Test\UnitTestCase;
16
17
class RequestFactoryMiddlewareTest extends UnitTestCase
18
{
19
    /** @var mixed */
20
    private $request;
21
    /** @var mixed */
22
    private $response;
23
    /** @var mixed */
24
    private $factory;
25
    /** @var RequestFactoryMiddleware */
26
    private $middleware;
27
28
    public function setUp()
29
    {
30
        $this->request = $this->mockRequest();
31
        $this->response = $this->mockResponse();
32
        $this->factory = $this->mockMessageFactory();
33
34
        $this->middleware = new RequestFactoryMiddleware($this->factory);
0 ignored issues
show
Bug introduced by
$this->factory of type Mockery\MockInterface is incompatible with the type Graze\GuzzleHttp\JsonRpc...MessageFactoryInterface expected by parameter $factory of Graze\GuzzleHttp\JsonRpc...ddleware::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

34
        $this->middleware = new RequestFactoryMiddleware(/** @scrutinizer ignore-type */ $this->factory);
Loading history...
35
    }
36
37
    public function testApplyRequest()
38
    {
39
        $newRequest = clone $this->request;
40
        $this->factory->shouldReceive('fromRequest')->once()->with($this->request)->andReturn($newRequest);
41
42
        $this->assertSame($newRequest, $this->middleware->applyRequest($this->request, []));
43
    }
44
45
    public function testApplyResponse()
46
    {
47
        $this->assertSame($this->response, $this->middleware->applyResponse($this->request, $this->response, []));
48
    }
49
}
50