Passed
Pull Request — master (#186)
by Alexander
02:41
created

HttpStreamCollectorTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 21
c 0
b 0
f 0
dl 0
loc 42
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A collectTestData() 0 11 1
A checkIndexData() 0 5 1
A checkCollectedData() 0 11 1
A getCollector() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Tests\Collector;
6
7
use Yiisoft\Yii\Debug\Collector\CollectorInterface;
8
use Yiisoft\Yii\Debug\Collector\HttpStreamCollector;
9
10
final class HttpStreamCollectorTest extends AbstractCollectorTestCase
11
{
12
    /**
13
     * @param CollectorInterface|HttpStreamCollector $collector
14
     */
15
    protected function collectTestData(CollectorInterface $collector): void
16
    {
17
        $collector->collect(
0 ignored issues
show
Bug introduced by
The method collect() does not exist on Yiisoft\Yii\Debug\Collector\CollectorInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Yiisoft\Yii\Debug\Collector\QueueCollector. Are you sure you never get one of those? ( Ignorable by Annotation )

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

17
        $collector->/** @scrutinizer ignore-call */ 
18
                    collect(
Loading history...
18
            operation: 'read',
19
            path: __FILE__,
20
            args: ['arg1' => 'v1', 'arg2' => 'v2'],
21
        );
22
        $collector->collect(
23
            operation: 'read',
24
            path: __FILE__,
25
            args: ['arg3' => 'v3', 'arg4' => 'v4'],
26
        );
27
    }
28
29
    protected function getCollector(): CollectorInterface
30
    {
31
        return new HttpStreamCollector();
32
    }
33
34
    protected function checkCollectedData(array $data): void
35
    {
36
        parent::checkCollectedData($data);
37
        $collected = $data;
38
        $this->assertCount(1, $collected);
39
40
        $this->assertCount(2, $collected['read']);
41
        $this->assertEquals([
42
            ['uri' => __FILE__, 'args' => ['arg1' => 'v1', 'arg2' => 'v2']],
43
            ['uri' => __FILE__, 'args' => ['arg3' => 'v3', 'arg4' => 'v4']],
44
        ], $collected['read']);
45
    }
46
47
    protected function checkIndexData(array $data): void
48
    {
49
        parent::checkIndexData($data);
50
        $this->assertArrayHasKey('http_stream', $data);
51
        $this->assertEquals(['read' => 2], $data['http_stream']);
52
    }
53
}
54