Total Complexity | 6 |
Total Lines | 51 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | trait InteractsWithApi |
||
8 | { |
||
9 | public $user; |
||
10 | |||
11 | /** |
||
12 | * @param null $data |
||
|
|||
13 | * @param array $params |
||
14 | * @param array $headers |
||
15 | * @return TestResponse |
||
16 | */ |
||
17 | protected function doAuthenticatedRequest($data, array $params = [], $headers = []) |
||
18 | { |
||
19 | return $this->actingAs($this->user, 'api')->doRequest($data, $params, $headers); |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * @param array $data |
||
24 | * @param array $params |
||
25 | * @param array $headers |
||
26 | * @return TestResponse |
||
27 | */ |
||
28 | protected function doRequest($data, array $params = [], $headers = []) |
||
29 | { |
||
30 | return $this->call( |
||
31 | $this->httpAction(), |
||
32 | route($this->routeName(), $params), |
||
33 | $data, |
||
34 | [], |
||
35 | [], |
||
36 | empty($headers) ? $this->defaultHeaders() : $headers |
||
37 | ); |
||
38 | } |
||
39 | |||
40 | protected function defaultHeaders() |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @param TestResponse $response |
||
47 | * @return array |
||
48 | */ |
||
49 | protected function getResponseData(TestResponse $response) |
||
58 | } |
||
59 | } |
||
60 |