GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 5cefd1...492078 )
by Anton
04:08
created

ResponseTest::testNewInstanceWhenNewBody()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
namespace RingCentral\Tests\Psr7;
3
4
use RingCentral\Psr7\Response;
5
use RingCentral\Psr7;
6
7
/**
8
 * @covers RingCentral\Psr7\MessageTrait
9
 * @covers RingCentral\Psr7\Response
10
 */
11
class ResponseTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Bug introduced by
The type PHPUnit_Framework_TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
{
13
    public function testAddsDefaultReason()
14
    {
15
        $r = new Response('200');
16
        $this->assertSame(200, $r->getStatusCode());
17
        $this->assertEquals('OK', $r->getReasonPhrase());
18
    }
19
20
    public function testCanGiveCustomReason()
21
    {
22
        $r = new Response(200, array(), null, '1.1', 'bar');
23
        $this->assertEquals('bar', $r->getReasonPhrase());
24
    }
25
26
    public function testCanGiveCustomProtocolVersion()
27
    {
28
        $r = new Response(200, array(), null, '1000');
29
        $this->assertEquals('1000', $r->getProtocolVersion());
30
    }
31
32
    public function testCanCreateNewResponseWithStatusAndNoReason()
33
    {
34
        $r = new Response(200);
35
        $r2 = $r->withStatus(201);
36
        $this->assertEquals(200, $r->getStatusCode());
37
        $this->assertEquals('OK', $r->getReasonPhrase());
38
        $this->assertEquals(201, $r2->getStatusCode());
39
        $this->assertEquals('Created', $r2->getReasonPhrase());
40
    }
41
42
    public function testCanCreateNewResponseWithStatusAndReason()
43
    {
44
        $r = new Response(200);
45
        $r2 = $r->withStatus(201, 'Foo');
46
        $this->assertEquals(200, $r->getStatusCode());
47
        $this->assertEquals('OK', $r->getReasonPhrase());
48
        $this->assertEquals(201, $r2->getStatusCode());
49
        $this->assertEquals('Foo', $r2->getReasonPhrase());
50
    }
51
52
    public function testCreatesResponseWithAddedHeaderArray()
53
    {
54
        $r = new Response();
55
        $r2 = $r->withAddedHeader('foo', array('baz', 'bar'));
56
        $this->assertFalse($r->hasHeader('foo'));
57
        $this->assertEquals('baz, bar', $r2->getHeaderLine('foo'));
58
    }
59
60
    public function testReturnsIdentityWhenRemovingMissingHeader()
61
    {
62
        $r = new Response();
63
        $this->assertSame($r, $r->withoutHeader('foo'));
64
    }
65
66
    public function testAlwaysReturnsBody()
67
    {
68
        $r = new Response();
69
        $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody());
70
    }
71
72
    public function testCanSetHeaderAsArray()
73
    {
74
        $r = new Response(200, array(
75
            'foo' => array('baz ', ' bar ')
76
        ));
77
        $this->assertEquals('baz, bar', $r->getHeaderLine('foo'));
78
        $this->assertEquals(array('baz', 'bar'), $r->getHeader('foo'));
79
    }
80
81
    public function testSameInstanceWhenSameBody()
82
    {
83
        $r = new Response(200, array(), 'foo');
84
        $b = $r->getBody();
85
        $this->assertSame($r, $r->withBody($b));
86
    }
87
88
    public function testNewInstanceWhenNewBody()
89
    {
90
        $r = new Response(200, array(), 'foo');
91
        $b2 = Psr7\stream_for('abc');
0 ignored issues
show
Bug introduced by
The function stream_for was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

91
        $b2 = /** @scrutinizer ignore-call */ Psr7\stream_for('abc');
Loading history...
92
        $this->assertNotSame($r, $r->withBody($b2));
93
    }
94
95
    public function testSameInstanceWhenSameProtocol()
96
    {
97
        $r = new Response(200);
98
        $this->assertSame($r, $r->withProtocolVersion('1.1'));
99
    }
100
101
    public function testNewInstanceWhenNewProtocol()
102
    {
103
        $r = new Response(200);
104
        $this->assertNotSame($r, $r->withProtocolVersion('1.0'));
105
    }
106
107
    public function testNewInstanceWhenRemovingHeader()
108
    {
109
        $r = new Response(200, array('Foo' => 'Bar'));
110
        $r2 = $r->withoutHeader('Foo');
111
        $this->assertNotSame($r, $r2);
112
        $this->assertFalse($r2->hasHeader('foo'));
113
    }
114
115
    public function testNewInstanceWhenAddingHeader()
116
    {
117
        $r = new Response(200, array('Foo' => 'Bar'));
118
        $r2 = $r->withAddedHeader('Foo', 'Baz');
119
        $this->assertNotSame($r, $r2);
120
        $this->assertEquals('Bar, Baz', $r2->getHeaderLine('foo'));
121
    }
122
123
    public function testNewInstanceWhenAddingHeaderArray()
124
    {
125
        $r = new Response(200, array('Foo' => 'Bar'));
126
        $r2 = $r->withAddedHeader('Foo', array('Baz', 'Qux'));
127
        $this->assertNotSame($r, $r2);
128
        $this->assertEquals(array('Bar', 'Baz', 'Qux'), $r2->getHeader('foo'));
129
    }
130
131
    public function testNewInstanceWhenAddingHeaderThatWasNotThereBefore()
132
    {
133
        $r = new Response(200, array('Foo' => 'Bar'));
134
        $r2 = $r->withAddedHeader('Baz', 'Bam');
135
        $this->assertNotSame($r, $r2);
136
        $this->assertEquals('Bam', $r2->getHeaderLine('Baz'));
137
        $this->assertEquals('Bar', $r2->getHeaderLine('Foo'));
138
    }
139
140
    public function testRemovesPreviouslyAddedHeaderOfDifferentCase()
141
    {
142
        $r = new Response(200, array('Foo' => 'Bar'));
143
        $r2 = $r->withHeader('foo', 'Bam');
144
        $this->assertNotSame($r, $r2);
145
        $this->assertEquals('Bam', $r2->getHeaderLine('Foo'));
146
    }
147
148
    public function testBodyConsistent()
149
    {
150
        $r = new Response(200, array(), '0');
151
        $this->assertEquals('0', (string)$r->getBody());
152
    }
153
154
}
155