|
38 | 38 | $this->http->request(payload: Payload::create(uri: 'api/2/issues')); |
39 | 39 | }); |
40 | 40 |
|
41 | | -it('can send valid request and receive invalid response (errorMessage)', function () { |
| 41 | +it('can send valid request and receive invalid response (errorMessage)', function (string $function) { |
42 | 42 | $this->client->shouldReceive('sendRequest') |
43 | 43 | ->once() |
44 | 44 | ->andReturn(new Response(status: 400, body: json_encode(errorMessage()))); |
45 | 45 |
|
46 | | - $this->http->request(payload: Payload::create(uri: 'api/2/issues')); |
47 | | -})->throws(ErrorException::class, errorMessage()['errorMessage'], 0); |
| 46 | + $this->http->{$function}(payload: Payload::create(uri: 'api/2/issues')); |
| 47 | +}) |
| 48 | + ->with('functions') |
| 49 | + ->throws(ErrorException::class, errorMessage()['errorMessage'], 0); |
48 | 50 |
|
49 | | -it('can send valid request and receive invalid response (errorMessages)', function () { |
| 51 | +it('can send valid request and receive invalid response (errorMessages)', function (string $function) { |
50 | 52 | $this->client->shouldReceive('sendRequest') |
51 | 53 | ->once() |
52 | 54 | ->andReturn(new Response(status: 400, body: json_encode(errorMessages()))); |
53 | 55 |
|
54 | | - $this->http->request(payload: Payload::create(uri: 'api/2/issues')); |
55 | | -})->throws(ErrorException::class, errorMessages()['errorMessages'][0], 0); |
| 56 | + $this->http->{$function}(payload: Payload::create(uri: 'api/2/issues')); |
| 57 | +}) |
| 58 | + ->with('functions') |
| 59 | + ->throws(ErrorException::class, errorMessages()['errorMessages'][0], 0); |
56 | 60 |
|
57 | | -it('can send valid request and receive invalid response (errors)', function () { |
| 61 | +it('can send valid request and receive invalid response (errors)', function (string $function) { |
58 | 62 | $this->client->shouldReceive('sendRequest') |
59 | 63 | ->once() |
60 | 64 | ->andReturn(new Response(status: 400, body: json_encode(errors()))); |
61 | 65 |
|
62 | | - $this->http->request(payload: Payload::create(uri: 'api/2/issues')); |
63 | | -})->throws(ErrorException::class, errors()['errors']['customfield_18208'], 0); |
| 66 | + $this->http->{$function}(payload: Payload::create(uri: 'api/2/issues')); |
| 67 | +}) |
| 68 | + ->with('functions') |
| 69 | + ->throws(ErrorException::class, errors()['errors']['customfield_18208'], 0); |
64 | 70 |
|
65 | 71 | it('can send valid request and receive invalid response (syntax)', function () { |
66 | 72 | $this->client->shouldReceive('sendRequest') |
|
70 | 76 | $this->http->request(payload: Payload::create(uri: 'api/2/issues')); |
71 | 77 | })->throws(UnserializableResponse::class, 'Syntax error', 0); |
72 | 78 |
|
73 | | -it('will fail because of a client errors', function () { |
| 79 | +it('will fail because of a client errors', function (string $function) { |
74 | 80 | $payload = Payload::create( |
75 | 81 | uri: 'api/2/issues', |
76 | 82 | ); |
|
87 | 93 | ) |
88 | 94 | ); |
89 | 95 |
|
90 | | - $this->http->request(payload: $payload); |
91 | | -})->throws(TransporterException::class, 'Could not resolve host.', 0); |
| 96 | + $this->http->{$function}(payload: $payload); |
| 97 | +}) |
| 98 | + ->with('functions') |
| 99 | + ->throws(TransporterException::class, 'Could not resolve host.', 0); |
| 100 | + |
| 101 | +it('can send valid requestContent and receive valid response', function () { |
| 102 | + $this->client->shouldReceive('sendRequest') |
| 103 | + ->once() |
| 104 | + ->andReturn(new Response(body: '')); |
| 105 | + |
| 106 | + $this->http->requestContent(payload: Payload::create(uri: 'https://www.example.com/jira/attachments/10000', query: ['a' => 'b'])); |
| 107 | +}); |
0 commit comments