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); |
|
|
|
|
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
|
|
|
|