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

MethodMatchingPolicySpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 28
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_matching_policy() 0 4 1
A it_return_true_when_config_does_not_have_allowed_methods() 0 4 1
A it_return_true_when_request_method_is_in_response_config_allowed_methods() 0 7 1
A it_return_false_when_request_method_is_not_in_response_config_allowed_methods() 0 7 1
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