diff --git a/src/Client.php b/src/Client.php index 2fba580a..1c196a03 100644 --- a/src/Client.php +++ b/src/Client.php @@ -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; diff --git a/test/ClientTest.php b/test/ClientTest.php index 4688d45c..2408af0c 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -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, @@ -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 */