/**
  * @param string[] $serviceMetadata
  * @param string[] $typeData
  * @param string $schema
  * @dataProvider generateDataProvider
  */
 public function testGenerate($serviceMetadata, $typeData, $schema)
 {
     $service = 'testModule5AllSoapAndRestV2';
     $requestedService = [$service];
     $this->serviceMetadataMock->expects($this->any())->method('getRouteMetadata')->willReturn($serviceMetadata);
     $this->typeProcessorMock->expects($this->any())->method('getTypeData')->willReturnMap([['TestModule5V2EntityAllSoapAndRest', $typeData]]);
     $this->typeProcessorMock->expects($this->any())->method('isTypeSimple')->willReturnMap([['int', true]]);
     $this->assertEquals($schema, $this->generator->generate($requestedService, 'http://', 'magento.host', '/rest/default/schema?services=service1'));
 }
 /**
  * Retrieve a list of services visible to current user.
  *
  * @return string[]
  */
 public function getListOfServices()
 {
     $listOfAllowedServices = [];
     foreach ($this->serviceMetadata->getServicesConfig() as $serviceName => $service) {
         foreach ($service[ServiceMetadata::KEY_SERVICE_METHODS] as $method) {
             if ($this->authorization->isAllowed($method[ServiceMetadata::KEY_ACL_RESOURCES])) {
                 $listOfAllowedServices[] = $serviceName;
                 break;
             }
         }
     }
     return $listOfAllowedServices;
 }
 /**
  * Test exception for handle
  *
  * @expectedException        \Magento\Framework\Webapi\Exception
  * @expectedExceptionMessage exception message
  */
 public function testHandleWithException()
 {
     $genWSDL = 'generatedWSDL';
     $exceptionMsg = 'exception message';
     $requestedService = ['catalogProduct'];
     $serviceMetadata = ['methods' => ['methodName' => ['interface' => 'aInterface']]];
     $this->serviceMetadata->expects($this->any())->method('getServiceMetadata')->willReturn($serviceMetadata);
     $this->_typeProcessor->expects($this->once())->method('processInterfaceCallInfo')->willThrowException(new \Magento\Framework\Webapi\Exception(__($exceptionMsg)));
     $this->assertEquals($genWSDL, $this->_wsdlGenerator->generate($requestedService, 'http://', 'magento.host', '/soap/default'));
 }
 public function testGetRouteMetadata()
 {
     $expectedResult = ['methods' => ['activateById' => ['method' => 'activateById', 'inputRequired' => '', 'isSecure' => '', 'resources' => [['Magento_Customer::manage']], 'interface' => ['in' => ['parameters' => ['customerId' => ['force' => true, 'value' => '%customer_id%'], 'requiredInputParameter' => ['required' => true]]], 'out' => ['parameters' => ['outputParameter' => ['type' => 'string']]]]]], 'class' => 'Magento\\Customer\\Api\\AccountManagementInterface', 'description' => 'classDescription', 'routes' => ['/V1/customers/me/activate' => ['PUT' => ['method' => 'activateById', 'parameters' => ['customerId' => ['force' => true, 'value' => '%customer_id%']]]]]];
     $result = $this->serviceMetadata->getRouteMetadata('customerAccountManagementV1');
     $this->assertEquals($expectedResult, $result);
 }
Esempio n. 5
0
 /**
  * Generate SOAP operation name.
  *
  * @param string $interfaceName e.g. \Magento\Catalog\Api\ProductInterfaceV1
  * @param string $methodName e.g. create
  * @param string $version
  * @return string e.g. catalogProductCreate
  */
 public function getSoapOperation($interfaceName, $methodName, $version)
 {
     $serviceName = $this->serviceMetadata->getServiceName($interfaceName, $version);
     $operationName = $serviceName . ucfirst($methodName);
     return $operationName;
 }
 /**
  * Retrieve an array of services
  *
  * @return array
  */
 public function getListOfServices()
 {
     return $this->serviceMetadata->getServicesConfig();
 }