Skip to content

Commit 30f44e4

Browse files
committed
reformatted code
1 parent 3ec56cc commit 30f44e4

File tree

1 file changed

+50
-27
lines changed

1 file changed

+50
-27
lines changed

src/Codeception/Module/SOAP.php

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
class SOAP extends \Codeception\Module
3838
{
3939

40-
protected $config = array('schema' => "", 'schema_url' => 'http://schemas.xmlsoap.org/soap/envelope/');
41-
protected $requiredFields = array('endpoint');
40+
protected $config = ['schema' => "", 'schema_url' => 'http://schemas.xmlsoap.org/soap/envelope/'];
41+
protected $requiredFields = ['endpoint'];
4242
/**
4343
* @var \Symfony\Component\BrowserKit\Client
4444
*/
@@ -67,11 +67,14 @@ public function _before(\Codeception\TestCase $test)
6767
}
6868
}
6969
} else {
70-
if (!$this->hasModule('PhpBrowser'))
70+
if (!$this->hasModule('PhpBrowser')) {
7171
throw new \Codeception\Exception\ModuleConfig(__CLASS__, "For Soap testing via HTTP please enable PhpBrowser module");
72+
}
7273
$this->client = $this->getModule('PhpBrowser')->client;
7374
}
74-
if (!$this->client) throw new \Codeception\Exception\ModuleConfig(__CLASS__, "Client for SOAP requests not initialized.\nProvide either PhpBrowser module or Framework module which shares FrameworkInterface");
75+
if (!$this->client) {
76+
throw new \Codeception\Exception\ModuleConfig(__CLASS__, "Client for SOAP requests not initialized.\nProvide either PhpBrowser module or Framework module which shares FrameworkInterface");
77+
}
7578
}
7679

