public function testFetchAllOnSuccess() { $reqp = $this->prophesize('Hirak\\Prestissimo\\CopyRequest'); $reqp->getCurlOptions()->willReturn(array(CURLOPT_URL => 'file://' . __DIR__ . '/test.txt', CURLOPT_FILE => tmpfile())); $reqp->makeSuccess()->willReturn(null); $reqp->getMaskedURL()->willReturn('file://' . __DIR__ . '/test.txt'); $this->iop->writeError(arg::type('string'))->shouldBeCalled(); $fetcher = new Prefetcher(); $fetcher->fetchAll($this->iop->reveal(), array($reqp->reveal())); }
protected function preloadProviderListings($data) { if ($this->providersUrl && isset($data['provider-includes'])) { $includes = $data['provider-includes']; $requests = array(); $cachedir = $this->config->get('cache-repo-dir'); $cacheBase = $cachedir . DIRECTORY_SEPARATOR . strtr($this->baseUrl, ':/', '--'); foreach ($includes as $include => $metadata) { $url = $this->baseUrl . '/' . str_replace('%hash%', $metadata['sha256'], $include); $cacheKey = str_replace(array('%hash%', '$'), '', $include); if ($this->cache->sha256($cacheKey) !== $metadata['sha256']) { $dest = $cacheBase . DIRECTORY_SEPARATOR . str_replace('/', '-', $cacheKey); $requests[] = new CopyRequest($url, $dest, false, $this->io, $this->config); } } if ($requests) { $prefetcher = new Prefetcher(); $prefetcher->fetchAll($this->io, $requests); } } }