44
55namespace Codeception \Module ;
66
7- use Codeception \Lib \Interfaces \DependsOnModule ;
8- use Codeception \Module ;
9- use Codeception \TestInterface ;
107use Codeception \Exception \ModuleException ;
118use Codeception \Exception \ModuleRequireException ;
129use Codeception \Lib \Framework ;
1310use Codeception \Lib \InnerBrowser ;
11+ use Codeception \Lib \Interfaces \DependsOnModule ;
12+ use Codeception \Module ;
13+ use Codeception \TestInterface ;
1414use Codeception \Util \Soap as SoapUtils ;
1515use Codeception \Util \XmlStructure ;
1616use DOMDocument ;
17+ use ErrorException ;
1718use PHPUnit \Framework \Assert ;
1819use Symfony \Component \BrowserKit \AbstractBrowser ;
1920
@@ -124,7 +125,7 @@ protected function onReconfigure(): void
124125
125126 public function _depends ()
126127 {
127- return [\ Codeception \ Lib \ InnerBrowser::class => $ this ->dependencyMessage ];
128+ return [InnerBrowser::class => $ this ->dependencyMessage ];
128129 }
129130
130131 public function _inject (InnerBrowser $ connectionModule ): void
@@ -151,7 +152,7 @@ private function getXmlResponse(): DOMDocument
151152 return $ this ->xmlResponse ;
152153 }
153154
154- private function getXmlStructure (): \ Codeception \ Util \ XmlStructure
155+ private function getXmlStructure (): XmlStructure
155156 {
156157 if (!$ this ->xmlStructure ) {
157158 $ this ->xmlStructure = new XmlStructure ($ this ->getXmlResponse ());
@@ -182,9 +183,9 @@ private function getXmlStructure(): \Codeception\Util\XmlStructure
182183 * </soapenv:Header>
183184 * ```
184185 *
185- * @param $header
186+ * @param string $header
186187 */
187- public function haveSoapHeader ($ header , array $ params = []): void
188+ public function haveSoapHeader (string $ header , array $ params = []): void
188189 {
189190 $ soap_schema_url = $ this ->config ['schema_url ' ];
190191 $ xml = $ this ->xmlRequest ;
@@ -211,10 +212,10 @@ public function haveSoapHeader($header, array $params = []): void
211212 * ->name->val('notdavert');
212213 * ```
213214 *
214- * @param $request
215- * @param $body
215+ * @param string $action
216+ * @param object|string $body
216217 */
217- public function sendSoapRequest ($ action , $ body = '' ): void
218+ public function sendSoapRequest (string $ action , $ body = '' ): void
218219 {
219220 $ soap_schema_url = $ this ->config ['schema_url ' ];
220221 $ xml = $ this ->xmlRequest ;
@@ -268,9 +269,9 @@ public function sendSoapRequest($action, $body = ''): void
268269 *
269270 * ```
270271 *
271- * @param $xml
272+ * @param string $xml
272273 */
273- public function seeSoapResponseEquals ($ xml ): void
274+ public function seeSoapResponseEquals (string $ xml ): void
274275 {
275276 $ xml = SoapUtils::toXml ($ xml );
276277 $ this ->assertEquals ($ xml ->C14N (), $ this ->getXmlResponse ()->C14N ());
@@ -293,12 +294,12 @@ public function seeSoapResponseEquals($xml): void
293294 * $I->seeSoapRequestIncludes($dom);
294295 * ```
295296 *
296- * @param $xml
297+ * @param string $xml
297298 */
298- public function seeSoapResponseIncludes ($ xml ): void
299+ public function seeSoapResponseIncludes (string $ xml ): void
299300 {
300301 $ xml = $ this ->canonicalize ($ xml );
301- $ this ->assertStringContainsString ($ xml , $ this ->getXmlResponse ()->C14N (), " found in XML Response " );
302+ $ this ->assertStringContainsString ($ xml , $ this ->getXmlResponse ()->C14N (), ' found in XML Response ' );
302303 }
303304
304305
@@ -308,9 +309,9 @@ public function seeSoapResponseIncludes($xml): void
308309 *
309310 * Parameter can be passed either as XmlBuilder, DOMDocument, DOMNode, XML string, or array (if no attributes).
310311 *
311- * @param $xml
312+ * @param string $xml
312313 */
313- public function dontSeeSoapResponseEquals ($ xml ): void
314+ public function dontSeeSoapResponseEquals (string $ xml ): void
314315 {
315316 $ xml = SoapUtils::toXml ($ xml );
316317 Assert::assertXmlStringNotEqualsXmlString ($ xml ->C14N (), $ this ->getXmlResponse ()->C14N ());
@@ -322,9 +323,9 @@ public function dontSeeSoapResponseEquals($xml): void
322323 * Comparison is done by canonicalizing both xml`s.
323324 * Parameter can be passed either as XmlBuilder, DOMDocument, DOMNode, XML string, or array (if no attributes).
324325 *
325- * @param $xml
326+ * @param string $xml
326327 */
327- public function dontSeeSoapResponseIncludes ($ xml ): void
328+ public function dontSeeSoapResponseIncludes (string $ xml ): void
328329 {
329330 $ xml = $ this ->canonicalize ($ xml );
330331 $ this ->assertStringNotContainsString ($ xml , $ this ->getXmlResponse ()->C14N (), "found in XML Response " );
@@ -347,9 +348,9 @@ public function dontSeeSoapResponseIncludes($xml): void
347348 * This method does not use schema for validation.
348349 * This method does not require path from root to match the structure.
349350 *
350- * @param $xml
351+ * @param string $xml
351352 */
352- public function seeSoapResponseContainsStructure ($ xml ): void
353+ public function seeSoapResponseContainsStructure (string $ xml ): void
353354 {
354355 $ xml = SoapUtils::toXml ($ xml );
355356 $ this ->debugSection ("Structure " , $ xml ->saveXML ());
@@ -358,9 +359,9 @@ public function seeSoapResponseContainsStructure($xml): void
358359
359360 /**
360361 * Opposite to `seeSoapResponseContainsStructure`
361- * @param $xml
362+ * @param string $xml
362363 */
363- public function dontSeeSoapResponseContainsStructure ($ xml ): void
364+ public function dontSeeSoapResponseContainsStructure (string $ xml ): void
364365 {
365366 $ xml = SoapUtils::toXml ($ xml );
366367 $ this ->debugSection ("Structure " , $ xml ->saveXML ());
@@ -375,9 +376,9 @@ public function dontSeeSoapResponseContainsStructure($xml): void
375376 * $I->seeSoapResponseContainsXPath('//root/user[@id=1]');
376377 * ```
377378 *
378- * @param $xPath
379+ * @param string $xPath
379380 */
380- public function seeSoapResponseContainsXPath ($ xPath ): void
381+ public function seeSoapResponseContainsXPath (string $ xPath ): void
381382 {
382383 $ this ->assertTrue ($ this ->getXmlStructure ()->matchesXpath ($ xPath ));
383384 }
@@ -390,9 +391,9 @@ public function seeSoapResponseContainsXPath($xPath): void
390391 * $I->dontSeeSoapResponseContainsXPath('//root/user[@id=1]');
391392 * ```
392393 *
393- * @param $xPath
394+ * @param string $xPath
394395 */
395- public function dontSeeSoapResponseContainsXPath ($ xPath ): void
396+ public function dontSeeSoapResponseContainsXPath (string $ xPath ): void
396397 {
397398 $ this ->assertFalse ($ this ->getXmlStructure ()->matchesXpath ($ xPath ));
398399 }
@@ -401,9 +402,9 @@ public function dontSeeSoapResponseContainsXPath($xPath): void
401402 /**
402403 * Checks response code from server.
403404 *
404- * @param $code
405+ * @param string $code
405406 */
406- public function seeSoapResponseCodeIs ($ code ): void
407+ public function seeSoapResponseCodeIs (string $ code ): void
407408 {
408409 $ this ->assertEquals (
409410 $ code ,
@@ -417,9 +418,9 @@ public function seeSoapResponseCodeIs($code): void
417418 * Element is matched by either CSS or XPath
418419 *
419420 * @version 1.1
420- * @param $cssOrXPath
421+ * @param string $cssOrXPath
421422 */
422- public function grabTextContentFrom ($ cssOrXPath ): string
423+ public function grabTextContentFrom (string $ cssOrXPath ): string
423424 {
424425 $ el = $ this ->getXmlStructure ()->matchElement ($ cssOrXPath );
425426 return $ el ->textContent ;
@@ -430,10 +431,10 @@ public function grabTextContentFrom($cssOrXPath): string
430431 * Element is matched by either CSS or XPath
431432 *
432433 * @version 1.1
433- * @param $cssOrXPath
434- * @param $attribute
434+ * @param string $cssOrXPath
435+ * @param string $attribute
435436 */
436- public function grabAttributeFrom ($ cssOrXPath , $ attribute ): string
437+ public function grabAttributeFrom (string $ cssOrXPath , string $ attribute ): string
437438 {
438439 $ el = $ this ->getXmlStructure ()->matchElement ($ cssOrXPath );
439440 $ elHasAttribute = $ el ->hasAttribute ($ attribute );
@@ -448,7 +449,7 @@ protected function getSchema()
448449 return $ this ->config ['schema ' ];
449450 }
450451
451- protected function canonicalize ($ xml ): string
452+ protected function canonicalize (string $ xml ): string
452453 {
453454 return SoapUtils::toXml ($ xml )->C14N ();
454455 }
@@ -471,7 +472,7 @@ protected function buildRequest(): DOMDocument
471472 return $ xml ;
472473 }
473474
474- protected function processRequest ($ action , $ body ): void
475+ protected function processRequest (string $ action , string $ body ): void
475476 {
476477 $ this ->getClient ()->request (
477478 'POST ' ,
@@ -490,13 +491,13 @@ protected function processRequest($action, $body): void
490491 /**
491492 * @return string|bool
492493 */
493- protected function processInternalRequest ($ action , $ body )
494+ protected function processInternalRequest (string $ action , string $ body )
494495 {
495496 ob_start ();
496497 try {
497498 $ this ->getClient ()->setServerParameter ('HTTP_HOST ' , 'localhost ' );
498499 $ this ->processRequest ($ action , $ body );
499- } catch (\ ErrorException $ e ) {
500+ } catch (ErrorException $ e ) {
500501 // Zend_Soap outputs warning as an exception
501502 if (strpos ($ e ->getMessage (), 'Warning: Cannot modify header information ' ) === false ) {
502503 ob_end_clean ();
@@ -508,7 +509,7 @@ protected function processInternalRequest($action, $body)
508509 return $ response ;
509510 }
510511
511- protected function processExternalRequest ($ action , $ body ): string
512+ protected function processExternalRequest (string $ action , string $ body ): string
512513 {
513514 $ this ->processRequest ($ action , $ body );
514515 return $ this ->client ->getInternalResponse ()->getContent ();
0 commit comments