/**
  * Sets the exception error info from the Perun response.
  * 
  * @param Response $response
  */
 public function setErrorFromResponse(Response $response)
 {
     $this->setErrorId($response->getErrorId());
     $this->setErrorName($response->getErrorName());
     $this->setErrorType($response->getErrorType());
     $this->setErrorInfo($response->getErrorInfo());
     $this->setErrorMessage($response->getErrorMessage());
     $this->setPerunException($response->isPerunException());
     $this->message = sprintf("Perun %s [%s]: [%s] %s (%s)", $this->isPerunException() ? 'exception' : 'error', $this->getErrorId(), $this->getErrorName(), $this->getErrorMessage(), $this->getErrorInfo());
 }
 public function testConstructorWithError()
 {
     $errorId = 'testid';
     $errorType = 'testtype';
     $errorMessage = 'testmessage';
     $errorInfo = 'testinfo';
     $errorName = 'testname';
     $isPerunException = 'true';
     $request = $this->getRequestMock();
     $payload = $this->getPayloadMock($errorId, $errorType, $errorMessage, $errorInfo, $errorName, $isPerunException);
     $response = new Response($request, $payload);
     $this->assertTrue($response->isError());
     $this->assertSame($errorId, $response->getErrorId());
     $this->assertSame($errorType, $response->getErrorType());
     $this->assertSame($errorMessage, $response->getErrorMessage());
     $this->assertSame($errorInfo, $response->getErrorInfo());
     $this->assertSame($errorName, $response->getErrorName());
     $this->assertTrue($response->isPerunException());
 }