Exemplo n.º 1
0
 /**
  * Add complex type.
  *
  * @param string $type
  * @param array $parentCallInfo array of callInfo from parent complex type
  * @return string
  * @throws InvalidArgumentException
  */
 public function addComplexType($type, $parentCallInfo = array())
 {
     if (($soapType = $this->scanRegisteredTypes($type)) !== null) {
         return $soapType;
     }
     /** @var DOMDocument $dom */
     $dom = $this->getContext()->toDomDocument();
     $this->_dom = $dom;
     $soapType = Wsdl::TYPES_NS . ':' . $type;
     // Register type here to avoid recursion
     $this->getContext()->addType($type, $soapType);
     $complexType = $this->_dom->createElement(Wsdl::XSD_NS . ':complexType');
     $complexType->setAttribute('name', $type);
     $typeData = $this->_config->getTypeData($type);
     if (isset($typeData['documentation'])) {
         $this->addAnnotation($complexType, $typeData['documentation']);
     }
     if (isset($typeData['parameters']) && is_array($typeData['parameters'])) {
         $callInfo = isset($typeData['callInfo']) ? $typeData['callInfo'] : $parentCallInfo;
         $sequence = $this->_processParameters($typeData['parameters'], $callInfo);
         $complexType->appendChild($sequence);
     }
     $this->getContext()->getSchema()->appendChild($complexType);
     return $soapType;
 }
Exemplo n.º 2
0
 /**
  * Test that complexType for Data structures has been generated correctly in WSDL.
  * See /_files/controllers/AutoDiscover/ModuleB/SubresourceData.php
  */
 public function testGenerateDataStructureComplexTypes()
 {
     $wsdlNs = Wsdl::WSDL_NS;
     $xsdNs = Wsdl::XSD_NS;
     // Generated from Vendor_ModuleB_Model_Webapi_ModuleBData class.
     $dataStructureName = 'VendorModuleBData';
     $typeData = $this->_config->getTypeData($dataStructureName);
     $complexTypeXpath = "//{$wsdlNs}:types/{$xsdNs}:schema/{$xsdNs}:complexType[@name='%s']";
     /** @var DOMElement $dataStructure */
     $dataStructure = $this->_xpath->query(sprintf($complexTypeXpath, $dataStructureName))->item(0);
     $this->assertNotNull($dataStructure, sprintf('Complex type for data structure "%s" was not found in WSDL.', $dataStructureName));
     $this->_assertDocumentation($typeData['documentation'], $dataStructure);
     // Expected appinfo tags.
     $expectedAppinfo = (include __DIR__ . '/../../_files/Controller/annotation_fixture.php');
     foreach ($typeData['parameters'] as $parameterName => $parameterData) {
         // remove all appinfo placeholders from expected doc.
         $expectedDoc = trim(preg_replace('/(\\{.*\\}|\\r)/U', '', $parameterData['documentation']));
         $this->_assertParameter($parameterName, $parameterData['type'], $parameterData['required'], $expectedDoc, $expectedAppinfo[$parameterName], $dataStructure);
     }
 }
Exemplo n.º 3
0
 /**
  * Test getDataType functionality.
  * Expected result of method is placed in file fixture.
  */
 public function testGetDataType()
 {
     $expectedType = (include __DIR__ . '/../../../_files/config/data_structure_fixture.php');
     $this->assertEquals($expectedType, $this->_config->getTypeData('NamespaceAModuleAData'));
 }