public function testCreateFromResponse() { $errorId = 123; $response = $this->getResponseMock(); $response->expects($this->once())->method('getErrorId')->will($this->returnValue($errorId)); $e = PerunErrorException::createFromResponse($response); $this->assertInstanceOf('InoPerunApi\\Manager\\Exception\\PerunErrorException', $e); $this->assertSame($errorId, $e->getErrorId()); }
/** * Performs a remote call to a manager method. * @param string $methodName * @param array $params * @param string $changeState * @throws Exception\ClientRuntimeException * @throws Exception\PerunErrorException * @return EntityInterface|Collection */ public function callMethod($methodName, array $params = array(), $changeState = null) { $params = $this->paramsToArray($params); try { $response = $this->client->sendRequest($this->managerName, $methodName, $params, $changeState); } catch (\Exception $e) { throw new Exception\ClientRuntimeException(sprintf("Exception during client request: [%s] %s", get_class($e), $e->getMessage()), null, $e); } if ($response->isError()) { throw PerunErrorException::createFromResponse($response); } return $this->getEntityFactory()->createFromResponsePayload($response->getPayload()); }