Ejemplo n.º 1
0
 /**
  * Set up helper.
  */
 protected function setUp()
 {
     $objectManagerMock = $this->getMockBuilder('Magento\\Framework\\App\\ObjectManager')->disableOriginalConstructor()->getMock();
     $fileSystemMock = $this->getMockBuilder('Magento\\Framework\\App\\Filesystem')->disableOriginalConstructor()->getMock();
     $classReflection = $this->getMock('Magento\\Webapi\\Model\\Config\\ClassReflector', array('reflectClassMethods'), array(), '', false);
     $classReflection->expects($this->any())->method('reflectClassMethods')->will($this->returnValue(array()));
     $this->_helperMock = $this->getMock('Magento\\Webapi\\Helper\\Data', array(), array(), '', false);
     $this->_configMock = $this->getMock('Magento\\Webapi\\Model\\Config', array(), array(), '', false);
     $servicesConfig = ['services' => ['Magento\\Framework\\Module\\Service\\FooV1Interface' => ['someMethod' => ['resources' => [['Magento_TestModule1::resource1']], 'secure' => false]], 'Magento\\Framework\\Module\\Service\\BarV1Interface' => ['someMethod' => ['resources' => [['Magento_TestModule1::resource2']], 'secure' => false]]]];
     $this->_configMock->expects($this->once())->method('getServices')->will($this->returnValue($servicesConfig));
     $this->_helperMock->expects($this->any())->method('getServiceName')->will($this->returnValueMap(array(array('Magento\\Framework\\Module\\Service\\FooV1Interface', true, 'moduleFooV1'), array('Magento\\Framework\\Module\\Service\\BarV1Interface', true, 'moduleBarV1'))));
     $this->_soapConfig = new \Magento\Webapi\Model\Soap\Config($objectManagerMock, $fileSystemMock, $this->_configMock, $classReflection, $this->_helperMock);
     parent::setUp();
 }
Ejemplo n.º 2
0
 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))));
 }