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)); }
public function testSetEnabledBadValue() { $this->setExpectedException('InvalidArgumentException'); Cache::setEnabled('foo'); }