Skip to content

Commit 9aef1fd

Browse files
committed
issue #31 - handle outputHeaders property
1 parent 91722fb commit 9aef1fd

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"email" : "[email protected]"
4646
},
4747
"require": {
48-
"php" : ">=5.4"
48+
"php" : ">=5.4",
49+
"ext-soap": "*"
4950
},
5051
"scripts": {
5152
"test": "vendor/bin/phpunit",

src/AbstractSoapClientBase.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ abstract class AbstractSoapClientBase implements SoapClientInterface
1919
* @var array
2020
*/
2121
private $lastError;
22+
/**
23+
* Contains output headers
24+
* @var array
25+
*/
26+
protected $outputHeaders = [];
2227
/**
2328
* Constructor
2429
* @uses AbstractSoapClientBase::setLastError()
@@ -482,4 +487,11 @@ public function setResult($result)
482487
$this->result = $result;
483488
return $this;
484489
}
490+
/**
491+
* @return array
492+
*/
493+
public function getOutputHeaders()
494+
{
495+
return $this->outputHeaders;
496+
}
485497
}

tests/SoapClient.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace WsdlToPhp\PackageBase\Tests;
44

5+
use SoapFault;
56
use WsdlToPhp\PackageBase\AbstractSoapClientBase;
67

78
class SoapClient extends AbstractSoapClientBase
@@ -24,7 +25,7 @@ public function search()
2425
{
2526
try {
2627
self::getSoapClient()->search();
27-
} catch (\SoapFault $soapFault) {
28+
} catch (SoapFault $soapFault) {
2829
$this->setResult(null);
2930
$this->saveLastError(__METHOD__, $soapFault);
3031
}

tests/SoapClientTest.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace WsdlToPhp\PackageBase\Tests;
44

55
use WsdlToPhp\PackageBase\Utils;
6-
use WsdlToPhp\PackageBase\Tests\SoapClient;
76

87
class SoapClientTest extends TestCase
98
{
@@ -486,7 +485,7 @@ public static function classMap()
486485
*/
487486
public function testInvalidNonWsdlModeMustNotCreateASoapInstanceForMissingUriAndLocationOptions()
488487
{
489-
$soapClient = new SoapClient(array(
488+
new SoapClient(array(
490489
SoapClient::WSDL_URL => null,
491490
));
492491

@@ -497,7 +496,7 @@ public function testInvalidNonWsdlModeMustNotCreateASoapInstanceForMissingUriAnd
497496
*/
498497
public function testInvalidNonWsdlModeMustNotCreateASoapInstanceForMissingLocationOption()
499498
{
500-
$soapClient = new SoapClient(array(
499+
new SoapClient(array(
501500
SoapClient::WSDL_URL => null,
502501
SoapClient::WSDL_URI => 'http://api.bing.net:80/soap.asmx',
503502
));
@@ -509,7 +508,7 @@ public function testInvalidNonWsdlModeMustNotCreateASoapInstanceForMissingLocati
509508
*/
510509
public function testInvalidNonWsdlModeMustNotCreateASoapInstanceForMissingUriOption()
511510
{
512-
$soapClient = new SoapClient(array(
511+
new SoapClient(array(
513512
SoapClient::WSDL_URL => null,
514513
SoapClient::WSDL_LOCATION => 'http://api.bing.net:80/soap.asmx',
515514
));
@@ -521,12 +520,26 @@ public function testInvalidNonWsdlModeMustNotCreateASoapInstanceForMissingUriOpt
521520
*/
522521
public function testInvalidNonWsdlModeMustCreateASoapInstanceWithUriAndLocationOptions()
523522
{
524-
$soapClient = new SoapClient(array(
523+
new SoapClient(array(
525524
SoapClient::WSDL_URL => null,
526525
SoapClient::WSDL_LOCATION => 'http://api.bing.net:80/soap.asmx',
527526
SoapClient::WSDL_URI => 'http://api.bing.net:80/soap.asmx',
528527
));
529528

530529
$this->assertInstanceOf('\SoapClient', SoapClient::getSoapClient());
531530
}
531+
/**
532+
*
533+
*/
534+
public function testGetOutputHeadersWithoutRequestMustReturnAnEmptyArray()
535+
{
536+
$soapClient = new SoapClient(array(
537+
SoapClient::WSDL_URL => null,
538+
SoapClient::WSDL_LOCATION => 'http://api.bing.net:80/soap.asmx',
539+
SoapClient::WSDL_URI => 'http://api.bing.net:80/soap.asmx',
540+
));
541+
542+
$this->assertTrue(is_array($soapClient->getOutputHeaders()));
543+
$this->assertEmpty($soapClient->getOutputHeaders());
544+
}
532545
}

0 commit comments

Comments
 (0)