Skip to content

Commit

Permalink
Mark command responses successful for both OK and SKIPPED statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraM committed Jan 17, 2019
1 parent 15514f3 commit 6c6d66e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
### Changed
- Invalid command inside recommendation/sorting request does not cause whole request to fail, rather the specific command response is marked as invalid.
- Deprecated `CommandResponse::STATUS_ERROR`, because Matej no longer uses it (`CommandResponse::STATUS_INVALID` is instead used everywhere).
- Method `CommandResponse::isSuccessfull()` now returns true even for not only OK but also SKIPPED (ie. not invalid) statuses.
This also means `Response::getNumberOfSuccessfulCommands()` now won't necessarily return the same number of command responses that return true on `CommandResponse::isSuccessful()`.

## 2.2.0 - 2018-10-02
### Added
Expand Down
5 changes: 4 additions & 1 deletion src/Model/CommandResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public function getData(): array

public function isSuccessful(): bool
{
return $this->getStatus() === static::STATUS_OK;
// Both OK and SKIPPED command responses are marked as successful to allow easy "command did not fail" detection.
// This also means `Response::getNumberOfSuccessfulCommands()` don't necessarily return the same number of
// command responses that return true on `CommandResponse::isSuccessful()`.
return $this->getStatus() === static::STATUS_OK || $this->getStatus() === static::STATUS_SKIPPED;
}
}
2 changes: 1 addition & 1 deletion tests/unit/Model/CommandResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function provideResponseStatuses(): array
return [
['status' => CommandResponse::STATUS_OK, 'isSuccessful' => true],
['status' => CommandResponse::STATUS_INVALID, 'isSuccessful' => false],
['status' => CommandResponse::STATUS_SKIPPED, 'isSuccessful' => false] ,
['status' => CommandResponse::STATUS_SKIPPED, 'isSuccessful' => true] ,
];
}

Expand Down

0 comments on commit 6c6d66e

Please sign in to comment.