/** * Download new ownCloud package * @param Feed $feed * @param Callable $onProgress * @throws \UnexpectedValueException */ public function getOwncloud(Feed $feed, callable $onProgress) { if ($feed->isValid()) { $downloadPath = $this->getBaseDownloadPath($feed); if (!is_writable(dirname($downloadPath))) { throw new \Exception(dirname($downloadPath) . ' is not writable.'); } $url = $feed->getUrl(); $request = $this->httpClient->createRequest('GET', $url, ['save_to' => $downloadPath, 'timeout' => 600]); $request->getEmitter()->on('progress', $onProgress); $response = $this->httpClient->send($request); $this->validateResponse($response); } }
/** * @dataProvider resultProvider */ public function testValidity($feedData, $expectedValidity) { $feed = new Feed($feedData); $this->assertEquals($expectedValidity, $feed->isValid()); }