示例#1
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);
 }
示例#2
0
 /**
  * Test WSDL operations Generation.
  * Generate WSDL XML using AutoDiscover and prepared config.
  * Walk through all methods from "vendorModuleB resource" (_files/controllers/AutoDiscover/ModuleBController.php)
  * Assert that service, portType and binding has been generated correctly for resource.
  * Assert that each method from controller has generated operations in portType and binding nodes.
  * Assert that each method has input and output messages and complexTypes generated correctly.
  */
 public function testGenerateOperations()
 {
     $this->_assertServiceNode();
     $binding = $this->_assertBinding();
     $portType = $this->_assertPortType();
     foreach ($this->_resourceData['methods'] as $methodName => $methodData) {
         $operationName = $this->_autoDiscover->getOperationName($this->_resourceName, $methodName);
         $this->_assertBindingOperation($operationName, $binding);
         $portOperation = $this->_assertPortTypeOperation($operationName, $portType);
         // Assert portType operation input
         /** @var DOMElement $operationInput */
         $operationInput = $portOperation->getElementsByTagName('input')->item(0);
         $this->assertNotNull($operationInput, sprintf('"input" node was not found in "%s" port operation.', $operationName));
         $messageName = $this->_autoDiscover->getInputMessageName($operationName);
         $operationRequest = $this->_assertMessage($operationInput, $messageName, $methodData['documentation']);
         if (isset($methodData['interface']['in'])) {
             foreach ($methodData['interface']['in']['parameters'] as $parameterName => $parameterData) {
                 $expectedAppinfo = array('callInfo' => array($operationName => array('requiredInput' => $parameterData['required'] ? 'Yes' : 'No')));
                 $this->_assertParameter($parameterName, $parameterData['type'], $parameterData['required'], $parameterData['documentation'], $expectedAppinfo, $operationRequest);
             }
         }
         // Assert portType operation output
         if (isset($methodData['interface']['out'])) {
             /** @var DOMElement $operationOutput */
             $operationOutput = $portOperation->getElementsByTagName('output')->item(0);
             $this->assertNotNull($operationOutput, sprintf('"output" node was not found in "%s" port operation.', $operationName));
             $messageName = $this->_autoDiscover->getInputMessageName($operationName);
             $expectedDoc = sprintf('Response container for the %s call.', $operationName);
             $operationResponse = $this->_assertMessage($operationOutput, $messageName, $expectedDoc);
             foreach ($methodData['interface']['out']['parameters'] as $parameterName => $parameterData) {
                 $expectedAppinfo = array('callInfo' => array($operationName => array('returned' => $parameterData['required'] ? 'Always' : 'Conditionally')));
                 $this->_assertParameter($parameterName, $parameterData['type'], $parameterData['required'], $parameterData['documentation'], $expectedAppinfo, $operationResponse);
             }
         }
     }
 }