1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-25 02:22:57 +01:00

Fixing regression introduced when parsing nested XML.

This commit is contained in:
Michael Dowling 2013-05-08 00:04:38 -07:00
parent 9b99f7af10
commit 673b4017f5
2 changed files with 15 additions and 1 deletions

View File

@ -17,7 +17,7 @@ class XmlVisitor extends AbstractResponseVisitor
public function before(CommandInterface $command, array &$result)
{
// Set the result of the command to the array conversion of the XML body
$result = get_object_vars($command->getResponse()->xml());
$result = json_decode(json_encode($command->getResponse()->xml()), true);
}
/**

View File

@ -25,6 +25,20 @@ class XmlVisitorTest extends AbstractResponseVisitorTest
$this->assertEquals(array('Bar' => 'test'), $result);
}
public function testBeforeMethodParsesNestedXml()
{
$visitor = new Visitor();
$command = $this->getMockBuilder('Guzzle\Service\Command\AbstractCommand')
->setMethods(array('getResponse'))
->getMockForAbstractClass();
$command->expects($this->once())
->method('getResponse')
->will($this->returnValue(new Response(200, null, '<foo><Items><Bar>test</Bar></Items></foo>')));
$result = array();
$visitor->before($command, $result);
$this->assertEquals(array('Items' => array('Bar' => 'test')), $result);
}
public function testCanExtractAndRenameTopLevelXmlValues()
{
$visitor = new Visitor();