/** * {@inheritdoc} */ protected function generateSchema($requestedServiceMetadata, $requestScheme, $requestHost, $endPointUrl) { $wsdl = $this->_wsdlFactory->create(self::WSDL_NAME, $endPointUrl); $wsdl->addSchemaTypeSection(); $faultMessageName = $this->_addGenericFaultComplexTypeNodes($wsdl); $wsdl = $this->addCustomAttributeTypes($wsdl); foreach ($requestedServiceMetadata as $serviceClass => $serviceData) { $portTypeName = $this->getPortTypeName($serviceClass); $bindingName = $this->getBindingName($serviceClass); $portType = $wsdl->addPortType($portTypeName); $binding = $wsdl->addBinding($bindingName, Wsdl::TYPES_NS . ':' . $portTypeName); $wsdl->addSoapBinding($binding, 'document', 'http://schemas.xmlsoap.org/soap/http', SOAP_1_2); $portName = $this->getPortName($serviceClass); $serviceName = $this->getServiceName($serviceClass); $wsdl->addService($serviceName, $portName, Wsdl::TYPES_NS . ':' . $bindingName, $endPointUrl, SOAP_1_2); foreach ($serviceData['methods'] as $methodName => $methodData) { $operationName = $this->typeProcessor->getOperationName($serviceClass, $methodName); $bindingDataPrototype = ['use' => 'literal']; $inputBinding = $bindingDataPrototype; $inputMessageName = $this->_createOperationInput($wsdl, $operationName, $methodData); $outputMessageName = false; $outputBinding = false; if (isset($methodData['interface']['out']['parameters'])) { $outputBinding = $bindingDataPrototype; $outputMessageName = $this->_createOperationOutput($wsdl, $operationName, $methodData); } $faultBinding = ['name' => Fault::NODE_DETAIL_WRAPPER]; $wsdl->addPortOperation($portType, $operationName, $inputMessageName, $outputMessageName, ['message' => $faultMessageName, 'name' => Fault::NODE_DETAIL_WRAPPER]); $bindingOperation = $wsdl->addBindingOperation($binding, $operationName, $inputBinding, $outputBinding, $faultBinding, SOAP_1_2); $wsdl->addSoapOperation($bindingOperation, $operationName, SOAP_1_2); } } return $wsdl->toXML(); }
public function testCreate() { $wsdlName = 'wsdlName'; $endpointUrl = 'endpointUrl'; $this->_objectManagerMock->expects($this->once())->method('create')->with('Magento\\Webapi\\Model\\Soap\\Wsdl', ['name' => $wsdlName, 'uri' => $endpointUrl]); $this->_soapWsdlFactory->create($wsdlName, $endpointUrl); }
protected function setUp() { $this->serviceMetadata = $this->getMockBuilder('Magento\\Webapi\\Model\\ServiceMetadata')->disableOriginalConstructor()->getMock(); $_wsdlMock = $this->getMockBuilder('Magento\\Webapi\\Model\\Soap\\Wsdl')->disableOriginalConstructor()->setMethods(['addSchemaTypeSection', 'addService', 'addPortType', 'addBinding', 'addSoapBinding', 'addElement', 'addComplexType', 'addMessage', 'addPortOperation', 'addBindingOperation', 'addSoapOperation', 'toXML'])->getMock(); $this->_wsdlFactoryMock = $this->getMockBuilder('Magento\\Webapi\\Model\\Soap\\WsdlFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock(); $this->_wsdlFactoryMock->expects($this->any())->method('create')->will($this->returnValue($_wsdlMock)); $this->_cacheMock = $this->getMockBuilder('Magento\\Webapi\\Model\\Cache\\Type\\Webapi')->disableOriginalConstructor()->getMock(); $this->_cacheMock->expects($this->any())->method('load')->will($this->returnValue(false)); $this->_cacheMock->expects($this->any())->method('save')->will($this->returnValue(true)); $this->_typeProcessor = $this->getMock('Magento\\Framework\\Reflection\\TypeProcessor', [], [], '', false); /** @var \Magento\Framework\Webapi\Authorization|\PHPUnit_Framework_MockObject_MockObject $authorizationMock */ $authorizationMock = $this->getMockBuilder('Magento\\Framework\\Webapi\\Authorization')->disableOriginalConstructor()->getMock(); $authorizationMock->expects($this->any())->method('isAllowed')->willReturn(true); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->customAttributeTypeLocator = $objectManager->getObject('Magento\\Eav\\Model\\EavCustomAttributeTypeLocator'); $this->_wsdlGenerator = $objectManager->getObject('Magento\\Webapi\\Model\\Soap\\Wsdl\\Generator', ['wsdlFactory' => $this->_wsdlFactoryMock, 'cache' => $this->_cacheMock, 'typeProcessor' => $this->_typeProcessor, 'customAttributeTypeLocator' => $this->customAttributeTypeLocator, 'serviceMetadata' => $this->serviceMetadata, 'authorization' => $authorizationMock]); parent::setUp(); }
protected function setUp() { $this->_soapConfigMock = $this->getMockBuilder('Magento\\Webapi\\Model\\Soap\\Config')->disableOriginalConstructor()->getMock(); $_wsdlMock = $this->getMockBuilder('Magento\\Webapi\\Model\\Soap\\Wsdl')->disableOriginalConstructor()->setMethods(['addSchemaTypeSection', 'addService', 'addPortType', 'addBinding', 'addSoapBinding', 'addElement', 'addComplexType', 'addMessage', 'addPortOperation', 'addBindingOperation', 'addSoapOperation', 'toXML'])->getMock(); $this->_wsdlFactoryMock = $this->getMockBuilder('Magento\\Webapi\\Model\\Soap\\WsdlFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock(); $this->_wsdlFactoryMock->expects($this->any())->method('create')->will($this->returnValue($_wsdlMock)); $this->_cacheMock = $this->getMockBuilder('Magento\\Framework\\App\\Cache\\Type\\Webapi')->disableOriginalConstructor()->getMock(); $this->_cacheMock->expects($this->any())->method('load')->will($this->returnValue(false)); $this->_cacheMock->expects($this->any())->method('save')->will($this->returnValue(true)); $this->_typeProcessor = $this->getMock('Magento\\Framework\\Reflection\\TypeProcessor', [], [], '', false); $this->storeManagerMock = $this->getMockBuilder('Magento\\Store\\Model\\StoreManagerInterface')->setMethods(['getStore'])->disableOriginalConstructor()->getMockForAbstractClass(); $storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->setMethods(['getCode', '__wakeup'])->disableOriginalConstructor()->getMock(); $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); $storeMock->expects($this->any())->method('getCode')->will($this->returnValue('store_code')); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->customAttributeTypeLocator = $objectManager->getObject('Magento\\Eav\\Model\\EavCustomAttributeTypeLocator'); $this->_wsdlGenerator = $objectManager->getObject('Magento\\Webapi\\Model\\Soap\\Wsdl\\Generator', ['apiConfig' => $this->_soapConfigMock, 'wsdlFactory' => $this->_wsdlFactoryMock, 'cache' => $this->_cacheMock, 'typeProcessor' => $this->_typeProcessor, 'storeManagerMock' => $this->storeManagerMock, 'customAttributeTypeLocator' => $this->customAttributeTypeLocator]); parent::setUp(); }