Completed
Push — master ( c5de01...c9c19d )
by
unknown
07:34 queued 05:10
created

ResolverSpec::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 2
1
<?php
2
3
namespace spec\Coduo\TuTu\Config;
4
5
use Coduo\TuTu\Config\Loader\Loader;
6
use Coduo\TuTu\Request\MatchingPolicy;
7
use PhpSpec\ObjectBehavior;
8
use Prophecy\Argument;
9
use Symfony\Component\HttpFoundation\Request;
10
11
class ResolverSpec extends ObjectBehavior
12
{
13
    function let(Loader $loader, MatchingPolicy $matchingPolicy)
14
    {
15
        $loader->getResponsesArray()->willReturn([]);
16
        $this->beConstructedWith($loader, $matchingPolicy);
17
    }
18
19
    function it_resolve_config_when_matching_policy_match_request_to_response_config(Loader $loader, MatchingPolicy $matchingPolicy)
20
    {
21
        $loader->getResponsesArray()->willReturn([
22
            [
23
                'request' => [
24
                    'path' => '/foo/index',
25
                    'methods' => ['POST']
26
                ]
27
            ]
28
        ]);
29
30
        $request = Request::create('/foo/index', 'POST');
31
        $matchingPolicy->match($request, Argument::type('Coduo\TuTu\Config\Element'))->willReturn(true);
32
33
        $this->resolveConfigElement($request)->shouldReturnAnInstanceOf('Coduo\TuTu\Config\Element');
34
    }
35
36
    function it_return_null_when_matching_policy_cant_match_request(MatchingPolicy $matchingPolicy)
37
    {
38
        $request = Request::create('/foo/index', 'POST');
39
        $matchingPolicy->match($request, Argument::type('Coduo\TuTu\Config\Element'))->willReturn(false);
40
41
        $this->resolveConfigElement($request)->shouldReturn(null);
42
    }
43
}
44