public function testResponseFailureHelper() { $failureResponseError = 'failure'; $failureResponseCode = 'InternalError'; $failureResponse = Response::failure(null, $failureResponseError, $failureResponseCode); self::assertFalse($failureResponse->isOk()); self::assertNotNull($failureResponse->getError()); self::assertNotNull($failureResponse->getErrorMessage()); self::assertNotNull($failureResponse->getErrorCode()); }
/** * Реализует взаимодействие с внешним сервисом * * @param string $method Вызываемый метод * @param array $args Аргументы вызываемого метода * * @return Response * @throws InvalidParameterException */ protected function implementation($method, array $args = array()) { try { $raw = call_user_func_array(array($this->client, $method), $args); $raw = $this->map($method, $raw); return Response::success($raw); } catch (SoapFault $fault) { return Response::failure(null, $fault->getMessage(), $fault->faultcode); } }
/** * Реализует конкретное взаимодействие с внешним источником * * @param string $method Вызываемый метод * @param array $args Аргументы вызываемого метода * * @return Response */ protected function implementation($method, array $args = array()) { $this->logger->info(var_export($args, true)); array_unshift($args, $this->client); try { $raw = call_user_func_array(sprintf('ldap_%s', $method), $args); return Response::success($raw); } catch (\Exception $e) { return Response::failure(null, $e->getMessage()); } }