-
Notifications
You must be signed in to change notification settings - Fork 431
Expand file tree
/
Copy pathStompHeadersEncoderTest.php
More file actions
69 lines (60 loc) · 2.42 KB
/
Copy pathStompHeadersEncoderTest.php
File metadata and controls
69 lines (60 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Enqueue\Stomp\Tests;
use Enqueue\Stomp\StompHeadersEncoder;
class StompHeadersEncoderTest extends \PHPUnit\Framework\TestCase
{
public function headerValuesDataProvider()
{
return [
[['key' => 'Lorem ipsum'], ['key' => 'Lorem ipsum', '_type_key' => 's']],
[['key' => 1234], ['key' => '1234', '_type_key' => 'i']],
[['key' => 123.45], ['key' => '123.45', '_type_key' => 'f']],
[['key' => true], ['key' => 'true', '_type_key' => 'b']],
[['key' => false], ['key' => 'false', '_type_key' => 'b']],
[['key' => null], ['key' => '', '_type_key' => 'n']],
];
}
public function propertyValuesDataProvider()
{
return [
[['key' => 'Lorem ipsum'], ['_property_key' => 'Lorem ipsum', '_property__type_key' => 's']],
[['key' => 1234], ['_property_key' => '1234', '_property__type_key' => 'i']],
[['key' => 123.45], ['_property_key' => '123.45', '_property__type_key' => 'f']],
[['key' => true], ['_property_key' => 'true', '_property__type_key' => 'b']],
[['key' => false], ['_property_key' => 'false', '_property__type_key' => 'b']],
[['key' => null], ['_property_key' => '', '_property__type_key' => 'n']],
];
}
/**
* @dataProvider headerValuesDataProvider
*/
public function testShouldEncodeHeaders($originalValue, $encodedValue)
{
$this->assertSame($encodedValue, StompHeadersEncoder::encode($originalValue));
}
/**
* @dataProvider propertyValuesDataProvider
*/
public function testShouldEncodeProperties($originalValue, $encodedValue)
{
$this->assertSame($encodedValue, StompHeadersEncoder::encode([], $originalValue));
}
/**
* @dataProvider headerValuesDataProvider
*/
public function testShouldDecodeHeaders($originalValue, $encodedValue)
{
$this->assertSame([$originalValue, []], StompHeadersEncoder::decode($encodedValue));
}
/**
* @dataProvider propertyValuesDataProvider
*/
public function testShouldDecodeProperties($originalValue, $encodedValue)
{
$this->assertSame([[], $originalValue], StompHeadersEncoder::decode($encodedValue));
}
public function testShouldKeepTypeAsIsIfHereIsNoTypeField()
{
$this->assertSame([['key' => 123.45], []], StompHeadersEncoder::decode(['key' => 123.45]));
}
}