Passed
Push — master ( 7bc6a4...bace86 )
by Dmitriy
06:54 queued 04:27
created

tests/Unit/Collector/HttpStreamCollectorTest.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Tests\Unit\Collector;
6
7
use Yiisoft\Yii\Debug\Collector\CollectorInterface;
8
use Yiisoft\Yii\Debug\Collector\Stream\HttpStreamCollector;
9
use Yiisoft\Yii\Debug\Tests\Shared\AbstractCollectorTestCase;
10
11
final class HttpStreamCollectorTest extends AbstractCollectorTestCase
12
{
13
    /**
14
     * @param CollectorInterface|HttpStreamCollector $collector
15
     */
16
    protected function collectTestData(CollectorInterface $collector): void
17
    {
18
        $collector->collect(
0 ignored issues
show
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\Collec...mmaryCollectorInterface. 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

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