Пример #1
0
 /**
  * @dataProvider isErrorProvider
  *
  * @covers ::isError
  * @covers ::isOk
  * @covers ::mayHaveBody
  *
  * @param int  $code
  * @param bool $isError
  * @param bool $isOk
  * @param bool $mayHaveBody
  */
 public function test_isError($code, $isError, $isOk, $mayHaveBody)
 {
     // When
     $gotIsOk = HttpCodes::isOk($code);
     $gotIsError = HttpCodes::isError($code);
     $gotMayHaveBody = HttpCodes::mayHaveBody($code);
     // Then
     $this->assertSame($isOk, $gotIsOk);
     $this->assertSame($isError, $gotIsError);
     $this->assertSame($mayHaveBody, $gotMayHaveBody);
 }
Пример #2
0
 /**
  * Check if a response is a success.
  *
  * @param stdClass $response The AJAX response in a format returned by buildResponse method
  *
  * @return bool
  */
 public static function isSuccess(stdClass $response)
 {
     if (is_object($response) && $response->success == true) {
         return HttpCodes::isOk($response->http_code);
     } else {
         return false;
     }
 }