8 use \Magento\Webapi\Model\Soap\Wsdl\ComplexTypeStrategy;
31 $this->_typeProcessor = $this->getMockBuilder(
32 \
Magento\Framework\Reflection\TypeProcessor::class
35 )->disableOriginalConstructor()->getMock();
36 $this->_wsdl = $this->getMockBuilder(
39 [
'toDomDocument',
'getTypes',
'getSchema']
40 )->disableOriginalConstructor()->getMock();
42 $this->_strategy->setContext($this->_wsdl);
51 unset($this->_typeProcessor);
52 unset($this->_strategy);
64 $testType =
'testComplexTypeName';
65 $testTypeWsdlName =
'tns:' . $testType;
66 $includedTypes = [$testType => $testTypeWsdlName];
67 $this->_wsdl->expects($this->exactly(2))->method(
'getTypes')->will($this->returnValue($includedTypes));
69 $this->assertEquals($testTypeWsdlName, $this->_strategy->addComplexType($testType));
81 $this->_wsdl->expects($this->any())->method(
'getTypes')->will($this->returnValue([]));
83 $this->_wsdl->expects($this->any())->method(
'toDomDocument')->will($this->returnValue(
new \DOMDocument()));
85 $schemaMock = $this->getMockBuilder(\DOMElement::class)
86 ->setConstructorArgs([
'a'])
88 $schemaMock->expects($this->any())->method(
'appendChild');
89 $this->_wsdl->expects($this->any())->method(
'getSchema')->will($this->returnValue($schemaMock));
91 $this->_typeProcessor->expects(
98 $this->returnValue(
$data)
101 $this->assertEquals(Wsdl::TYPES_NS .
':' .
$type, $this->_strategy->addComplexType(
$type));
112 'simple parameters' => [
113 'VendorModuleADataStructure',
115 'documentation' =>
'test',
120 'documentation' =>
'Required string param.',
125 'documentation' =>
'Required int param.',
130 'documentation' =>
'Optional complex type param.{annotation:test}',
135 'type with call info' => [
136 'VendorModuleADataStructure',
138 'documentation' =>
'test',
143 'documentation' =>
'{callInfo:VendorModuleACreate:requiredInput:conditionally}',
147 'requiredInput' => [
'yes' => [
'calls' => [
'VendorModuleACreate']]],
148 'returned' => [
'always' => [
'calls' => [
'VendorModuleAGet']]],
152 'parameter with call info' => [
153 'VendorModuleADataStructure',
155 'documentation' =>
'test',
160 'documentation' =>
'{callInfo:VendorModuleACreate:requiredInput:conditionally}' .
161 '{callInfo:allCallsExcept(VendorModuleAGet):returned:always}',
166 'parameter with see link' => [
167 'VendorModuleADataStructure',
169 'documentation' =>
'test',
174 'documentation' =>
'{seeLink:http://google.com/:title:for}',
179 'parameter with doc instructions' => [
180 'VendorModuleADataStructure',
182 'documentation' =>
'test',
187 'documentation' =>
'{docInstructions:output:noDoc}',
200 $type =
'VendorModuleADataStructure';
201 $parameterType =
'ComplexType';
203 'documentation' =>
'test',
206 'type' => $parameterType,
208 'documentation' =>
'complex type param.',
213 'documentation' =>
'test',
216 'type' =>
'ComplexTypeB[]',
218 'documentation' =>
'string param.',
223 $this->_wsdl->expects($this->at(0))->method(
'getTypes')->will($this->returnValue([]));
224 $this->_wsdl->expects(
229 $this->returnValue([
$type => Wsdl::TYPES_NS .
':' .
$type])
232 $this->_wsdl->expects($this->any())->method(
'toDomDocument')->will($this->returnValue(
new \DOMDocument()));
233 $schemaMock = $this->getMockBuilder(\DOMElement::class)
234 ->setConstructorArgs([
'a'])
236 $schemaMock->expects($this->any())->method(
'appendChild');
237 $this->_wsdl->expects($this->any())->method(
'getSchema')->will($this->returnValue($schemaMock));
238 $this->_typeProcessor->expects(
245 $this->returnValue($typeData)
247 $this->_typeProcessor->expects(
254 $this->returnValue($parameterData)
257 $this->assertEquals(Wsdl::TYPES_NS .
':' .
$type, $this->_strategy->addComplexType(
$type));
265 $dom = new \DOMDocument();
266 $this->_wsdl->expects($this->any())->method(
'toDomDocument')->will($this->returnValue($dom));
267 $annotationDoc =
"test doc";
268 $complexType = $dom->createElement(Wsdl::XSD_NS .
':complexType');
269 $complexType->setAttribute(
'name',
'testRequest');
270 $this->_strategy->addAnnotation($complexType, $annotationDoc);
273 $complexType->getElementsByTagName(
"xsd:documentation")->item(0)->nodeValue
static addComplexTypeDataProvider()
testAddComplexTypeComplexParameters()
testAddAnnotationToComplexType()
testAddComplexTypeSimpleParameters($type, $data)