示例#1
0
 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);
 }
 /**
  * {@inheritdoc}
  */
 public function before(CommandInterface $command, array &$result)
 {
     parent::before($command, $result);
     // Unwrapped wrapped responses
     $operation = $command->getOperation();
     if ($operation->getServiceDescription()->getData('resultWrapped')) {
         $wrappingNode = $operation->getName() . 'Result';
         if (isset($result[$wrappingNode])) {
             $result = $result[$wrappingNode] + $result;
             unset($result[$wrappingNode]);
         }
     }
 }