Ejemplo n.º 1
0
 /**
  * Tries to parse the error response xml from the AdWords API server as an
  * object. This method is used in parsing all error responses when API
  * version >= v201209, and in other versions when apiMode header is mentioned
  * in the request headers.
  *
  * @param String $responseXml the error response xml
  * @return Object the parsed error object, or null if the response cannot
  * be parsed.
  */
 private static function ParseApiErrorXml($responseXml)
 {
     $retval = null;
     try {
         $doc = XmlUtils::GetDomFromXml($responseXml);
         $retval = XmlUtils::ConvertDocumentToObject($doc);
         if (!is_array($retval->ApiError)) {
             $retval->ApiError = array($retval->ApiError);
         }
     } catch (Exception $e) {
         // There was a parse exception and hence this response cannot be
         // interpreted as an xml.
     }
     return $retval;
 }
Ejemplo n.º 2
0
 /**
  * Test converting a DOM document to an object.
  * @param string $xml the XML to convert
  * @param Object $expected the expected result of the conversion
  * @covers XmlUtils::ConvertDocumentToObject
  * @covers XmlUtils::ConvertElementToObject
  * @covers XmlUtils::ConvertNodeValueToObject
  * @dataProvider XmlToObjectProvider
  */
 public function testConvertDocumentToObject($xml, $expected)
 {
     $document = XmlUtils::GetDomFromXml($xml);
     $result = XmlUtils::ConvertDocumentToObject($document);
     $this->assertEquals($expected, $result);
 }