Debian Codegraph @

tests/phpunit/unit/includes/libs/telemetry/OtlpSerializerTest.php

raw symbols SCIP
1 <?php
2 namespace Wikimedia\Tests\Telemetry;
3
4 use MediaWikiUnitTestCase;
5 use Wikimedia\Telemetry\OtlpSerializer;
6
7 /**
8 * @covers \Wikimedia\Telemetry\OtlpSerializer
9 */
10 class OtlpSerializerTest extends MediaWikiUnitTestCase {
11 /**
12 * @dataProvider provideKeyValuePairSerializationData
13 */
14 public function testKeyValuePairSerialization( array $input, array $expected ): void {
15 $actual = OtlpSerializer::serializeKeyValuePairs( $input );
16
17 $this->assertSame( $expected, $actual );
18 }
19
20 public static function provideKeyValuePairSerializationData(): iterable {
21 yield 'empty data' => [ [], [] ];
22 yield 'mixed data' => [
23 [
24 'string-value' => 'string',
25 'numeric-value' => 123,
26 'float-value' => 1.5,
27 'object-value' => new \stdClass(),
28 'boolean-value' => true,
29 'list-value' => [ 'a', 'b' ]
30 ],
31 [
32 [ 'key' => 'string-value', 'value' => [ 'stringValue' => 'string' ] ],
33 [ 'key' => 'numeric-value', 'value' => [ 'intValue' => 123 ] ],
34 [ 'key' => 'float-value', 'value' => [ 'doubleValue' => 1.5 ] ],
35 [ 'key' => 'boolean-value', 'value' => [ 'boolValue' => true ] ],
36 [ 'key' => 'list-value', 'value' => [ 'arrayValue' => [ 'a', 'b' ] ] ]
37 ]
38 ];
39 }
40 }