Total Complexity | 10 |
Total Lines | 101 |
Duplicated Lines | 0 % |
Coverage | 53.33% |
Changes | 0 |
1 | <?php |
||
5 | class HttpClient |
||
6 | { |
||
7 | public $http = []; |
||
8 | |||
9 | public $assertion; |
||
10 | |||
11 | public $app; |
||
12 | |||
13 | public $event; |
||
14 | |||
15 | public $exception; |
||
16 | |||
17 | /** |
||
18 | * HttpClient constructor. |
||
19 | * |
||
20 | * @param $app |
||
21 | */ |
||
22 | 26 | public function __construct($app) |
|
25 | 26 | } |
|
26 | |||
27 | 2 | public function sendingPostRequest($uri, array $data = [], array $headers = []): IsRespondedWith |
|
28 | { |
||
29 | 2 | $this->http = [ |
|
30 | 2 | 'method' => 'post', |
|
31 | 2 | 'url' => $uri, |
|
32 | 2 | 'data' => $data, |
|
33 | 2 | 'headers' => $headers, |
|
34 | ]; |
||
35 | |||
36 | 2 | return new IsRespondedWith($this); |
|
37 | } |
||
38 | |||
39 | public function sendingDeleteRequest($uri, array $data = [], array $headers = []) |
||
40 | { |
||
41 | $this->http = [ |
||
42 | 'method' => 'delete', |
||
43 | 'url' => $uri, |
||
44 | 'data' => $data, |
||
45 | 'headers' => $headers, |
||
46 | ]; |
||
47 | |||
48 | return new IsRespondedWith($this); |
||
49 | } |
||
50 | |||
51 | public function sendingPutRequest($uri, array $data = [], array $headers = []) |
||
52 | { |
||
53 | $this->http = [ |
||
54 | 'method' => 'put', |
||
55 | 'url' => $uri, |
||
56 | 'data' => $data, |
||
57 | 'headers' => $headers, |
||
58 | ]; |
||
59 | |||
60 | return new IsRespondedWith($this); |
||
61 | } |
||
62 | |||
63 | public function sendingPatchRequest($uri, array $data = [], array $headers = []) |
||
64 | { |
||
65 | $this->http = [ |
||
66 | 'method' => 'patch', |
||
67 | 'url' => $uri, |
||
68 | 'data' => $data, |
||
69 | 'headers' => $headers, |
||
70 | ]; |
||
71 | |||
72 | return new IsRespondedWith($this); |
||
73 | } |
||
74 | |||
75 | 23 | public function sendingGetRequest($url): IsRespondedWith |
|
76 | { |
||
77 | 23 | $this->http = [ |
|
78 | 23 | 'method' => 'get', |
|
79 | 23 | 'url' => $url, |
|
80 | 'data' => [], |
||
81 | ]; |
||
82 | |||
83 | 23 | return new IsRespondedWith($this); |
|
84 | } |
||
85 | |||
86 | 1 | public function exceptionIsThrown($type) |
|
87 | { |
||
88 | 1 | $this->exception = $type; |
|
89 | 1 | } |
|
90 | |||
91 | 1 | public function whenEventHappens($event) |
|
96 | } |
||
97 | |||
98 | 26 | public function whenYouReachCheckPoint($name) |
|
99 | { |
||
100 | 26 | return $this->whenEventHappens('heyman_checkpoint_'.$name); |
|
101 | 25 | } |
|
102 | |||
103 | public function __destruct() |
||
108 |