/** * Test generate uri with wsdl param as true */ public function testGenerateUriWithNoWsdlParam() { $param = "testModule1AllSoapAndRest:V1,testModule2AllSoapNoRest:V1"; $serviceKey = \Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_SERVICES; $this->_requestMock->expects($this->any())->method('getParam')->will($this->returnValue($param)); $expectedResult = "http://magento.com/soap/storeCode?{$serviceKey}={$param}"; $actualResult = $this->_soapServer->generateUri(false); $this->assertEquals($expectedResult, urldecode($actualResult), 'URI (without WSDL param) generated is invalid.'); }
public function testCall() { $requestedServices = array('requestedServices'); $this->_requestMock->expects($this->once())->method('getRequestedServices')->will($this->returnValue($requestedServices)); $this->_dataObjectConverter->expects($this->once())->method('convertStdObjectToArray')->will($this->returnValue(['field' => 1])); $operationName = 'soapOperation'; $className = 'Magento\\Framework\\Object'; $methodName = 'testMethod'; $isSecure = false; $aclResources = array('Magento_TestModule::resourceA'); $this->_apiConfigMock->expects($this->once())->method('getServiceMethodInfo')->with($operationName, $requestedServices)->will($this->returnValue(array(SoapConfig::KEY_CLASS => $className, SoapConfig::KEY_METHOD => $methodName, SoapConfig::KEY_IS_SECURE => $isSecure, SoapConfig::KEY_ACL_RESOURCES => $aclResources))); $this->_authorizationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true)); $serviceMock = $this->getMockBuilder($className)->disableOriginalConstructor()->setMethods(array($methodName))->getMock(); $serviceResponse = array('foo' => 'bar'); $serviceMock->expects($this->once())->method($methodName)->will($this->returnValue($serviceResponse)); $this->_objectManagerMock->expects($this->once())->method('get')->with($className)->will($this->returnValue($serviceMock)); $this->_serializerMock->expects($this->once())->method('getInputData')->will($this->returnArgument(2)); /** Execute SUT. */ $this->assertEquals(array('result' => $serviceResponse), $this->_handler->__call($operationName, array((object) array('field' => 1)))); }
/** * Mock getParam() of request object to return given value. * * @param $param * @param $value */ protected function _mockGetParam($param, $value) { $this->_requestMock->expects($this->once())->method('getParam')->with($param)->will($this->returnValue($value)); }