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:
parent
9b99f7af10
commit
673b4017f5
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user