Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Check valid value for Client cacheWSDL property #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -890,14 +890,16 @@ public function getSoapFeatures()
*
* @param string|int|bool|null $caching
* @return self
* @throws Exception\InvalidArgumentException
*/
public function setWSDLCache($caching)
{
//@todo check WSDL_CACHE_* constants?
if ($caching === null) {
$this->cacheWsdl = null;
} else {
} elseif (in_array($caching, [WSDL_CACHE_NONE, WSDL_CACHE_DISK, WSDL_CACHE_MEMORY, WSDL_CACHE_BOTH])) {
$this->cacheWsdl = (int) $caching;
} else {
throw new Exception\InvalidArgumentException("Invalid value for cache_wsdl option");
}

return $this;
Expand Down
11 changes: 10 additions & 1 deletion test/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function testSetOptions()
'passphrase' => 'some pass phrase',

'stream_context' => $ctx,
'cache_wsdl' => 8,
'cache_wsdl' => WSDL_CACHE_NONE,
'features' => 4,

'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5,
Expand Down Expand Up @@ -244,6 +244,15 @@ public function testAllowNumericZeroAsValueForCacheWsdlOption()
$this->assertArrayNotHasKey('cache_wsdl', $options);
}

/**
* @expectedException \Zend\Soap\Exception\InvalidArgumentException
*/
public function testInvalidCacheWsdlOptionException()
{
$client = new Client();
$client->setWsdlCache(100);
}

/**
* @group ZF-10542
*/
Expand Down