Completed
Push — EZP-31287 ( fe8c5c...af9523 )
by
unknown
34:01
created

SimplifiedRequestNormalizerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testNormalize() 0 31 1
A testSupportsNormalization() 0 7 1
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