Total Complexity | 2 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
13 | class RendererTest extends TestCase |
||
14 | { |
||
15 | public function testRender() |
||
16 | { |
||
17 | $collectionRegistry = $this->createMock(CollectorRegistry::class); |
||
18 | $collectionRegistry->expects(self::once())->method('getMetricFamilySamples')->willReturn([new MetricFamilySamples([ |
||
19 | 'name' => 'name', |
||
20 | 'type' => 'type', |
||
21 | 'help' => 'help', |
||
22 | 'labelNames' => [], |
||
23 | 'samples' => [], |
||
24 | ])]); |
||
25 | $metrics = new AppMetrics(); |
||
26 | $metrics->init('test_ns', $collectionRegistry); |
||
27 | $renderer = new Renderer($collectionRegistry); |
||
28 | $response = $renderer->render(); |
||
29 | $this->assertEquals("# HELP name help\n# TYPE name type\n", $response); |
||
30 | } |
||
31 | |||
32 | public function testRenderResponse() |
||
33 | { |
||
34 | $collectionRegistry = $this->createMock(CollectorRegistry::class); |
||
35 | $collectionRegistry->expects(self::once())->method('getMetricFamilySamples')->willReturn([new MetricFamilySamples([ |
||
36 | 'name' => 'name', |
||
37 | 'type' => 'type', |
||
38 | 'help' => 'help', |
||
39 | 'labelNames' => [], |
||
40 | 'samples' => [], |
||
41 | ])]); |
||
42 | $metrics = new AppMetrics(); |
||
43 | $metrics->init('test_ns', $collectionRegistry); |
||
44 | $renderer = new Renderer($collectionRegistry); |
||
45 | $response = $renderer->renderResponse(); |
||
46 | $this->assertContains("# HELP name help\n# TYPE name type\n", $response->getContent()); |
||
47 | } |
||
49 |