Total Complexity | 11 |
Total Lines | 67 |
Duplicated Lines | 0 % |
Coverage | 96.67% |
Changes | 0 |
1 | <?php |
||
5 | class CheckExpectations |
||
6 | { |
||
7 | private $chain; |
||
8 | |||
9 | private $phpunit; |
||
10 | |||
11 | /** |
||
12 | * CheckExpectations constructor. |
||
13 | * |
||
14 | * @param $chain |
||
15 | * @param $phpunit |
||
16 | */ |
||
17 | 32 | public function __construct($chain, $phpunit) |
|
21 | 32 | } |
|
22 | |||
23 | 32 | public function check() |
|
24 | { |
||
25 | 32 | $this->expectExceptions(); |
|
26 | 32 | $this->fireEvents(); |
|
27 | 31 | $this->checkResponse(); |
|
28 | 31 | } |
|
29 | |||
30 | 31 | private function checkResponse() |
|
31 | { |
||
32 | 31 | if (!$this->chain->http) { |
|
33 | return; |
||
34 | } |
||
35 | 31 | $this->checkResponses($this->sendRequest()); |
|
36 | 31 | } |
|
37 | |||
38 | /** |
||
39 | * @return mixed |
||
40 | */ |
||
41 | 31 | private function sendRequest() |
|
48 | } |
||
49 | |||
50 | /** |
||
51 | * @param $response |
||
52 | */ |
||
53 | 31 | private function checkResponses($response) |
|
54 | { |
||
55 | 31 | foreach ($this->chain->assertion as $assertion) { |
|
56 | 27 | $type = $assertion['type']; |
|
57 | 27 | $response->$type($assertion['value']); |
|
58 | } |
||
59 | 31 | } |
|
60 | |||
61 | 32 | private function fireEvents() |
|
62 | { |
||
63 | 32 | if ($this->chain->event) { |
|
64 | 1 | event($this->chain->event); |
|
65 | } |
||
66 | 31 | } |
|
67 | |||
68 | 32 | private function expectExceptions() |
|
72 | } |
||
73 | 32 | } |
|
74 | } |
||
75 |