Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
WsdlGenerationFromDataObjectTest.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Webapi;
8 
10 
15 {
17  protected $_baseUrl = TESTS_BASE_URL;
18 
20  protected $_storeCode;
21 
23  protected $_soapUrl;
24 
26  protected $isSingleService;
27 
28  protected function setUp()
29  {
30  $this->_markTestAsSoapOnly("WSDL generation tests are intended to be executed for SOAP adapter only.");
31  $this->_storeCode = Bootstrap::getObjectManager()->get(\Magento\Store\Model\StoreManagerInterface::class)
32  ->getStore()->getCode();
33  parent::setUp();
34  }
35 
36  public function testMultiServiceWsdl()
37  {
38  $this->_soapUrl = "{$this->_baseUrl}/soap/{$this->_storeCode}"
39  . "?services=testModule5AllSoapAndRestV1%2CtestModule5AllSoapAndRestV2";
40  $wsdlUrl = $this->_getBaseWsdlUrl() . 'testModule5AllSoapAndRestV1,testModule5AllSoapAndRestV2';
41  $wsdlContent = $this->_convertXmlToString($this->_getWsdlContent($wsdlUrl));
42  $this->isSingleService = false;
43 
44  $this->_checkTypesDeclaration($wsdlContent);
45  $this->_checkPortTypeDeclaration($wsdlContent);
46  $this->_checkBindingDeclaration($wsdlContent);
47  $this->_checkServiceDeclaration($wsdlContent);
48  $this->_checkMessagesDeclaration($wsdlContent);
49  $this->_checkFaultsDeclaration($wsdlContent);
50  }
51 
52  public function testSingleServiceWsdl()
53  {
54  $this->_soapUrl = "{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV2";
55  $wsdlUrl = $this->_getBaseWsdlUrl() . 'testModule5AllSoapAndRestV2';
56  $wsdlContent = $this->_convertXmlToString($this->_getWsdlContent($wsdlUrl));
57  $this->isSingleService = true;
58 
59  $this->_checkTypesDeclaration($wsdlContent);
60  $this->_checkPortTypeDeclaration($wsdlContent);
61  $this->_checkBindingDeclaration($wsdlContent);
62  $this->_checkServiceDeclaration($wsdlContent);
63  $this->_checkMessagesDeclaration($wsdlContent);
64  $this->_checkFaultsDeclaration($wsdlContent);
65  }
66 
67  public function testNoAuthorizedServices()
68  {
69  $wsdlUrl = $this->_getBaseWsdlUrl() . 'testModule5AllSoapAndRestV2';
70  $connection = curl_init($wsdlUrl);
71  curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
72  $responseContent = curl_exec($connection);
73  $this->assertEquals(curl_getinfo($connection, CURLINFO_HTTP_CODE), 401);
74  $this->assertContains("The consumer isn't authorized to access %resources.", $responseContent);
75  }
76 
77  public function testInvalidWsdlUrlNoServices()
78  {
79  $responseContent = $this->_getWsdlContent($this->_getBaseWsdlUrl());
80  $this->assertContains("Requested services are missing.", $responseContent);
81  }
82 
84  {
85  $wsdlUrl = $this->_getBaseWsdlUrl() . '&invalid';
86  $responseContent = $this->_getWsdlContent($wsdlUrl);
87  $this->assertContains("Not allowed parameters", $responseContent);
88  }
89 
96  protected function _convertXmlToString($xml)
97  {
98  return str_replace([' ', "\n", "\r", "&#13;", "&#10;"], '', $xml);
99  }
100 
107  protected function _getWsdlContent($wsdlUrl)
108  {
109  $accessCredentials = \Magento\TestFramework\Authentication\OauthHelper::getApiAccessCredentials()['key'];
110  $connection = curl_init($wsdlUrl);
111  curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
112  curl_setopt($connection, CURLOPT_HTTPHEADER, ['header' => "Authorization: Bearer " . $accessCredentials]);
113  $responseContent = curl_exec($connection);
114  $responseDom = new \DOMDocument();
115  $this->assertTrue(
116  $responseDom->loadXML($responseContent),
117  "Valid XML is always expected as a response for WSDL request."
118  );
119  return $responseContent;
120  }
121 
127  protected function _getBaseWsdlUrl()
128  {
130  $soapAdapter = $this->_getWebApiAdapter(self::ADAPTER_SOAP);
131  $wsdlUrl = $soapAdapter->generateWsdlUrl([]);
132  return $wsdlUrl;
133  }
134 
140  protected function _checkTypesDeclaration($wsdlContent)
141  {
142  // @codingStandardsIgnoreStart
143  $typesSectionDeclaration = <<< TYPES_SECTION_DECLARATION
144 <types>
145  <xsd:schema targetNamespace="{$this->_soapUrl}">
146 TYPES_SECTION_DECLARATION;
147  // @codingStandardsIgnoreEnd
148  $this->assertContains(
149  $this->_convertXmlToString($typesSectionDeclaration),
150  $wsdlContent,
151  'Types section declaration is invalid'
152  );
153  $this->_checkElementsDeclaration($wsdlContent);
154  $this->_checkComplexTypesDeclaration($wsdlContent);
155  }
156 
160  protected function _checkElementsDeclaration($wsdlContent)
161  {
162  if ($this->isSingleService) {
163  $requestElement = <<< REQUEST_ELEMENT
164 <xsd:element name="testModule5AllSoapAndRestV2ItemRequest" type="tns:TestModule5AllSoapAndRestV2ItemRequest"/>
165 REQUEST_ELEMENT;
166  } else {
167  $requestElement = <<< REQUEST_ELEMENT
168 <xsd:element name="testModule5AllSoapAndRestV1ItemRequest" type="tns:TestModule5AllSoapAndRestV1ItemRequest"/>
169 REQUEST_ELEMENT;
170  }
171  $this->assertContains(
172  $this->_convertXmlToString($requestElement),
173  $wsdlContent,
174  'Request element declaration in types section is invalid'
175  );
176 
177  if ($this->isSingleService) {
178  $responseElement = <<< RESPONSE_ELEMENT
179 <xsd:element name="testModule5AllSoapAndRestV2ItemResponse" type="tns:TestModule5AllSoapAndRestV2ItemResponse"/>
180 RESPONSE_ELEMENT;
181  } else {
182  $responseElement = <<< RESPONSE_ELEMENT
183 <xsd:element name="testModule5AllSoapAndRestV1ItemResponse" type="tns:TestModule5AllSoapAndRestV1ItemResponse"/>
184 RESPONSE_ELEMENT;
185  }
186  $this->assertContains(
187  $this->_convertXmlToString($responseElement),
188  $wsdlContent,
189  'Response element declaration in types section is invalid'
190  );
191  }
192 
197  protected function _checkComplexTypesDeclaration($wsdlContent)
198  {
199  // @codingStandardsIgnoreStart
200  if ($this->isSingleService) {
201  $requestType = <<< REQUEST_TYPE
202 <xsd:complexType name="TestModule5AllSoapAndRestV2ItemRequest">
203  <xsd:annotation>
204  <xsd:documentation>Retrieve existing item.</xsd:documentation>
205  <xsd:appinfo xmlns:inf="{$this->_soapUrl}"/>
206  </xsd:annotation>
207  <xsd:sequence>
208  <xsd:element name="id" minOccurs="1" maxOccurs="1" type="xsd:int">
209  <xsd:annotation>
210  <xsd:documentation></xsd:documentation>
211  <xsd:appinfo xmlns:inf="{$this->_soapUrl}">
212  <inf:min/>
213  <inf:max/>
214  <inf:callInfo>
215  <inf:callName>testModule5AllSoapAndRestV2Item</inf:callName>
216  <inf:requiredInput>Yes</inf:requiredInput>
217  </inf:callInfo>
218  </xsd:appinfo>
219  </xsd:annotation>
220  </xsd:element>
221  </xsd:sequence>
222 </xsd:complexType>
223 REQUEST_TYPE;
224  } else {
225  $requestType = <<< REQUEST_TYPE
226 <xsd:complexType name="TestModule5AllSoapAndRestV1ItemRequest">
227  <xsd:annotation>
228  <xsd:documentation>Retrieve an item.</xsd:documentation>
229  <xsd:appinfo xmlns:inf="{$this->_soapUrl}"/>
230  </xsd:annotation>
231  <xsd:sequence>
232  <xsd:element name="entityId" minOccurs="1" maxOccurs="1" type="xsd:int">
233  <xsd:annotation>
234  <xsd:documentation></xsd:documentation>
235  <xsd:appinfo xmlns:inf="{$this->_soapUrl}">
236  <inf:min/>
237  <inf:max/>
238  <inf:callInfo>
239  <inf:callName>testModule5AllSoapAndRestV1Item</inf:callName>
240  <inf:requiredInput>Yes</inf:requiredInput>
241  </inf:callInfo>
242  </xsd:appinfo>
243  </xsd:annotation>
244  </xsd:element>
245  </xsd:sequence>
246 </xsd:complexType>
247 REQUEST_TYPE;
248  }
249  // @codingStandardsIgnoreEnd
250  $this->assertContains(
251  $this->_convertXmlToString($requestType),
252  $wsdlContent,
253  'Request type declaration in types section is invalid'
254  );
255 
256  // @codingStandardsIgnoreStart
257  if ($this->isSingleService) {
258  $responseType = <<< RESPONSE_TYPE
259 <xsd:complexType name="TestModule5AllSoapAndRestV2ItemResponse">
260  <xsd:annotation>
261  <xsd:documentation>
262  Response container for the testModule5AllSoapAndRestV2Item call.
263  </xsd:documentation>
264  <xsd:appinfo xmlns:inf="{$this->_soapUrl}"/>
265  </xsd:annotation>
266  <xsd:sequence>
267  <xsd:element name="result" minOccurs="1" maxOccurs="1" type="tns:TestModule5V2EntityAllSoapAndRest">
268  <xsd:annotation>
269  <xsd:documentation></xsd:documentation>
270  <xsd:appinfo xmlns:inf="{$this->_soapUrl}">
271  <inf:callInfo>
272  <inf:callName>testModule5AllSoapAndRestV2Item</inf:callName>
273  <inf:returned>Always</inf:returned>
274  </inf:callInfo>
275  </xsd:appinfo>
276  </xsd:annotation>
277  </xsd:element>
278  </xsd:sequence>
279 </xsd:complexType>
280 RESPONSE_TYPE;
281  } else {
282  $responseType = <<< RESPONSE_TYPE
283 <xsd:complexType name="TestModule5AllSoapAndRestV1ItemResponse">
284  <xsd:annotation>
285  <xsd:documentation>
286  Response container for the testModule5AllSoapAndRestV1Item call.
287  </xsd:documentation>
288  <xsd:appinfo xmlns:inf="{$this->_soapUrl}"/>
289  </xsd:annotation>
290  <xsd:sequence>
291  <xsd:element name="result" minOccurs="1" maxOccurs="1" type="tns:TestModule5V1EntityAllSoapAndRest">
292  <xsd:annotation>
293  <xsd:documentation></xsd:documentation>
294  <xsd:appinfo xmlns:inf="{$this->_soapUrl}">
295  <inf:callInfo>
296  <inf:callName>testModule5AllSoapAndRestV1Item</inf:callName>
297  <inf:returned>Always</inf:returned>
298  </inf:callInfo>
299  </xsd:appinfo>
300  </xsd:annotation>
301  </xsd:element>
302  </xsd:sequence>
303 </xsd:complexType>
304 RESPONSE_TYPE;
305  }
306  // @codingStandardsIgnoreEnd
307  $this->assertContains(
308  $this->_convertXmlToString($responseType),
309  $wsdlContent,
310  'Response type declaration in types section is invalid'
311  );
312  $this->_checkReferencedTypeDeclaration($wsdlContent);
313  }
314 
321  protected function _checkReferencedTypeDeclaration($wsdlContent)
322  {
323  // @codingStandardsIgnoreStart
324  if ($this->isSingleService) {
325  $referencedType = <<< RESPONSE_TYPE
326 <xsd:complexType name="TestModule5V2EntityAllSoapAndRest">
327  <xsd:annotation>
328  <xsd:documentation>Some Data Object short description. Data Object long multi line description.</xsd:documentation>
329  <xsd:appinfo xmlns:inf="{$this->_soapUrl}"/>
330  </xsd:annotation>
331  <xsd:sequence>
332  <xsd:element name="price" minOccurs="1" maxOccurs="1" type="xsd:int">
333  <xsd:annotation>
334  <xsd:documentation></xsd:documentation>
335  <xsd:appinfo xmlns:inf="{$this->_soapUrl}">
336  <inf:min/>
337  <inf:max/>
338  <inf:callInfo>
339  <inf:callName>testModule5AllSoapAndRestV2Item</inf:callName>
340  <inf:callName>testModule5AllSoapAndRestV2Create</inf:callName>
341  <inf:callName>testModule5AllSoapAndRestV2Update</inf:callName>
342  <inf:callName>testModule5AllSoapAndRestV2Delete</inf:callName>
343  <inf:returned>Always</inf:returned>
344  </inf:callInfo>
345  <inf:callInfo>
346  <inf:callName>testModule5AllSoapAndRestV2Create</inf:callName>
347  <inf:callName>testModule5AllSoapAndRestV2Update</inf:callName>
348  <inf:requiredInput>Yes</inf:requiredInput>
349  </inf:callInfo>
350  </xsd:appinfo>
351  </xsd:annotation>
352  </xsd:element>
353  </xsd:sequence>
354 </xsd:complexType>
355 RESPONSE_TYPE;
356  } else {
357  $referencedType = <<< RESPONSE_TYPE
358 <xsd:complexType name="TestModule5V1EntityAllSoapAndRest">
359  <xsd:annotation>
360  <xsd:documentation>Some Data Object short description. Data Object long multi line description.</xsd:documentation>
361  <xsd:appinfo xmlns:inf="{$this->_soapUrl}"/>
362  </xsd:annotation>
363  <xsd:sequence>
364  <xsd:element name="entityId" minOccurs="1" maxOccurs="1" type="xsd:int">
365  <xsd:annotation>
366  <xsd:documentation>Item ID</xsd:documentation>
367  <xsd:appinfo xmlns:inf="{$this->_soapUrl}">
368  <inf:min/>
369  <inf:max/>
370  <inf:callInfo>
371  <inf:callName>testModule5AllSoapAndRestV1Item</inf:callName>
372  <inf:callName>testModule5AllSoapAndRestV1Create</inf:callName>
373  <inf:callName>testModule5AllSoapAndRestV1Update</inf:callName>
374  <inf:callName>testModule5AllSoapAndRestV1NestedUpdate</inf:callName>
375  <inf:returned>Always</inf:returned>
376  </inf:callInfo>
377  <inf:callInfo>
378  <inf:callName>testModule5AllSoapAndRestV1Create</inf:callName>
379  <inf:callName>testModule5AllSoapAndRestV1Update</inf:callName>
380  <inf:callName>testModule5AllSoapAndRestV1NestedUpdate</inf:callName>
381  <inf:requiredInput>Yes</inf:requiredInput>
382  </inf:callInfo>
383  </xsd:appinfo>
384  </xsd:annotation>
385  </xsd:element>
386  <xsd:element name="name" minOccurs="0" maxOccurs="1" type="xsd:string">
387  <xsd:annotation>
388  <xsd:documentation>Item name</xsd:documentation>
389  <xsd:appinfo xmlns:inf="{$this->_soapUrl}">
390  <inf:maxLength/>
391  <inf:callInfo>
392  <inf:callName>testModule5AllSoapAndRestV1Item</inf:callName>
393  <inf:callName>testModule5AllSoapAndRestV1Create</inf:callName>
394  <inf:callName>testModule5AllSoapAndRestV1Update</inf:callName>
395  <inf:callName>testModule5AllSoapAndRestV1NestedUpdate</inf:callName>
396  <inf:returned>Conditionally</inf:returned>
397  </inf:callInfo>
398  <inf:callInfo>
399  <inf:callName>testModule5AllSoapAndRestV1Create</inf:callName>
400  <inf:callName>testModule5AllSoapAndRestV1Update</inf:callName>
401  <inf:callName>testModule5AllSoapAndRestV1NestedUpdate</inf:callName>
402  <inf:requiredInput>No</inf:requiredInput>
403  </inf:callInfo>
404  </xsd:appinfo>
405  </xsd:annotation>
406  </xsd:element>
407  <xsd:element name="enabled" minOccurs="1" maxOccurs="1" type="xsd:boolean">
408  <xsd:annotation>
409  <xsd:documentation>If entity is enabled</xsd:documentation>
410  <xsd:appinfo xmlns:inf="{$this->_soapUrl}">
411  <inf:default>false</inf:default>
412  <inf:callInfo>
413  <inf:callName>testModule5AllSoapAndRestV1Item</inf:callName>
414  <inf:callName>testModule5AllSoapAndRestV1Create</inf:callName>
415  <inf:callName>testModule5AllSoapAndRestV1Update</inf:callName>
416  <inf:callName>testModule5AllSoapAndRestV1NestedUpdate</inf:callName>
417  <inf:returned>Conditionally</inf:returned>
418  </inf:callInfo>
419  <inf:callInfo>
420  <inf:callName>testModule5AllSoapAndRestV1Create</inf:callName>
421  <inf:callName>testModule5AllSoapAndRestV1Update</inf:callName>
422  <inf:callName>testModule5AllSoapAndRestV1NestedUpdate</inf:callName>
423  <inf:requiredInput>No</inf:requiredInput>
424  </inf:callInfo>
425  </xsd:appinfo>
426  </xsd:annotation>
427  </xsd:element>
428  <xsd:element name="orders" minOccurs="1" maxOccurs="1" type="xsd:boolean">
429  <xsd:annotation>
430  <xsd:documentation>If current entity has a property defined</xsd:documentation>
431  <xsd:appinfo xmlns:inf="{$this->_soapUrl}">
432  <inf:default>false</inf:default>
433  <inf:callInfo>
434  <inf:callName>testModule5AllSoapAndRestV1Item</inf:callName>
435  <inf:callName>testModule5AllSoapAndRestV1Create</inf:callName>
436  <inf:callName>testModule5AllSoapAndRestV1Update</inf:callName>
437  <inf:callName>testModule5AllSoapAndRestV1NestedUpdate</inf:callName>
438  <inf:returned>Conditionally</inf:returned>
439  </inf:callInfo>
440  <inf:callInfo>
441  <inf:callName>testModule5AllSoapAndRestV1Create</inf:callName>
442  <inf:callName>testModule5AllSoapAndRestV1Update</inf:callName>
443  <inf:callName>testModule5AllSoapAndRestV1NestedUpdate</inf:callName>
444  <inf:requiredInput>No</inf:requiredInput>
445  </inf:callInfo>
446  </xsd:appinfo>
447  </xsd:annotation>
448  </xsd:element>
449  <xsd:element name="customAttributes" type="tns:ArrayOfFrameworkAttributeInterface" minOccurs="0">
450  <xsd:annotation>
451  <xsd:documentation>Custom attributes values.</xsd:documentation>
452  <xsd:appinfo xmlns:inf="{$this->_soapUrl}">
453  <inf:natureOfType>array</inf:natureOfType>
454  <inf:callInfo>
455  <inf:callName>testModule5AllSoapAndRestV1Item</inf:callName>
456  <inf:callName>testModule5AllSoapAndRestV1Create</inf:callName>
457  <inf:callName>testModule5AllSoapAndRestV1Update</inf:callName>
458  <inf:callName>testModule5AllSoapAndRestV1NestedUpdate</inf:callName>
459  <inf:returned>Conditionally</inf:returned>
460  </inf:callInfo>
461  <inf:callInfo>
462  <inf:callName>testModule5AllSoapAndRestV1Create</inf:callName>
463  <inf:callName>testModule5AllSoapAndRestV1Update</inf:callName>
464  <inf:callName>testModule5AllSoapAndRestV1NestedUpdate</inf:callName>
465  <inf:requiredInput>No</inf:requiredInput>
466  </inf:callInfo>
467  </xsd:appinfo>
468  </xsd:annotation>
469  </xsd:element>
470  </xsd:sequence>
471 </xsd:complexType>
472 RESPONSE_TYPE;
473  }
474  // @codingStandardsIgnoreEnd
475  $this->assertContains(
476  $this->_convertXmlToString($referencedType),
477  $wsdlContent,
478  'Declaration of complex type generated from Data Object, which is referenced in response, is invalid'
479  );
480  }
481 
487  protected function _checkPortTypeDeclaration($wsdlContent)
488  {
489  if ($this->isSingleService) {
490  $firstPortType = <<< FIRST_PORT_TYPE
491 <portType name="testModule5AllSoapAndRestV2PortType">
492 FIRST_PORT_TYPE;
493  } else {
494  $firstPortType = <<< FIRST_PORT_TYPE
495 <portType name="testModule5AllSoapAndRestV1PortType">
496 FIRST_PORT_TYPE;
497  }
498  $this->assertContains(
499  $this->_convertXmlToString($firstPortType),
500  $wsdlContent,
501  'Port type declaration is missing or invalid'
502  );
503 
504  if (!$this->isSingleService) {
505  $secondPortType = <<< SECOND_PORT_TYPE
506 <portType name="testModule5AllSoapAndRestV2PortType">
507 SECOND_PORT_TYPE;
508  $this->assertContains(
509  $this->_convertXmlToString($secondPortType),
510  $wsdlContent,
511  'Port type declaration is missing or invalid'
512  );
513  }
514 
515  if ($this->isSingleService) {
516  $operationDeclaration = <<< OPERATION_DECLARATION
517 <operation name="testModule5AllSoapAndRestV2Item">
518  <input message="tns:testModule5AllSoapAndRestV2ItemRequest"/>
519  <output message="tns:testModule5AllSoapAndRestV2ItemResponse"/>
520  <fault name="GenericFault" message="tns:GenericFault"/>
521 </operation>
522 <operation name="testModule5AllSoapAndRestV2Items">
523  <input message="tns:testModule5AllSoapAndRestV2ItemsRequest"/>
524  <output message="tns:testModule5AllSoapAndRestV2ItemsResponse"/>
525  <fault name="GenericFault" message="tns:GenericFault"/>
526 </operation>
527 OPERATION_DECLARATION;
528  } else {
529  $operationDeclaration = <<< OPERATION_DECLARATION
530 <operation name="testModule5AllSoapAndRestV2Item">
531  <input message="tns:testModule5AllSoapAndRestV2ItemRequest"/>
532  <output message="tns:testModule5AllSoapAndRestV2ItemResponse"/>
533  <fault name="GenericFault" message="tns:GenericFault"/>
534 </operation>
535 <operation name="testModule5AllSoapAndRestV2Items">
536  <input message="tns:testModule5AllSoapAndRestV2ItemsRequest"/>
537  <output message="tns:testModule5AllSoapAndRestV2ItemsResponse"/>
538  <fault name="GenericFault" message="tns:GenericFault"/>
539 </operation>
540 OPERATION_DECLARATION;
541  }
542  $this->assertContains(
543  $this->_convertXmlToString($operationDeclaration),
544  $wsdlContent,
545  'Operation in port type is invalid'
546  );
547  }
548 
554  protected function _checkBindingDeclaration($wsdlContent)
555  {
556  if ($this->isSingleService) {
557  $firstBinding = <<< FIRST_BINDING
558 <binding name="testModule5AllSoapAndRestV2Binding" type="tns:testModule5AllSoapAndRestV2PortType">
559  <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
560 FIRST_BINDING;
561  } else {
562  $firstBinding = <<< FIRST_BINDING
563 <binding name="testModule5AllSoapAndRestV1Binding" type="tns:testModule5AllSoapAndRestV1PortType">
564  <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
565 FIRST_BINDING;
566  }
567  $this->assertContains(
568  $this->_convertXmlToString($firstBinding),
569  $wsdlContent,
570  'Binding declaration is missing or invalid'
571  );
572 
573  if (!$this->isSingleService) {
574  $secondBinding = <<< SECOND_BINDING
575 <binding name="testModule5AllSoapAndRestV2Binding" type="tns:testModule5AllSoapAndRestV2PortType">
576  <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
577 SECOND_BINDING;
578  $this->assertContains(
579  $this->_convertXmlToString($secondBinding),
580  $wsdlContent,
581  'Binding declaration is missing or invalid'
582  );
583  }
584 
585  if ($this->isSingleService) {
586  $operationDeclaration = <<< OPERATION_DECLARATION
587 <operation name="testModule5AllSoapAndRestV2Item">
588  <soap12:operation soapAction="testModule5AllSoapAndRestV2Item"/>
589  <input>
590  <soap12:body use="literal"/>
591  </input>
592  <output>
593  <soap12:body use="literal"/>
594  </output>
595  <fault name="GenericFault"/>
596 </operation>
597 <operation name="testModule5AllSoapAndRestV2Items">
598  <soap12:operation soapAction="testModule5AllSoapAndRestV2Items"/>
599  <input>
600  <soap12:body use="literal"/>
601  </input>
602  <output>
603  <soap12:body use="literal"/>
604  </output>
605  <fault name="GenericFault"/>
606 </operation>
607 OPERATION_DECLARATION;
608  } else {
609  $operationDeclaration = <<< OPERATION_DECLARATION
610 <operation name="testModule5AllSoapAndRestV1Item">
611  <soap12:operation soapAction="testModule5AllSoapAndRestV1Item"/>
612  <input>
613  <soap12:body use="literal"/>
614  </input>
615  <output>
616  <soap12:body use="literal"/>
617  </output>
618  <fault name="GenericFault"/>
619 </operation>
620 <operation name="testModule5AllSoapAndRestV1Items">
621  <soap12:operation soapAction="testModule5AllSoapAndRestV1Items"/>
622  <input>
623  <soap12:body use="literal"/>
624  </input>
625  <output>
626  <soap12:body use="literal"/>
627  </output>
628  <fault name="GenericFault"/>
629 </operation>
630 OPERATION_DECLARATION;
631  }
632  $this->assertContains(
633  $this->_convertXmlToString($operationDeclaration),
634  $wsdlContent,
635  'Operation in binding is invalid'
636  );
637  }
638 
644  protected function _checkServiceDeclaration($wsdlContent)
645  {
646  // @codingStandardsIgnoreStart
647  if ($this->isSingleService) {
648  $firstServiceDeclaration = <<< FIRST_SERVICE_DECLARATION
649 <service name="testModule5AllSoapAndRestV2Service">
650  <port name="testModule5AllSoapAndRestV2Port" binding="tns:testModule5AllSoapAndRestV2Binding">
651  <soap12:address location="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV2"/>
652  </port>
653 </service>
654 FIRST_SERVICE_DECLARATION;
655  } else {
656  $firstServiceDeclaration = <<< FIRST_SERVICE_DECLARATION
657 <service name="testModule5AllSoapAndRestV1Service">
658  <port name="testModule5AllSoapAndRestV1Port" binding="tns:testModule5AllSoapAndRestV1Binding">
659  <soap12:address location="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV1%2CtestModule5AllSoapAndRestV2"/>
660  </port>
661 </service>
662 FIRST_SERVICE_DECLARATION;
663  }
664  // @codingStandardsIgnoreEnd
665  $this->assertContains(
666  $this->_convertXmlToString($firstServiceDeclaration),
667  $wsdlContent,
668  'First service section is invalid'
669  );
670 
671  // @codingStandardsIgnoreStart
672  if (!$this->isSingleService) {
673  $secondServiceDeclaration = <<< SECOND_SERVICE_DECLARATION
674 <service name="testModule5AllSoapAndRestV2Service">
675  <port name="testModule5AllSoapAndRestV2Port" binding="tns:testModule5AllSoapAndRestV2Binding">
676  <soap12:address location="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV1%2CtestModule5AllSoapAndRestV2"/>
677  </port>
678 </service>
679 SECOND_SERVICE_DECLARATION;
680  // @codingStandardsIgnoreEnd
681  $this->assertContains(
682  $this->_convertXmlToString($secondServiceDeclaration),
683  $wsdlContent,
684  'Second service section is invalid'
685  );
686  }
687  }
688 
694  protected function _checkMessagesDeclaration($wsdlContent)
695  {
696  $itemMessagesDeclaration = <<< MESSAGES_DECLARATION
697 <message name="testModule5AllSoapAndRestV2ItemRequest">
698  <part name="messageParameters" element="tns:testModule5AllSoapAndRestV2ItemRequest"/>
699 </message>
700 <message name="testModule5AllSoapAndRestV2ItemResponse">
701  <part name="messageParameters" element="tns:testModule5AllSoapAndRestV2ItemResponse"/>
702 </message>
703 MESSAGES_DECLARATION;
704  $this->assertContains(
705  $this->_convertXmlToString($itemMessagesDeclaration),
706  $wsdlContent,
707  'Messages section for "item" operation is invalid'
708  );
709  $itemsMessagesDeclaration = <<< MESSAGES_DECLARATION
710 <message name="testModule5AllSoapAndRestV2ItemsRequest">
711  <part name="messageParameters" element="tns:testModule5AllSoapAndRestV2ItemsRequest"/>
712 </message>
713 <message name="testModule5AllSoapAndRestV2ItemsResponse">
714  <part name="messageParameters" element="tns:testModule5AllSoapAndRestV2ItemsResponse"/>
715 </message>
716 MESSAGES_DECLARATION;
717  $this->assertContains(
718  $this->_convertXmlToString($itemsMessagesDeclaration),
719  $wsdlContent,
720  'Messages section for "items" operation is invalid'
721  );
722  }
723 
729  protected function _checkFaultsDeclaration($wsdlContent)
730  {
731  $this->_checkFaultsPortTypeSection($wsdlContent);
732  $this->_checkFaultsBindingSection($wsdlContent);
733  $this->_checkFaultsMessagesSection($wsdlContent);
734  $this->_checkFaultsComplexTypeSection($wsdlContent);
735  }
736 
740  protected function _checkFaultsPortTypeSection($wsdlContent)
741  {
742  $faultsInPortType = <<< FAULT_IN_PORT_TYPE
743 <fault name="GenericFault" message="tns:GenericFault"/>
744 FAULT_IN_PORT_TYPE;
745  $this->assertContains(
746  $this->_convertXmlToString($faultsInPortType),
747  $wsdlContent,
748  'SOAP Fault section in port type section is invalid'
749  );
750  }
751 
755  protected function _checkFaultsBindingSection($wsdlContent)
756  {
757  $faultsInBinding = <<< FAULT_IN_BINDING
758 <fault name="GenericFault"/>
759 FAULT_IN_BINDING;
760  $this->assertContains(
761  $this->_convertXmlToString($faultsInBinding),
762  $wsdlContent,
763  'SOAP Fault section in binding section is invalid'
764  );
765  }
766 
770  protected function _checkFaultsMessagesSection($wsdlContent)
771  {
772  $genericFaultMessage = <<< GENERIC_FAULT_IN_MESSAGES
773 <message name="GenericFault">
774  <part name="messageParameters" element="tns:GenericFault"/>
775 </message>
776 GENERIC_FAULT_IN_MESSAGES;
777  $this->assertContains(
778  $this->_convertXmlToString($genericFaultMessage),
779  $wsdlContent,
780  'Generic SOAP Fault declaration in messages section is invalid'
781  );
782  }
783 
788  protected function _checkFaultsComplexTypeSection($wsdlContent)
789  {
790  $this->assertContains(
791  $this->_convertXmlToString('<xsd:element name="GenericFault" type="tns:GenericFault"/>'),
792  $wsdlContent,
793  'Default SOAP Fault complex type element declaration is invalid'
794  );
795 
796  // @codingStandardsIgnoreStart
797  $genericFaultType = <<< GENERIC_FAULT_COMPLEX_TYPE
798 <xsd:complexType name="GenericFault">
799  <xsd:sequence>
800  <xsd:element name="Trace" minOccurs="0" maxOccurs="1" type="xsd:string">
801  <xsd:annotation>
802  <xsd:documentation>Exception calls stack trace.</xsd:documentation>
803  <xsd:appinfo xmlns:inf="{$this->_soapUrl}">
804  <inf:maxLength/>
805  </xsd:appinfo>
806  </xsd:annotation>
807  </xsd:element>
808  <xsd:element name="Parameters" type="tns:ArrayOfGenericFaultParameter" minOccurs="0">
809  <xsd:annotation>
810  <xsd:documentation>Additional exception parameters.</xsd:documentation>
811  <xsd:appinfo xmlns:inf="{$this->_soapUrl}">
812  <inf:natureOfType>array</inf:natureOfType>
813  </xsd:appinfo>
814  </xsd:annotation>
815  </xsd:element>
816  <xsd:element name="WrappedErrors" type="tns:ArrayOfWrappedError" minOccurs="0">
817  <xsd:annotation>
818  <xsd:documentation>Additional wrapped errors.</xsd:documentation>
819  <xsd:appinfo xmlns:inf="{$this->_soapUrl}">
820  <inf:natureOfType>array</inf:natureOfType>
821  </xsd:appinfo>
822  </xsd:annotation>
823  </xsd:element>
824  </xsd:sequence>
825 </xsd:complexType>
826 GENERIC_FAULT_COMPLEX_TYPE;
827  $this->assertContains(
828  $this->_convertXmlToString($genericFaultType),
829  $wsdlContent,
830  'Default SOAP Fault complex types declaration is invalid'
831  );
832 
833  $detailsParameterType = <<< PARAM_COMPLEX_TYPE
834 <xsd:complexType name="GenericFaultParameter">
835  <xsd:sequence>
836  <xsd:element name="key" minOccurs="1" maxOccurs="1" type="xsd:string">
837  <xsd:annotation>
838  <xsd:documentation></xsd:documentation>
839  <xsd:appinfo xmlns:inf="{$this->_soapUrl}">
840  <inf:maxLength/>
841  </xsd:appinfo>
842  </xsd:annotation>
843  </xsd:element>
844  <xsd:element name="value" minOccurs="1" maxOccurs="1" type="xsd:string">
845  <xsd:annotation>
846  <xsd:documentation></xsd:documentation>
847  <xsd:appinfo xmlns:inf="{$this->_soapUrl}">
848  <inf:maxLength/>
849  </xsd:appinfo>
850  </xsd:annotation>
851  </xsd:element>
852  </xsd:sequence>
853 </xsd:complexType>
854 PARAM_COMPLEX_TYPE;
855  $this->assertContains(
856  $this->_convertXmlToString($detailsParameterType),
857  $wsdlContent,
858  'Details parameter complex types declaration is invalid.'
859  );
860 
861  // @codingStandardsIgnoreStart
862  if ($this->isSingleService) {
863  $detailsWrappedErrorType = <<< WRAPPED_ERROR_COMPLEX_TYPE
864 <xsd:complexType name="WrappedError">
865  <xsd:sequence>
866  <xsd:element name="message" minOccurs="1" maxOccurs="1" type="xsd:string">
867  <xsd:annotation>
868  <xsd:documentation></xsd:documentation>
869  <xsd:appinfo xmlns:inf="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV2">
870  <inf:maxLength/>
871  </xsd:appinfo>
872  </xsd:annotation>
873  </xsd:element>
874  <xsd:element name="parameters" type="tns:ArrayOfGenericFaultParameter" minOccurs="0">
875  <xsd:annotation>
876  <xsd:documentation>Message parameters.</xsd:documentation>
877  <xsd:appinfo xmlns:inf="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV2">
878  <inf:natureOfType>array</inf:natureOfType>
879  </xsd:appinfo>
880  </xsd:annotation>
881  </xsd:element>
882  </xsd:sequence>
883 </xsd:complexType>
884 WRAPPED_ERROR_COMPLEX_TYPE;
885  } else {
886  $detailsWrappedErrorType = <<< WRAPPED_ERROR_COMPLEX_TYPE
887 <xsd:complexType name="WrappedError">
888  <xsd:sequence>
889  <xsd:element name="message" minOccurs="1" maxOccurs="1" type="xsd:string">
890  <xsd:annotation>
891  <xsd:documentation></xsd:documentation>
892  <xsd:appinfo xmlns:inf="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV1%2CtestModule5AllSoapAndRestV2">
893  <inf:maxLength/>
894  </xsd:appinfo>
895  </xsd:annotation>
896  </xsd:element>
897  <xsd:element name="parameters" type="tns:ArrayOfGenericFaultParameter" minOccurs="0">
898  <xsd:annotation>
899  <xsd:documentation>Message parameters.</xsd:documentation>
900  <xsd:appinfo xmlns:inf="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV1%2CtestModule5AllSoapAndRestV2">
901  <inf:natureOfType>array</inf:natureOfType>
902  </xsd:appinfo>
903  </xsd:annotation>
904  </xsd:element>
905  </xsd:sequence>
906 </xsd:complexType>
907 WRAPPED_ERROR_COMPLEX_TYPE;
908  }
909  // @codingStandardsIgnoreEnd
910  $this->assertContains(
911  $this->_convertXmlToString($detailsWrappedErrorType),
912  $wsdlContent,
913  'Details wrapped error complex types declaration is invalid.'
914  );
915 
916  $detailsParametersType = <<< PARAMETERS_COMPLEX_TYPE
917 <xsd:complexType name="ArrayOfGenericFaultParameter">
918  <xsd:annotation>
919  <xsd:documentation>An array of GenericFaultParameter items.</xsd:documentation>
920  <xsd:appinfo xmlns:inf="{$this->_soapUrl}"/>
921  </xsd:annotation>
922  <xsd:sequence>
923  <xsd:element name="item" minOccurs="0" maxOccurs="unbounded" type="tns:GenericFaultParameter">
924  <xsd:annotation>
925  <xsd:documentation>An item of ArrayOfGenericFaultParameter.</xsd:documentation>
926  <xsd:appinfo xmlns:inf="{$this->_soapUrl}"/>
927  </xsd:annotation>
928  </xsd:element>
929  </xsd:sequence>
930 </xsd:complexType>
931 PARAMETERS_COMPLEX_TYPE;
932  // @codingStandardsIgnoreEnd
933  $this->assertContains(
934  $this->_convertXmlToString($detailsParametersType),
935  $wsdlContent,
936  'Details parameters (array of parameters) complex types declaration is invalid.'
937  );
938 
939  if ($this->isSingleService) {
940  // @codingStandardsIgnoreStart
941  $detailsWrappedErrorsType = <<< WRAPPED_ERRORS_COMPLEX_TYPE
942 <xsd:complexType name="ArrayOfWrappedError">
943  <xsd:annotation>
944  <xsd:documentation>An array of WrappedError items.</xsd:documentation>
945  <xsd:appinfo xmlns:inf="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV2"/>
946  </xsd:annotation>
947  <xsd:sequence>
948  <xsd:element name="item" minOccurs="0" maxOccurs="unbounded" type="tns:WrappedError">
949  <xsd:annotation>
950  <xsd:documentation>An item of ArrayOfWrappedError.</xsd:documentation>
951  <xsd:appinfo xmlns:inf="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV2"/>
952  </xsd:annotation>
953  </xsd:element>
954  </xsd:sequence>
955 </xsd:complexType>
956 WRAPPED_ERRORS_COMPLEX_TYPE;
957  } else {
958  $detailsWrappedErrorsType = <<< WRAPPED_ERRORS_COMPLEX_TYPE
959 <xsd:complexType name="ArrayOfWrappedError">
960  <xsd:annotation>
961  <xsd:documentation>An array of WrappedError items.</xsd:documentation>
962  <xsd:appinfo xmlns:inf="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV1%2CtestModule5AllSoapAndRestV2"/>
963  </xsd:annotation>
964  <xsd:sequence>
965  <xsd:element name="item" minOccurs="0" maxOccurs="unbounded" type="tns:WrappedError">
966  <xsd:annotation>
967  <xsd:documentation>An item of ArrayOfWrappedError.</xsd:documentation>
968  <xsd:appinfo xmlns:inf="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV1%2CtestModule5AllSoapAndRestV2"/>
969  </xsd:annotation>
970  </xsd:element>
971  </xsd:sequence>
972 </xsd:complexType>
973 WRAPPED_ERRORS_COMPLEX_TYPE;
974 
975  }
976  // @codingStandardsIgnoreEnd
977  $this->assertContains(
978  $this->_convertXmlToString($detailsWrappedErrorsType),
979  $wsdlContent,
980  'Details wrapped errors (array of wrapped errors) complex types declaration is invalid.'
981  );
982  }
983 }
output($string, $level=INFO, $label='')
$connection
Definition: bulk.php:13