/** * @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')); }
/** * @expectedException \LogicException * @expectedExceptionMessage Class "\Some\Class" does not exist. Please note that namespace must be specified. */ public function testResolveObjectTypeWithConfiguredAttributeAndNonExistedClass() { $code = 'some_code'; $value = new \stdClass(); $context = '\\Some\\Class'; $config = ['Some\\Class' => ['some_code' => ['type' => '\\Some\\Class']]]; $this->typeProcessor->expects($this->once())->method('getArrayItemType')->with('\\Some\\Class')->willReturn('\\Some\\Class'); $this->configMock->expects($this->once())->method('get')->willReturn($config); $this->model->resolveObjectType($code, $value, $context); }
/** * 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')); }
/** * Test adding complex type with complex parameters and arrays. */ public function testAddComplexTypeComplexParameters() { $type = 'VendorModuleADataStructure'; $parameterType = 'ComplexType'; $typeData = ['documentation' => 'test', 'parameters' => ['complex_param' => ['type' => $parameterType, 'required' => true, 'documentation' => 'complex type param.']]]; $parameterData = ['documentation' => 'test', 'parameters' => ['string_param' => ['type' => 'ComplexTypeB[]', 'required' => true, 'documentation' => 'string param.']]]; $this->_wsdl->expects($this->at(0))->method('getTypes')->will($this->returnValue([])); $this->_wsdl->expects($this->any())->method('getTypes')->will($this->returnValue([$type => Wsdl::TYPES_NS . ':' . $type])); $this->_wsdl->expects($this->any())->method('toDomDocument')->will($this->returnValue(new \DOMDocument())); $schemaMock = $this->getMock('DOMElement', [], ['a']); $schemaMock->expects($this->any())->method('appendChild'); $this->_wsdl->expects($this->any())->method('getSchema')->will($this->returnValue($schemaMock)); $this->_typeProcessor->expects($this->at(0))->method('getTypeData')->with($type)->will($this->returnValue($typeData)); $this->_typeProcessor->expects($this->at(1))->method('getTypeData')->with($parameterType)->will($this->returnValue($parameterData)); $this->assertEquals(Wsdl::TYPES_NS . ':' . $type, $this->_strategy->addComplexType($type)); }
/** * Set up helper. */ protected function setUp() { $this->_typeProcessor = $this->getMock('\\Magento\\Framework\\Reflection\\TypeProcessor', ['process'], [], '', false); $this->_typeProcessor->expects($this->any())->method('process')->will($this->returnValueMap([['string', 'str'], ['int', 'int']])); $this->_classReflector = new \Magento\Webapi\Model\Config\ClassReflector($this->_typeProcessor); }