/** * @param string $response * @dataProvider readDataProvider */ public function testRead($response) { self::$curlExectClosure = function () use($response) { return $response; }; $this->assertEquals(file_get_contents(__DIR__ . '/_files/curl_response_expected.txt'), $this->model->read()); }
/** * @param string $fileUrl * @param string $localFilePath * @return bool|void */ protected function retrieveRemoteImage($fileUrl, $localFilePath) { $this->curl->setConfig(['header' => false]); $this->curl->write('GET', $fileUrl); $image = $this->curl->read(); $this->fileUtility->saveFile($localFilePath, $image); }
/** * Send curl purge request * to invalidate cache by tags pattern * * @param string $tagsPattern * @return void */ protected function sendPurgeRequest($tagsPattern) { $headers = ["X-Magento-Tags-Pattern: {$tagsPattern}"]; $this->_curlAdapter->setOptions([CURLOPT_CUSTOMREQUEST => 'PURGE']); $this->_curlAdapter->write('', $this->_helper->getUrl('*'), '1.1', $headers); $this->_curlAdapter->read(); $this->_curlAdapter->close(); }
/** * @param string $fileUrl * @param string $localFilePath * @return void * @throws \Magento\Framework\Exception\LocalizedException */ protected function retrieveRemoteImage($fileUrl, $localFilePath) { $this->curl->setConfig(['header' => false]); $this->curl->write('GET', $fileUrl); $image = $this->curl->read(); if (empty($image)) { throw new \Magento\Framework\Exception\LocalizedException(__('Could not get preview image information. Please check your connection and try again.')); } $this->fileUtility->saveFile($localFilePath, $image); }