Passed
Pull Request — master (#232)
by Alexander
05:12 queued 02:34
created

StreamWrapperTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 25
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testStream() 0 23 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Tests\Unit\Helper\StreamWrapper;
6
7
use PHPUnit\Framework\TestCase;
8
use Yiisoft\Yii\Debug\Tests\Support\Stub\PhpStreamProxy;
9
10
final class StreamWrapperTest extends TestCase
11
{
12
    public function testStream()
13
    {
14
        $handle = fopen('php://memory', 'rw');
15
16
        PhpStreamProxy::register();
17
        $proxy = new PhpStreamProxy();
18
        $proxy->decorated->stream = $handle;
0 ignored issues
show
Bug introduced by
Accessing stream on the interface Yiisoft\Yii\Debug\Helper...\StreamWrapperInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
19
20
        fwrite($handle, '1234567890');
21
22
        fseek($handle, 0);
23
24
        $firstElement = fread($handle, 2);
25
        $secondElement = fread($handle, 2);
26
27
        $this->assertNotSame($firstElement, $secondElement);
28
29
        fseek($handle, 0);
30
31
        $this->assertEquals($firstElement, fread($handle, 2));
32
33
        $proxy->stream_seek(0);
34
        $this->assertEquals($firstElement, fread($handle, 2));
35
    }
36
}
37