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( |
|
|
|
|
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
|
|
|
|