Total Complexity | 9 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | class CheckExpectations |
||
6 | { |
||
7 | private $last; |
||
8 | |||
9 | /** |
||
10 | * CheckExpectations constructor. |
||
11 | * |
||
12 | * @param $last |
||
13 | */ |
||
14 | public function __construct($last) |
||
17 | } |
||
18 | |||
19 | public function check() |
||
20 | { |
||
21 | $this->checkExceptions(); |
||
22 | $this->fireEvents(); |
||
23 | $this->checkResponse(); |
||
24 | } |
||
25 | |||
26 | private function checkResponse() |
||
27 | { |
||
28 | if (! $this->last->http) { |
||
29 | return; |
||
30 | } |
||
31 | $method = $this->last->http['method']; |
||
32 | |||
33 | $response = $this->last->app->$method($this->last->http['url'], $this->last->http['data']); |
||
34 | |||
35 | foreach ($this->last->assertion as $assertion) { |
||
36 | $type = $assertion['type']; |
||
37 | $response->$type($assertion['value']); |
||
38 | } |
||
39 | } |
||
40 | |||
41 | private function fireEvents() |
||
42 | { |
||
43 | if ($this->last->event) { |
||
44 | event($this->last->event); |
||
45 | } |
||
46 | } |
||
47 | |||
48 | private function checkExceptions() |
||
52 | } |
||
53 | } |
||
54 | } |