/** * Positive test case. Generate simple resource WSDL. * * @dataProvider generateDataProvider() */ public function testGenerate($resourceName, $methodName, $interface) { $serviceDomMock = $this->_getDomElementMock(); $this->_wsdlMock->expects($this->once())->method('addService')->will($this->returnValue($serviceDomMock)); $portTypeDomMock = $this->_getDomElementMock(); $portTypeName = $this->_autoDiscover->getPortTypeName($resourceName); $this->_wsdlMock->expects($this->once())->method('addPortType')->with($portTypeName)->will($this->returnValue($portTypeDomMock)); $bindingDomMock = $this->_getDomElementMock(); $bindingName = $this->_autoDiscover->getBindingName($resourceName); $this->_wsdlMock->expects($this->once())->method('addBinding')->with($bindingName, Wsdl::TYPES_NS . ':' . $portTypeName)->will($this->returnValue($bindingDomMock)); $this->_wsdlMock->expects($this->once())->method('addSoapBinding')->with($bindingDomMock); $operationName = $this->_autoDiscover->getOperationName($resourceName, $methodName); $inputMessageName = $this->_autoDiscover->getInputMessageName($operationName); $outputMessageName = $this->_autoDiscover->getOutputMessageName($operationName); $this->_wsdlMock->expects($this->once())->method('addPortOperation')->with($portTypeDomMock, $operationName, Wsdl::TYPES_NS . ':' . $inputMessageName, Wsdl::TYPES_NS . ':' . $outputMessageName); $operationDomMock = $this->_getDomElementMock(); $this->_wsdlMock->expects($this->once())->method('addBindingOperation')->with($bindingDomMock, $operationName, array('use' => 'literal'), array('use' => 'literal'), false, SOAP_1_2)->will($this->returnValue($operationDomMock)); $this->_wsdlMock->expects($this->once())->method('addSoapOperation')->with($operationDomMock, $operationName, SOAP_1_2); $this->_wsdlMock->expects($this->once())->method('toXML'); $requestedResources = array($resourceName => array('methods' => array($methodName => array('interface' => $interface, 'documentation' => 'test method A')))); $endpointUrl = 'http://magento.host/api/soap/'; $this->_autoDiscover->generate($requestedResources, $endpointUrl); }
/** * Create output message and corresponding element and complex types in WSDL. * * @param Mage_Webapi_Model_Soap_Wsdl $wsdl * @param string $operationName * @param array $methodData * @return string output message name */ protected function _createOperationOutput(Mage_Webapi_Model_Soap_Wsdl $wsdl, $operationName, $methodData) { $outputMessageName = $this->getOutputMessageName($operationName); $complexTypeName = $this->getElementComplexTypeName($outputMessageName); $wsdl->addElement(array('name' => $outputMessageName, 'type' => Wsdl::TYPES_NS . ':' . $complexTypeName)); $callInfo = array(); $callInfo['returned']['always']['calls'] = array($operationName); $typeData = array('documentation' => sprintf('Response container for the %s call.', $operationName), 'parameters' => $methodData['interface']['out']['parameters'], 'callInfo' => $callInfo); $this->_apiConfig->setTypeData($complexTypeName, $typeData); $wsdl->addComplexType($complexTypeName); $wsdl->addMessage($outputMessageName, array('messageParameters' => array('element' => Wsdl::TYPES_NS . ':' . $outputMessageName))); return Wsdl::TYPES_NS . ':' . $outputMessageName; }