/**
  * Accounts for wrapper nodes
  * {@inheritdoc}
  */
 public function visit(CommandInterface $command, Response $response, Parameter $param, &$value, $context = null)
 {
     parent::visit($command, $response, $param, $value, $context);
     // Account for wrapper nodes (e.g. RDS, ElastiCache, etc)
     if ($param->getData('wrapper')) {
         $wireName = $param->getWireName();
         $value += $value[$wireName];
         unset($value[$wireName]);
     }
 }
 public function testAddsEmptyArraysWhenValueIsMissing()
 {
     $visitor = new Visitor();
     $param = new Parameter(array('name' => 'Foo', 'type' => 'array', 'location' => 'xml', 'items' => array('type' => 'object', 'properties' => array('Baz' => array('type' => 'array'), 'Bar' => array('type' => 'object', 'properties' => array('Baz' => array('type' => 'array')))))));
     $value = array();
     $visitor->visit($this->command, $this->response, $param, $value);
     $value = array('Foo' => array('Bar' => array()));
     $visitor->visit($this->command, $this->response, $param, $value);
     $this->assertEquals(array('Foo' => array(array('Bar' => array()))), $value);
 }
Esempio n. 3
0
 public function testAddsBooleanWhenValueIsMissing()
 {
     $visitor = new Visitor();
     $param = new Parameter(array('name' => 'Foo', 'type' => 'boolean', 'location' => 'xml'));
     $value = null;
     $visitor->visit($this->command, $this->response, $param, $value);
     $this->assertSame(array('Foo' => false), $value);
 }
Esempio n. 4
0
 public function testProperlyHandlesEmptyStringValues()
 {
     $visitor = new Visitor();
     $param = new Parameter(array('name' => 'foo', 'type' => 'object', 'properties' => array('bar' => array('type' => 'string'))));
     $xml = '<wrapper><foo><bar /></foo></wrapper>';
     $value = json_decode(json_encode(new \SimpleXMLElement($xml)), true);
     $visitor->visit($this->command, $this->response, $param, $value);
     $this->assertEquals(array('foo' => array('bar' => '')), $value);
 }
Esempio n. 5
0
 /**
  * @group issue-399
  * @link  https://github.com/guzzle/guzzle/issues/399
  */
 public function testDiscardingUnknownPropertiesWithAliasing()
 {
     $visitor = new Visitor();
     $param = new Parameter(array('name' => 'foo', 'type' => 'object', 'additionalProperties' => false, 'properties' => array('bar' => array('name' => 'bar', 'sentAs' => 'baz'))));
     $this->value = array('foo' => array('baz' => 15, 'unknown' => 'Unknown'));
     $visitor->visit($this->command, $this->response, $param, $this->value);
     $this->assertEquals(array('foo' => array('bar' => 15)), $this->value);
 }