|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Imanghafoori\HeyMan\MakeSure; |
|
4
|
|
|
|
|
5
|
|
|
class HttpClient |
|
6
|
|
|
{ |
|
7
|
|
|
public $app; |
|
8
|
|
|
|
|
9
|
|
|
private $chain; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* HttpClient constructor. |
|
13
|
|
|
* |
|
14
|
|
|
* @param $app |
|
15
|
|
|
*/ |
|
16
|
|
|
public function __construct($app) |
|
17
|
|
|
{ |
|
18
|
|
|
$this->chain = new Chain($app); |
|
19
|
|
|
$this->app = $app; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
27 |
|
public function sendingPostRequest($uri, array $data = [], array $headers = []): IsRespondedWith |
|
23
|
|
|
{ |
|
24
|
27 |
|
$this->chain->http($uri, $data, $headers, 'post'); |
|
25
|
27 |
|
|
|
26
|
|
|
return new IsRespondedWith($this->chain); |
|
27
|
2 |
|
} |
|
28
|
|
|
|
|
29
|
2 |
|
public function sendingDeleteRequest($uri, array $data = [], array $headers = []) |
|
30
|
|
|
{ |
|
31
|
2 |
|
$this->chain->http($uri, $data, $headers, 'delete'); |
|
32
|
|
|
|
|
33
|
|
|
return new IsRespondedWith($this->chain); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function sendingPutRequest($uri, array $data = [], array $headers = []) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->chain->http($uri, $data, $headers, 'put'); |
|
39
|
|
|
|
|
40
|
|
|
return new IsRespondedWith($this->chain); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function sendingPatchRequest($uri, array $data = [], array $headers = []) |
|
44
|
|
|
{ |
|
45
|
|
|
$this->chain->http($uri, $data, $headers, 'patch'); |
|
46
|
|
|
|
|
47
|
|
|
return new IsRespondedWith($this->chain); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function sendingGetRequest($url): IsRespondedWith |
|
51
|
|
|
{ |
|
52
|
|
|
$this->chain->http = [ |
|
53
|
|
|
'method' => 'get', |
|
54
|
|
|
'url' => $url, |
|
55
|
24 |
|
'data' => [], |
|
56
|
|
|
]; |
|
57
|
24 |
|
|
|
58
|
24 |
|
return new IsRespondedWith($this->chain); |
|
59
|
24 |
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function exceptionIsThrown($type) |
|
62
|
|
|
{ |
|
63
|
24 |
|
$this->chain->exception = $type; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
1 |
|
public function whenEventHappens($event) |
|
67
|
|
|
{ |
|
68
|
1 |
|
$this->chain->event = $event; |
|
69
|
1 |
|
|
|
70
|
|
|
return $this; |
|
71
|
1 |
|
} |
|
72
|
|
|
|
|
73
|
1 |
|
public function whenYouReachCheckPoint($name) |
|
74
|
|
|
{ |
|
75
|
1 |
|
return $this->whenEventHappens('heyman_checkpoint_'.$name); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|