Пример #1
0
 /**
  * Assert port type node is present and return it.
  *
  * @return DOMElement
  */
 protected function _assertPortType()
 {
     $portTypes = $this->_dom->getElementsByTagNameNs(Wsdl::WSDL_NS_URI, 'portType');
     $this->assertEquals(1, $portTypes->length, 'There should be only one portType in this test case.');
     /** @var DOMElement $portType */
     $portType = $portTypes->item(0);
     $this->assertTrue($portType->hasAttribute('name'));
     $expectedName = $this->_autoDiscover->getPortTypeName($this->_resourceName);
     $this->assertEquals($expectedName, $portType->getAttribute('name'));
     return $portType;
 }
Пример #2
0
 /**
  * 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);
 }