7780
$this->buildRequest();
@@ -104,7 +107,7 @@ public function _before(\Codeception\TestCase $test)
104107
* @param $header
105108
* @param array $params
106109
*/
107-
public function haveSoapHeader($header, $params = array())
110+
public function haveSoapHeader($header, $params = [])
108111
{
109112
$soap_schema_url = $this->config['schema_url'];
110113
$xml = $this->xmlRequest;
@@ -271,7 +274,8 @@ public function dontSeeSoapResponseIncludes($xml)
271274
*
272275
* @param $xml
273276
*/
274-
public function seeSoapResponseContainsStructure($xml) {
277+
public function seeSoapResponseContainsStructure($xml)
278+
{
275279
$xml = SoapUtils::toXml($xml);
276280
$this->debugSection("Structure", $xml->saveXML());
277281
$root = $xml->firstChild;
@@ -280,7 +284,9 @@ public function seeSoapResponseContainsStructure($xml) {
280284

281285
$els = $this->xmlResponse->getElementsByTagName($root->nodeName);
282286

283-
if (empty($els)) return \PHPUnit_Framework_Assert::fail("Element {$root->nodeName} not found in response");
287+
if (empty($els)) {
288+
return \PHPUnit_Framework_Assert::fail("Element {$root->nodeName} not found in response");
289+
}
284290

285291
$matches = false;
286292
foreach ($els as $node) {
@@ -305,7 +311,9 @@ public function seeSoapResponseContainsXPath($xpath)
305311
{
306312
$path = new \DOMXPath($this->xmlResponse);
307313
$res = $path->query($xpath);
308-
if ($res === false) $this->fail("XPath selector is malformed");
314+
if ($res === false) {
315+
$this->fail("XPath selector is malformed");
316+
}
309317
$this->assertGreaterThan(0, $res->length);
310318
}
311319

@@ -324,18 +332,20 @@ public function dontSeeSoapResponseContainsXPath($xpath)
324332
{
325333
$path = new \DOMXPath($this->xmlResponse);
326334
$res = $path->query($xpath);
327-
if ($res === false) $this->fail("XPath selector is malformed");
335+
if ($res === false) {
336+
$this->fail("XPath selector is malformed");
337+
}
328338
$this->assertEquals(0, $res->length);
329339
}
330340

331341

332-
333342
/**
334343
* Checks response code from server.
335344
*
336345
* @param $code
337346
*/
338-
public function seeResponseCodeIs($code) {
347+
public function seeResponseCodeIs($code)
348+
{
339349
\PHPUnit_Framework_Assert::assertEquals($code, $this->client->getInternalResponse()->getStatus(), "soap response code matches expected");
340350
}
341351

@@ -347,7 +357,8 @@ public function seeResponseCodeIs($code) {
347357
* @param $cssOrXPath
348358
* @return string
349359
*/
350-
public function grabTextContentFrom($cssOrXPath) {
360+
public function grabTextContentFrom($cssOrXPath)
361+
{
351362
$el = $this->matchElement($cssOrXPath);
352363
return $el->textContent;
353364
}
@@ -361,9 +372,12 @@ public function grabTextContentFrom($cssOrXPath) {
361372
* @param $attribute
362373
* @return string
363374
*/
364-
public function grabAttributeFrom($cssOrXPath, $attribute) {
375+
public function grabAttributeFrom($cssOrXPath, $attribute)
376+
{
365377
$el = $this->matchElement($cssOrXPath);
366-
if (!$el->hasAttribute($attribute)) $this->fail("Attribute not found in element matched by '$cssOrXPath'");
378+
if (!$el->hasAttribute($attribute)) {
379+
$this->fail("Attribute not found in element matched by '$cssOrXPath'");
380+
}
367381
return $el->getAttribute($attribute);
368382
}
369383

@@ -377,8 +391,11 @@ protected function matchElement($cssOrXPath)
377391
try {
378392
$selector = \Symfony\Component\CssSelector\CssSelector::toXPath($cssOrXPath);
379393
$els = $xpath->query($selector);
380-
if ($els) return $els->item(0);
381-
} catch (\Symfony\Component\CssSelector\Exception\ParseException $e) {}
394+
if ($els) {
395+
return $els->item(0);
396+
}
397+
} catch (\Symfony\Component\CssSelector\Exception\ParseException $e) {
398+
}
382399
$els = $xpath->query($cssOrXPath);
383400
if ($els) {
384401
return $els->item(0);
@@ -394,10 +411,14 @@ protected function structureMatches($schema, $xml)
394411
foreach ($xml->childNodes as $node2) {
395412
if ($node1->nodeName == $node2->nodeName) {
396413
$matched = $this->structureMatches($node1, $node2);
397-
if ($matched) break;
414+
if ($matched) {
415+
break;
416+
}
398417
}
399418
}
400-
if (!$matched) return false;
419+
if (!$matched) {
420+
return false;
421+
}
401422
}
402423
return true;
403424
}
@@ -434,14 +455,16 @@ protected function buildRequest()
434455

435456
protected function processRequest($action, $body)
436457
{
437-
$this->client->request('POST',
438-
$this->config['endpoint'],
439-
array(), array(),
440-
array(
441-
"HTTP_Content-Type" => "text/xml; charset=UTF-8",
442-
'HTTP_Content-Length' => strlen($body),
443-
'HTTP_SOAPAction' => $action),
444-
$body
458+
$this->client->request(
459+
'POST',
460+
$this->config['endpoint'],
461+
[], [],
462+
[
463+
"HTTP_Content-Type" => "text/xml; charset=UTF-8",
464+
'HTTP_Content-Length' => strlen($body),
465+
'HTTP_SOAPAction' => $action
466+
],
467+
$body
445468
);
446469
}
447470

@@ -453,7 +476,7 @@ protected function processInternalRequest($action, $body)
453476
$this->processRequest($action, $body);
454477
} catch (\ErrorException $e) {
455478
// Zend_Soap outputs warning as an exception
456-
if (strpos($e->getMessage(),'Warning: Cannot modify header information')===false) {
479+
if (strpos($e->getMessage(), 'Warning: Cannot modify header information') === false) {
457480
ob_end_clean();
458481
throw $e;
459482
}

0 commit comments

Comments
 (0)