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

MethodMatchingPolicySpec::it_is_matching_policy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace spec\Coduo\TuTu\Request;
4
5
use Coduo\TuTu\Config\Element;
6
use PhpSpec\ObjectBehavior;
7
use Prophecy\Argument;
8
use Symfony\Component\HttpFoundation\Request;
9
10
class MethodMatchingPolicySpec extends ObjectBehavior
11
{
12
    function it_is_matching_policy()
13
    {
14
        $this->shouldBeAnInstanceOf('Coduo\TuTu\Request\MatchingPolicy');
15
    }
16
17
    function it_return_true_when_config_does_not_have_allowed_methods()
18
    {
19
        $this->match(Request::create('/foo'), Element::fromArray(['request' => ['path' => '/foo']]))->shouldReturn(true);
20
    }
21
22
    function it_return_true_when_request_method_is_in_response_config_allowed_methods()
23
    {
24
        $responseConfig = Element::fromArray(['request' => ['path' => '/foo', 'methods' => ['POST']]]);
25
        $request        = Request::create('/foo', 'POST');
26
27
        $this->match($request, $responseConfig)->shouldReturn(true);
28
    }
29
30
    function it_return_false_when_request_method_is_not_in_response_config_allowed_methods()
31
    {
32
        $responseConfig = Element::fromArray(['request' => ['path' => '/foo', 'methods' => ['POST']]]);
33
        $request        = Request::create('/foo', 'GET');
34
35
        $this->match($request, $responseConfig)->shouldReturn(false);
36
    }
37
}
38