Example #1
0
 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);
     }
 }
Example #2
0
 public function testSetDirectory()
 {
     vfsStream::setup('Fixtures');
     $this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('foo'));
     $dir = vfsStream::url('Fixtures/foo');
     Cache::setDirectory($dir);
     $this->assertEquals($dir, Cache::getDirectory());
     $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('foo'));
     $this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('bar'));
     $dir = vfsStream::url('Fixtures/bar');
     Cache::setDirectory($dir);
     $this->assertEquals($dir, Cache::getDirectory());
     $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('bar'));
 }
 /**
  * @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));
 }