Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/php/webservices/rest/RestResponse.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public function __construct($status, $message, $headers= [], $reader= null, $uri
/** @return int */
public function status() { return $this->status; }

/** @return bool */
public function ok() { return $this->status >= 200 && $this->status <= 299; }

/** @return string */
public function message() { return $this->message; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public function status() {
Assert::equals(200, (new RestResponse(200, 'OK'))->status());
}

#[Test, Values([[200, true], [202, true], [299, true], [100, false], [300, false], [400, false]])]
public function ok($status, $expected) {
Assert::equals($expected, (new RestResponse($status, 'Status #'.$status))->ok());
}

#[Test]
public function message() {
Assert::equals('OK', (new RestResponse(200, 'OK'))->message());
Expand Down
Loading