public function testCanAddArrayOfSimpleTypes() { $request = new EntityEnclosingRequest('POST', 'http://foo.com'); $visitor = new XmlVisitor(); $param = new Parameter(array('type' => 'object', 'location' => 'xml', 'name' => 'Out', 'properties' => array('Nodes' => array('required' => true, 'type' => 'array', 'min' => 1, 'items' => array('type' => 'string', 'sentAs' => 'Node'))))); $param->setParent(new Operation(array('data' => array('xmlRoot' => array('name' => 'Test', 'namespaces' => array('https://foo/')))))); $value = array('Nodes' => array('foo', 'baz')); $this->assertTrue($this->validator->validate($param, $value)); $visitor->visit($this->command, $request, $param, $value); $visitor->after($this->command, $request); $this->assertEquals("<?xml version=\"1.0\"?>\n" . "<Test xmlns=\"https://foo/\"><Out><Nodes><Node>foo</Node><Node>baz</Node></Nodes></Out></Test>\n", (string) $request->getBody()); }
/** * Add a parameter to the command * * @param Parameter $param Parameter to add * * @return self */ public function addParam(Parameter $param) { $this->parameters[$param->getName()] = $param; $param->setParent($this); return $this; }
public function testCanChangeParentOfNestedParameter() { $param1 = new Parameter(array('name' => 'parent')); $param2 = new Parameter(array('name' => 'child')); $param2->setParent($param1); $this->assertSame($param1, $param2->getParent()); }
/** * Add a property to the parameter * * @param Parameter $property Properties to set * * @return self */ public function addProperty(Parameter $property) { $this->properties[$property->getName()] = $property; $property->setParent($this); $this->propertiesCache = null; return $this; }
/** * Set the additionalProperties value of the parameter * * @param bool|Parameter|null $additional Boolean to allow any, an Parameter to specify a schema, or false to disallow * * @return self */ public function setAdditionalProperties($additional) { $this->additionalProperties = $additional; if ($additional instanceof self) { $additional->setParent($this); } return $this; }