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

it_match_paths_with_placeholders()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
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 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