Completed
Push — master ( c5de01...c9c19d )
by
unknown
07:34 queued 05:10
created

HeadersMatchingPolicySpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace spec\Coduo\TuTu\Request;
4
5
use Coduo\PHPMatcher\Factory\SimpleFactory;
6
use Coduo\TuTu\Config\Element;
7
use PhpSpec\ObjectBehavior;
8
use Prophecy\Argument;
9
use Symfony\Component\HttpFoundation\Request;
10
11
class HeadersMatchingPolicySpec extends ObjectBehavior
12
{
13
    function let()
14
    {
15
        $phpMatcher = (new SimpleFactory())->createMatcher();
16
        $this->beConstructedWith($phpMatcher);
17
    }
18
19
    function it_is_matching_policy()
20
    {
21
        $this->shouldBeAnInstanceOf('Coduo\TuTu\Request\MatchingPolicy');
22
    }
23
24
    function it_match_when_request_config_does_not_have_headers()
25
    {
26
        $responseConfig = Element::fromArray([
27
            'request' => [
28
                'path' => '/foo',
29
                'headers' => []
30
            ],
31
        ]);
32
        $request = Request::create('/foo');
33
34
        $this->match($request, $responseConfig)->shouldReturn(true);
35
    }
36
37
    function it_not_match_when_header_is_missing_in_request()
38
    {
39
        $responseConfig = Element::fromArray([
40
            'request' => [
41
                'path' => '/foo',
42
                'headers' => ['Header' => 'Value']
43
            ],
44
        ]);
45
        $request = Request::create('/foo');
46
47
        $this->match($request, $responseConfig)->shouldReturn(false);
48
    }
49
50 View Code Duplication
    function it_not_match_when_header_value_in_request_is_different_than_expected()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
    {
52
        $responseConfig = Element::fromArray([
53
            'request' => [
54
                'path' => '/foo',
55
                'headers' => ['Header' => 'Value']
56
            ],
57
        ]);
58
        $request = Request::create('/foo');
59
        $request->headers->add(['Header' => 'Different Value']);
60
61
        $this->match($request, $responseConfig)->shouldReturn(false);
62
    }
63
64 View Code Duplication
    function it_match_when_headers_from_config_are_equal_headers_from_request()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
65
    {
66
        $responseConfig = Element::fromArray([
67
            'request' => [
68
                'path' => '/foo',
69
                'headers' => [
70
                    'Header' => 'Value',
71
                    'Header1' => 'Value1'
72
                ]
73
            ],
74
        ]);
75
        $request = Request::create('/foo');
76
        $request->headers->add([
77
            'Header' => 'Value',
78
            'Header1' => 'Value1'
79
        ]);
80
81
        $this->match($request, $responseConfig)->shouldReturn(true);
82
    }
83
}
84