|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
5
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer; |
|
8
|
|
|
|
|
9
|
|
|
use eZ\Publish\Core\MVC\Symfony\Component\Serializer\SimplifiedRequestNormalizer; |
|
10
|
|
|
use eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest; |
|
11
|
|
|
use PHPUnit\Framework\TestCase; |
|
12
|
|
|
use stdClass; |
|
13
|
|
|
|
|
14
|
|
|
final class SimplifiedRequestNormalizerTest extends TestCase |
|
15
|
|
|
{ |
|
16
|
|
|
public function testNormalize() |
|
17
|
|
|
{ |
|
18
|
|
|
$request = new SimplifiedRequest([ |
|
19
|
|
|
'scheme' => 'http', |
|
20
|
|
|
'host' => 'www.example.com', |
|
21
|
|
|
'port' => 8080, |
|
22
|
|
|
'pathinfo' => '/foo', |
|
23
|
|
|
'queryParams' => ['param' => 'value', 'this' => 'that'], |
|
24
|
|
|
'headers' => [ |
|
25
|
|
|
'Accept' => 'text/html,application/xhtml+xml', |
|
26
|
|
|
'Accept-Encoding' => 'gzip, deflate, br', |
|
27
|
|
|
'Accept-Language' => 'pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7', |
|
28
|
|
|
'User-Agent' => 'Mozilla/5.0', |
|
29
|
|
|
'Cookie' => 'eZSESSID21232f297a57a5a743894a0e4a801fc3=mgbs2p6lv936hb5hmdd2cvq6bq', |
|
30
|
|
|
'Connection' => 'keep-alive', |
|
31
|
|
|
], |
|
32
|
|
|
'languages' => ['pl-PL', 'en-US'], |
|
33
|
|
|
]); |
|
34
|
|
|
|
|
35
|
|
|
$normalizer = new SimplifiedRequestNormalizer(); |
|
36
|
|
|
|
|
37
|
|
|
$this->assertEquals([ |
|
38
|
|
|
'scheme' => 'http', |
|
39
|
|
|
'host' => 'www.example.com', |
|
40
|
|
|
'port' => 8080, |
|
41
|
|
|
'pathinfo' => '/foo', |
|
42
|
|
|
'queryParams' => ['param' => 'value', 'this' => 'that'], |
|
43
|
|
|
'headers' => [], |
|
44
|
|
|
'languages' => ['pl-PL', 'en-US'], |
|
45
|
|
|
], $normalizer->normalize($request)); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function testSupportsNormalization() |
|
49
|
|
|
{ |
|
50
|
|
|
$normalizer = new SimplifiedRequestNormalizer(); |
|
51
|
|
|
|
|
52
|
|
|
$this->assertTrue($normalizer->supportsNormalization(new SimplifiedRequest())); |
|
53
|
|
|
$this->assertFalse($normalizer->supportsNormalization(new stdClass())); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|