-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix integration tests #10
base: integration-tests-issues
Are you sure you want to change the base?
Changes from 5 commits
f37b711
0c32a43
ef7ece7
db4eb5e
3cb0bbb
036b776
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,13 +35,16 @@ protected function getPayload( | |
// This handles inconsistency in ShipX API. Some errors have HTTP status code 200 and error data in body. | ||
if (isset($data['status']) && $data['status'] !== 200 && isset($data['key']) && isset($data['error'])) { | ||
return new Error([ | ||
'status' => $data['status'], | ||
'error' => $data['key'], | ||
'message' => $data['error'] | ||
'status' => $data['status'] ?? $httpResponse->getStatusCode(), | ||
'error' => $data['key'] ?? '', | ||
'message' => $data['error'] ?? '', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @snapshotpl These three lines of changes are unnecessary. Existence of |
||
]); | ||
} | ||
return null; | ||
} | ||
$data['status'] ??= $httpResponse->getStatusCode(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @snapshotpl Wow! I didn't know |
||
$data['error'] = $data['key'] ?? ''; | ||
$data['message'] = $data['error'] ?? ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @snapshotpl The default (documented) error response has I know the whole thing is stupid, but inconsistency of Inpost API is even more stupid 👎. |
||
return new Error($data); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -49,7 +49,12 @@ protected function assertSuccessWithFile(Response $response, DataTransferObject | |||
{ | ||||
if (!$response->getSuccess()) { | ||||
$this->debug(print_r($response->getPayload()->toArray(), true)); | ||||
|
||||
if ($response->getPayload()->status === 500) { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @snapshotpl In what cases did you encounter 500 errors? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you encounter this 500 error every time you perform a request? I have never had issues with this one, nor do I have it now... I would rather not skip test because of 500 error. Such mechanism might hide some real issues in the future. |
||||
$this->markTestSkipped('500 error: '. $response->getPayload()->message); | ||||
} | ||||
} | ||||
|
||||
$this->assertTrue($response->getSuccess()); | ||||
$this->assertInstanceOf(BinaryContent::class, $payload); | ||||
/** @var BinaryContent $payload */ | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@snapshotpl This three lines of changes are unnecessary. Existence of
status
,key
anderror
is already checked inif
condition.