public function testSetLimit() { Cache::setLimit(10); $this->assertEquals(10, Cache::getLimit()); Cache::setLimit(1); $this->assertEquals(1, Cache::getLimit()); }
public function withWsdlCache($cache) { if (!in_array($cache, Cache::getTypes(), true)) { throw new \InvalidArgumentException(); } $this->soapOptions['cache_wsdl'] = $cache; return $this; }
/** * Constructor. * * @param \BeSimple\SoapClient\Curl $curl Curl instance * @param boolean $resolveRemoteIncludes WSDL/XSD include enabled? * @param boolean $cacheWsdl Cache constant */ public function __construct(Curl $curl, $resolveRemoteIncludes = true, $cacheWsdl = Cache::TYPE_DISK) { $this->curl = $curl; $this->resolveRemoteIncludes = (bool) $resolveRemoteIncludes; // get current WSDL caching config $this->cacheEnabled = $cacheWsdl === Cache::TYPE_NONE ? Cache::DISABLED : Cache::ENABLED == Cache::isEnabled(); $this->cacheDir = Cache::getDirectory(); $this->cacheTtl = Cache::getLifetime(); }
public function __construct($cacheDisabled, $type, $directory, $lifetime = null, $limit = null) { $isEnabled = (bool) $cacheDisabled ? BaseCache::DISABLED : BaseCache::ENABLED; BaseCache::setEnabled($isEnabled); BaseCache::setType($type); BaseCache::setDirectory($directory); if (null !== $lifetime) { BaseCache::setLifetime($lifetime); } if (null !== $limit) { BaseCache::setLimit($limit); } }
/** * @dataProvider provideResolveXsdIncludes */ public function testResolveXsdIncludes($source, $cacheFile, $remoteParentUrl, $regexp, $nbDownloads) { $wsdlCacheDir = vfsStream::setup('wsdl'); $wsdlCacheUrl = $wsdlCacheDir->url('wsdl'); Cache::setEnabled(Cache::ENABLED); Cache::setDirectory($wsdlCacheUrl); $cacheDirForRegExp = preg_quote($wsdlCacheUrl, '#'); $wsdlDownloader = new WsdlDownloader(new Curl(array('proxy_host' => false))); $r = new \ReflectionClass($wsdlDownloader); $m = $r->getMethod('resolveRemoteIncludes'); $m->setAccessible(true); $this->assertCount(0, $wsdlCacheDir->getChildren()); $cacheFile = sprintf($cacheFile, $wsdlCacheUrl); $m->invoke($wsdlDownloader, file_get_contents($source), $cacheFile, $remoteParentUrl); $this->assertCount($nbDownloads, $wsdlCacheDir->getChildren()); $this->assertRegExp('#' . sprintf($regexp, $cacheDirForRegExp) . '#', file_get_contents($cacheFile)); }