コード例 #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
 /**
  * Set up config with fixture controllers directory scanner
  */
 protected function setUp()
 {
     $fixtureDir = __DIR__ . '/../../_files/Controller/AutoDiscover/';
     $directoryScanner = new \Zend\Code\Scanner\DirectoryScanner($fixtureDir);
     /** @var Mage_Core_Model_App $app */
     $app = $this->getMockBuilder('Mage_Core_Model_App')->disableOriginalConstructor()->getMock();
     $objectManager = new Magento_Test_ObjectManager();
     $this->_helper = $objectManager->get('Mage_Webapi_Helper_Config');
     $reader = $objectManager->get('Mage_Webapi_Model_Config_Reader_Soap');
     $reader->setDirectoryScanner($directoryScanner);
     $this->_config = new Mage_Webapi_Model_Config_Soap($reader, $this->_helper, $app);
     $objectManager->addSharedInstance($this->_config, 'Mage_Webapi_Model_Config_Soap');
     $wsdlFactory = new Mage_Webapi_Model_Soap_Wsdl_Factory($objectManager);
     $cache = $this->getMockBuilder('Mage_Core_Model_Cache')->disableOriginalConstructor()->getMock();
     $this->_autoDiscover = new Mage_Webapi_Model_Soap_AutoDiscover($this->_config, $wsdlFactory, $this->_helper, $cache);
     $this->_resourceName = 'vendorModuleB';
     $this->_resourceData = $this->_config->getResourceDataMerged($this->_resourceName, 'v1');
     $xml = $this->_autoDiscover->generate(array($this->_resourceName => $this->_resourceData), 'http://magento.host/api/soap');
     $this->_dom = new DOMDocument('1.0', 'utf-8');
     $this->_dom->loadXML($xml);
     $this->_xpath = new DOMXPath($this->_dom);
     $this->_xpath->registerNamespace(Wsdl::WSDL_NS, Wsdl::WSDL_NS_URI);
     parent::setUp();
 }