Completed
Pull Request — master (#46)
by
unknown
05:21
created

ParameterMatchingPolicySpec::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 ParameterMatchingPolicySpec 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_body_and_query_params_are_empty()
25
    {
26
        $responseConfig = Element::fromArray([
27
            'request' => [
28
                'path' => '/foo',
29
                'request' => [],
30
                'query' => []
31
            ],
32
        ]);
33
        $request = Request::create('/foo');
34
35
        $this->match($request, $responseConfig)->shouldReturn(true);
36
    }
37
38
    function it_not_match_when_request_config_query_parameter_does_not_exist_in_request_query()
39
    {
40
        $responseConfig = Element::fromArray([
41
            'request' => [
42
                'path' => '/foo',
43
                'query' => [
44
                    'foo' => 'bar'
45
                ]
46
            ],
47
        ]);
48
        $request = Request::create('/foo');
49
50
        $this->match($request, $responseConfig)->shouldReturn(false);
51
    }
52
53
    function it_not_match_when_request_config_query_parameter_is_different_than_request_query_param()
54
    {
55
        $responseConfig = Element::fromArray([
56
            'request' => [
57
                'path' => '/foo',
58
                'query' => [
59
                    'foo' => 'bar'
60
                ]
61
            ],
62
        ]);
63
        $request = Request::create('/foo?foo=baz');
64
65
        $this->match($request, $responseConfig)->shouldReturn(false);
66
    }
67
68 View Code Duplication
    function it_not_match_when_request_config_body_parameter_does_not_exist_in_request_body()
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...
69
    {
70
        $responseConfig = Element::fromArray([
71
            'request' => [
72
                'path' => '/foo',
73
                'request' => [
74
                    'foo' => 'bar'
75
                ]
76
            ],
77
        ]);
78
        $request = Request::create('/foo', 'POST', []);
79
80
        $this->match($request, $responseConfig)->shouldReturn(false);
81
    }
82
83 View Code Duplication
    function it_not_match_when_request_config_body_parameter_is_different_than_request_body_param()
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...
84
    {
85
        $responseConfig = Element::fromArray([
86
            'request' => [
87
                'path' => '/foo',
88
                'request' => [
89
                    'foo' => 'bar'
90
                ]
91
            ],
92
        ]);
93
        $request = Request::create('/foo', 'POST', ['foo' => 'baz']);
94
95
        $this->match($request, $responseConfig)->shouldReturn(false);
96
    }
97
98
99 View Code Duplication
    function it_match_when_request_config_query_and_body_parameters_match_parameters_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...
100
    {
101
        $responseConfig = Element::fromArray([
102
            'request' => [
103
                'path' => '/foo',
104
                'query' => [
105
                    'foo' => 'bar'
106
                ],
107
                'request' => [
108
                    'foo' => 'bar'
109
                ]
110
            ],
111
        ]);
112
        $request = Request::create('/foo?foo=bar', 'POST', ['foo' => 'bar']);
113
114
        $this->match($request, $responseConfig)->shouldReturn(true);
115
    }
116
}
117