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

ChainMatchingPolicySpec   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A it_returns_false_by_default() 0 4 1
A it_returns_true_when_all_policies_can_match_request_to_response_config() 0 15 1
1
<?php
2
3
namespace spec\Coduo\TuTu\Request;
4
5
use Coduo\TuTu\Config\Element;
6
use Coduo\TuTu\Request\MatchingPolicy;
7
use PhpSpec\ObjectBehavior;
8
use Prophecy\Argument;
9
use Symfony\Component\HttpFoundation\Request;
10
11
class ChainMatchingPolicySpec extends ObjectBehavior
12
{
13
    function it_returns_false_by_default()
14
    {
15
        $this->match(Request::create('/foo'), Element::fromArray(['request' => ['path' => '/foo']]))->shouldReturn(false);
16
    }
17
18
    function it_returns_true_when_all_policies_can_match_request_to_response_config(
19
        MatchingPolicy $positiveMatchingPolicy1,
20
        MatchingPolicy $positiveMatchingPolicy2
21
    ) {
22
        $this->addMatchingPolicy($positiveMatchingPolicy1);
23
        $this->addMatchingPolicy($positiveMatchingPolicy2);
24
25
        $responseConfig = Element::fromArray(['request' => ['path' => '/foo']]);
26
        $request        = Request::create('/foo');
27
28
        $positiveMatchingPolicy1->match($request, $responseConfig)->willReturn(true);
29
        $positiveMatchingPolicy2->match($request, $responseConfig)->willReturn(true);
30
31
        $this->match($request, $responseConfig)->shouldReturn(true);
32
    }
33
}
34