1 | <?php |
||||||
2 | |||||||
3 | namespace Digitonic\ApiTestSuite\Concerns; |
||||||
4 | |||||||
5 | use Illuminate\Foundation\Testing\TestResponse; |
||||||
6 | |||||||
7 | trait InteractsWithApi |
||||||
8 | { |
||||||
9 | public $user; |
||||||
10 | |||||||
11 | /** |
||||||
12 | * @param null $data |
||||||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||||||
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); |
||||||
0 ignored issues
–
show
It seems like
actingAs() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
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( |
||||||
0 ignored issues
–
show
It seems like
call() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
31 | $this->httpAction(), |
||||||
0 ignored issues
–
show
It seems like
httpAction() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
32 | route($this->routeName(), $params), |
||||||
0 ignored issues
–
show
It seems like
routeName() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
33 | $data, |
||||||
34 | [], |
||||||
35 | [], |
||||||
36 | empty($headers) ? $this->defaultHeaders() : $headers |
||||||
37 | ); |
||||||
38 | } |
||||||
39 | |||||||
40 | protected function defaultHeaders() |
||||||
41 | { |
||||||
42 | return config('digitonic.api-test-suite.default_headers'); |
||||||
43 | } |
||||||
44 | |||||||
45 | /** |
||||||
46 | * @param TestResponse $response |
||||||
47 | * @return array |
||||||
48 | */ |
||||||
49 | protected function getResponseData(TestResponse $response) |
||||||
50 | { |
||||||
51 | $data = json_decode($response->getContent(), true); |
||||||
52 | |||||||
53 | if (!isset($data['data'])) { |
||||||
54 | $this->fail('The response data is empty. Content: '. $response->getContent()); |
||||||
0 ignored issues
–
show
It seems like
fail() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
55 | } |
||||||
56 | |||||||
57 | return $data['data']; |
||||||
58 | } |
||||||
59 | } |
||||||
60 |