Completed
Pull Request — master (#30)
by Harry
02:53 queued 01:19
created

RequestTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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\Message;
14
15
use Graze\GuzzleHttp\JsonRpc\ClientInterface;
16
use Graze\GuzzleHttp\JsonRpc\Test\UnitTestCase;
17
18
class RequestTest extends UnitTestCase
19
{
20
    public function setUp()
21
    {
22
        $this->stream = $this->mockStream();
0 ignored issues
show
Bug introduced by
The property stream does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
23
    }
24
25
    public function testInterface()
26
    {
27
        $this->assertInstanceOf('Graze\GuzzleHttp\JsonRpc\Message\RequestInterface', new Request('foo', 'bar'));
28
        $this->assertInstanceOf('Psr\Http\Message\RequestInterface', new Request('foo', 'bar'));
29
    }
30
31 View Code Duplication
    public function testGetRpcId()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        $request = new Request('foo', 'bar', [], json_encode([
34
            'id' => 123
35
        ]));
36
37
        $this->assertEquals(123, $request->getRpcId());
38
    }
39
40
    public function testGetRpcIdIsNull()
41
    {
42
        $request = new Request('foo', 'bar');
43
44
        $this->assertNull($request->getRpcId());
45
    }
46
47 View Code Duplication
    public function testGetRpcMethod()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        $request = new Request('foo', 'bar', [], json_encode([
50
            'method' => 'foo'
51
        ]));
52
53
        $this->assertEquals('foo', $request->getRpcMethod());
54
    }
55
56
    public function testGetRpcMethodIsNull()
57
    {
58
        $request = new Request('foo', 'bar');
59
60
        $this->assertNull($request->getRpcMethod());
61
    }
62
63
    public function testGetRpcParams()
64
    {
65
        $request = new Request('foo', 'bar', [], json_encode([
66
            'params' => ['foo'=>'bar']
67
        ]));
68
69
        $this->assertEquals(['foo'=>'bar'], $request->getRpcParams());
70
    }
71
72
    public function testGetRpcParamsIsNull()
73
    {
74
        $request = new Request('foo', 'bar');
75
76
        $this->assertNull($request->getRpcParams());
77
    }
78
79 View Code Duplication
    public function testGetRpcVersion()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
80
    {
81
        $request = new Request('foo', 'bar', [], json_encode([
82
            'jsonrpc' => 'foo'
83
        ]));
84
85
        $this->assertEquals('foo', $request->getRpcVersion());
86
    }
87
88
    public function testGetRpcVersionIsNull()
89
    {
90
        $request = new Request('foo', 'bar');
91
92
        $this->assertNull($request->getRpcVersion());
93
    }
94
}
95