/**
  * Initializes the class with the given body XML response
  *
  * @param string $body
  * @throws IntacctException
  * @throws ResponseException
  */
 public function __construct($body)
 {
     libxml_use_internal_errors(true);
     $this->xml = simplexml_load_string($body, 'SimpleXMLIterator');
     if ($this->xml === false) {
         throw new IntacctException('XML could not be parsed properly');
     }
     libxml_clear_errors();
     libxml_use_internal_errors(false);
     if (!isset($this->xml->control)) {
         throw new IntacctException('Response is missing control block');
     }
     $this->setControl($this->xml->control);
     if ($this->control->getStatus() !== 'success') {
         $errors = [];
         if (isset($this->xml->errormessage)) {
             $errorMessage = new ErrorMessage($this->xml->errormessage);
             $errors = $errorMessage->getErrors();
         }
         throw new ResponseException('Response control status failure', $errors);
     }
 }
Example #2
0
 /**
  * @covers Intacct\Xml\Response\Control::getStatus
  */
 public function testGetStatus()
 {
     $this->assertEquals('success', $this->object->getStatus());
 }