Exemplo 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();
 }
Exemplo 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))));
 }
Exemplo n.º 3
0
 /**
  * @expectedException \InvalidArgumentException
  * @dataProvider dataProviderForTestGetServiceNamePartsInvalidName
  */
 public function testGetServiceNamePartsInvalidName($interfaceClassName)
 {
     $this->_helper->getServiceNameParts($interfaceClassName);
 }
Exemplo n.º 4
0
 /**
  * Set the selected resources, which is an array of resource ids. If everything is allowed, the
  * array will contain just the root resource id, which is "Magento_Adminhtml::all".
  *
  * @return void
  */
 protected function _construct()
 {
     parent::_construct();
     $this->_selectedResources = $this->_webapiHelper->getSelectedResources();
 }
Exemplo n.º 5
0
 /**
  * Generate SOAP operation name.
  *
  * @param string $interfaceName e.g. \Magento\Catalog\Service\ProductInterfaceV1
  * @param string $methodName e.g. create
  * @return string e.g. catalogProductCreate
  */
 public function getSoapOperation($interfaceName, $methodName)
 {
     $serviceName = $this->_helper->getServiceName($interfaceName);
     $operationName = $serviceName . ucfirst($methodName);
     return $operationName;
 }
Exemplo n.º 6
0
 /**
  * Class constructor
  *
  * @return void
  */
 protected function _construct()
 {
     parent::_construct();
     $this->setSelectedResources($this->_webapiData->getSelectedResources());
 }