Passed
Push — master ( 71ac2a...8d79cc )
by Dmitriy
02:35
created

MemoryStorageTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 26
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getStorage() 0 3 1
A testSummaryCount() 0 19 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Tests\Unit\Storage;
6
7
use Yiisoft\Yii\Debug\DebuggerIdGenerator;
8
use Yiisoft\Yii\Debug\Storage\MemoryStorage;
9
use Yiisoft\Yii\Debug\Storage\StorageInterface;
10
11
final class MemoryStorageTest extends AbstractStorageTest
12
{
13
    public function getStorage(DebuggerIdGenerator $idGenerator): StorageInterface
14
    {
15
        return new MemoryStorage($idGenerator);
16
    }
17
18
    public function testSummaryCount()
19
    {
20
        $idGenerator = new DebuggerIdGenerator();
21
        $storage = $this->getStorage($idGenerator);
22
23
        $storage->addCollector($collector1 = $this->createFakeSummaryCollector(['test' => 'test']));
24
        $storage->addCollector($collector2 = $this->createFakeCollector(['test' => 'test']));
25
26
        $result = $storage->read(StorageInterface::TYPE_SUMMARY, null);
27
        $this->assertCount(1, $result);
28
29
        $this->assertEquals(
30
            [
31
                $idGenerator->getId() => [
32
                    'id' => $idGenerator->getId(),
33
                    'collectors' => [$collector1->getName(), $collector2->getName()],
34
                ],
35
            ],
36
            $result
37
        );
38
    }
39
}
40