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

StreamDecoratorTraitTest::testWrapsWrites()   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 Psr\Http\Message\StreamInterface;
5
use RingCentral\Psr7;
6
use RingCentral\Psr7\StreamDecoratorTrait;
7
8
class Str extends StreamDecoratorTrait implements StreamInterface
9
{
10
}
11
12
/**
13
 * @covers RingCentral\Psr7\StreamDecoratorTrait
14
 */
15
class StreamDecoratorTraitTest 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...
16
{
17
    private $a;
18
    private $b;
19
    private $c;
20
21
    public function setUp()
22
    {
23
        $this->c = fopen('php://temp', 'r+');
24
        fwrite($this->c, 'foo');
25
        fseek($this->c, 0);
26
        $this->a = Psr7\stream_for($this->c);
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

26
        $this->a = /** @scrutinizer ignore-call */ Psr7\stream_for($this->c);
Loading history...
27
        $this->b = new Str($this->a);
28
    }
29
30
    public function testCatchesExceptionsWhenCastingToString()
31
    {
32
        $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
33
                  ->setMethods(array('read'))
34
                  ->getMockForAbstractClass();
35
        $s->expects($this->once())
36
          ->method('read')
37
          ->will($this->throwException(new \Exception('foo')));
38
        $msg = '';
39
        set_error_handler(function ($errNo, $str) use (&$msg) {
40
            $msg = $str;
41
        });
42
        echo new Str($s);
43
        restore_error_handler();
44
        $this->assertContains('foo', $msg);
45
    }
46
47
    public function testToString()
48
    {
49
        $this->assertEquals('foo', (string)$this->b);
50
    }
51
52
    public function testHasSize()
53
    {
54
        $this->assertEquals(3, $this->b->getSize());
55
    }
56
57
    public function testReads()
58
    {
59
        $this->assertEquals('foo', $this->b->read(10));
60
    }
61
62
    public function testCheckMethods()
63
    {
64
        $this->assertEquals($this->a->isReadable(), $this->b->isReadable());
65
        $this->assertEquals($this->a->isWritable(), $this->b->isWritable());
66
        $this->assertEquals($this->a->isSeekable(), $this->b->isSeekable());
67
    }
68
69
    public function testSeeksAndTells()
70
    {
71
        $this->b->seek(1);
72
        $this->assertEquals(1, $this->a->tell());
73
        $this->assertEquals(1, $this->b->tell());
74
        $this->b->seek(0);
75
        $this->assertEquals(0, $this->a->tell());
76
        $this->assertEquals(0, $this->b->tell());
77
        $this->b->seek(0, SEEK_END);
78
        $this->assertEquals(3, $this->a->tell());
79
        $this->assertEquals(3, $this->b->tell());
80
    }
81
82
    public function testGetsContents()
83
    {
84
        $this->assertEquals('foo', $this->b->getContents());
85
        $this->assertEquals('', $this->b->getContents());
86
        $this->b->seek(1);
87
        $this->assertEquals('oo', $this->b->getContents(1));
88
    }
89
90
    public function testCloses()
91
    {
92
        $this->b->close();
93
        $this->assertFalse(is_resource($this->c));
94
    }
95
96
    public function testDetaches()
97
    {
98
        $this->b->detach();
99
        $this->assertFalse($this->b->isReadable());
100
    }
101
102
    public function testWrapsMetadata()
103
    {
104
        $this->assertSame($this->b->getMetadata(), $this->a->getMetadata());
105
        $this->assertSame($this->b->getMetadata('uri'), $this->a->getMetadata('uri'));
106
    }
107
108
    public function testWrapsWrites()
109
    {
110
        $this->b->seek(0, SEEK_END);
111
        $this->b->write('foo');
112
        $this->assertEquals('foofoo', (string)$this->a);
113
    }
114
115
    /**
116
     * @expectedException \UnexpectedValueException
117
     */
118
    public function testThrowsWithInvalidGetter()
119
    {
120
        $this->b->foo;
121
    }
122
123
}