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

RouteMatchingPolicySpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 40
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_matching_policy() 0 4 1
A it_match_when_request_path_is_equal_to_response_config_path() 0 7 1
A it_match_when_request_path_is_equal_to_response_config_path_but_contain_upercase_chars() 0 7 1
A it_match_paths_with_placeholders() 0 7 1
A it_does_not_match_when_request_path_is_not_matching_response_config_path() 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 RouteMatchingPolicySpec extends ObjectBehavior
11
{
12
    function it_is_matching_policy()
13
    {
14
        $this->shouldBeAnInstanceOf('Coduo\TuTu\Request\MatchingPolicy');
15
    }
16
17
    function it_match_when_request_path_is_equal_to_response_config_path()
18
    {
19
        $responseConfig = Element::fromArray(['request' => ['path' => '/foo']]);
20
        $request        = Request::create('/foo');
21
22
        $this->match($request, $responseConfig)->shouldReturn(true);
23
    }
24
25
    function it_match_when_request_path_is_equal_to_response_config_path_but_contain_upercase_chars()
26
    {
27
        $responseConfig = Element::fromArray(['request' => ['path' => '/FOo']]);
28
        $request        = Request::create('/foo');
29
30
        $this->match($request, $responseConfig)->shouldReturn(true);
31
    }
32
33
    function it_match_paths_with_placeholders()
34
    {
35
        $responseConfig = Element::fromArray(['request' => ['path' => '/foo/{id}/bar/{name}']]);
36
        $request        = Request::create('/foo/1/bar/norbert');
37
38
        $this->match($request, $responseConfig)->shouldReturn(true);
39
    }
40
41
42
    function it_does_not_match_when_request_path_is_not_matching_response_config_path()
43
    {
44
        $responseConfig = Element::fromArray(['request' => ['path' => '/foo/bar']]);
45
        $request        = Request::create('/foo/baz');
46
47
        $this->match($request, $responseConfig)->shouldReturn(false);
48
    }
49
}
50