Passed
Push — master ( f7ef7a...65c26d )
by Dmitriy
02:46
created

UserCollectorTest::checkSummaryData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 8
rs 10
cc 1
nc 1
nop 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\Web\IdentityCollector;
9
use Yiisoft\Yii\Debug\Tests\Support\FakeIdentity;
10
11
final class UserCollectorTest extends AbstractCollectorTestCase
12
{
13
    /**
14
     * @param IdentityCollector $collector
15
     */
16
    protected function collectTestData(CollectorInterface $collector): void
17
    {
18
        $collector->collect(null);
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\Collec...mmaryCollectorInterface or Yiisoft\Yii\Debug\Collector\Queue\QueueCollector or Yiisoft\Yii\Debug\Collec...abase\DatabaseCollector. 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(null);
Loading history...
19
        $collector->collect(new FakeIdentity('stub1'));
20
21
        $collector->collect(null);
22
        $collector->collect(new FakeIdentity('stub2'));
23
        $collector->collect(null);
24
    }
25
26
    protected function getCollector(): CollectorInterface
27
    {
28
        return new IdentityCollector();
29
    }
30
31
    protected function checkCollectedData(array $data): void
32
    {
33
        parent::checkCollectedData($data);
34
35
        $this->assertCount(2, $data);
36
        $this->assertEquals([
37
            ['id' => 'stub1', 'class' => FakeIdentity::class],
38
            ['id' => 'stub2', 'class' => FakeIdentity::class],
39
        ], $data);
40
    }
41
42
    protected function checkSummaryData(array $data): void
43
    {
44
        parent::checkSummaryData($data);
45
46
        $this->assertArrayHasKey('identity', $data);
47
        $this->assertArrayHasKey('lastId', $data['identity']);
48
        $this->assertEquals('stub2', $data['identity']['lastId']);
49
        $this->assertEquals(2, $data['identity']['total']);
50
    }
51
}
52