Skip to content
This repository has been archived by the owner on May 16, 2018. It is now read-only.

Commit

Permalink
Fixes #32 - Zend_Soap_Client has no exceptions flag
Browse files Browse the repository at this point in the history
  • Loading branch information
froschdesign committed Nov 29, 2014
1 parent 26d8274 commit 1a065a8
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
40 changes: 39 additions & 1 deletion library/Zend/Soap/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class Zend_Soap_Client
protected $_features = null;
protected $_cache_wsdl = null;
protected $_user_agent = null;
protected $_exceptions = null;

/**
* WSDL used to access server
Expand Down Expand Up @@ -268,6 +269,9 @@ public function setOptions($options)
case 'user_agent':
$this->setUserAgent($value);
break;
case 'exceptions':
$this->setExceptions($value);
break;

// Not used now
// case 'connection_timeout':
Expand Down Expand Up @@ -315,13 +319,14 @@ public function getOptions()
$options['cache_wsdl'] = $this->getWsdlCache();
$options['features'] = $this->getSoapFeatures();
$options['user_agent'] = $this->getUserAgent();
$options['exceptions'] = $this->getExceptions();

foreach ($options as $key => $value) {
/*
* ugly hack as I don't know if checking for '=== null'
* breaks some other option
*/
if (in_array($key, array('user_agent', 'cache_wsdl', 'compression'))) {
if (in_array($key, array('user_agent', 'cache_wsdl', 'compression', 'exceptions'))) {
if ($value === null) {
unset($options[$key]);
}
Expand Down Expand Up @@ -908,6 +913,39 @@ public function getUserAgent()
return $this->_user_agent;
}

/**
* Set the exceptions option
*
* The exceptions option is a boolean value defining whether soap errors
* throw exceptions.
*
* @see http://php.net/manual/soapclient.soapclient.php#refsect1-soapclient.soapclient-parameters
*
* @param bool $exceptions
* @return $this
*/
public function setExceptions($exceptions)
{
$this->_exceptions = (bool) $exceptions;

return $this;
}

/**
* Get the exceptions option
*
* The exceptions option is a boolean value defining whether soap errors
* throw exceptions.
*
* @see http://php.net/manual/soapclient.soapclient.php#refsect1-soapclient.soapclient-parameters
*
* @return bool|null
*/
public function getExceptions()
{
return $this->_exceptions;
}

/**
* Retrieve request XML
*
Expand Down
36 changes: 36 additions & 0 deletions tests/Zend/Soap/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,42 @@ public function testAllowNumericZeroAsValueForCompressionOptions()
$this->assertArrayNotHasKey('compression', $options);
}

/**
* @group GH-32
*/
public function testGetAndSetExceptionsOption()
{
$client = new Zend_Soap_Client();
$this->assertNull($client->getExceptions());
$this->assertEquals(
array(
'encoding' => 'UTF-8',
'soap_version' => 2,
),
$client->getOptions()
);

$client->setExceptions(true);
$this->assertTrue($client->getExceptions());

$client->setExceptions(false);
$this->assertFalse($client->getExceptions());

$client->setOptions(array('exceptions' => true));
$this->assertTrue($client->getExceptions());

$client = new Zend_Soap_Client(null, array('exceptions' => false));
$this->assertFalse($client->getExceptions());
$this->assertEquals(
array(
'encoding' => 'UTF-8',
'soap_version' => 2,
'exceptions' => false,
),
$client->getOptions()
);
}

public function testGetFunctions()
{
$server = new Zend_Soap_Server(dirname(__FILE__) . '/_files/wsdl_example.wsdl');
Expand Down

0 comments on commit 1a065a8

Please sign in to comment.