public function testHasData() { $o = new Operation(array('data' => array('foo' => 'baz', 'bar' => 123)), new Description([])); $this->assertEquals('baz', $o->getData('foo')); $this->assertEquals(123, $o->getData('bar')); $this->assertNull($o->getData('wfefwe')); $this->assertEquals(['foo' => 'baz', 'bar' => 123], $o->getData()); }
/** * Create the root XML element to use with a request * * @param Operation $operation Operation object * * @return \XMLWriter */ protected function createRootElement(Operation $operation) { static $defaultRoot = array('name' => 'Request'); // If no root element was specified, then just wrap the XML in 'Request' $root = $operation->getData('xmlRoot') ?: $defaultRoot; // Allow the XML declaration to be customized with xmlEncoding $encoding = $operation->getData('xmlEncoding'); $writer = $this->startDocument($encoding); $writer->startElement($root['name']); // Create the wrapping element with no namespaces if no namespaces were present if (!empty($root['namespaces'])) { // Create the wrapping element with an array of one or more namespaces foreach ((array) $root['namespaces'] as $prefix => $uri) { $nsLabel = 'xmlns'; if (!is_numeric($prefix)) { $nsLabel .= ':' . $prefix; } $writer->writeAttribute($nsLabel, $uri); } } return $writer; }