public function testStoreAndGetUrl() { $storeId = $this->generateStoreId(); $expectedData = mt_rand(); $this->storage->store($storeId, $expectedData); $actualUrl = $this->storage->getUrl($storeId); $this->assertTrue(SpeedOut_Utils::isExternalLink($actualUrl)); // because of tests are running from CLI $actualPath = SpeedOut_Utils::getDocRoot() . substr($actualUrl, strlen(SpeedOut_Utils::getPathUrl(SpeedOut_Utils::getDocRoot()))); $this->assertEquals($expectedData, file_get_contents($actualPath)); }
/** * Replace resources links by one link on file, that contains resources links data * @param $html * @throws SpeedOut_DataHandler_Combiner_Exception_PathNotFound * @return null */ public function handleData(&$html) { $this->handlingProcessData = array(); $linksNodes = $this->getLinksNodes($html); if ($linksNodes) { $linksHash = $this->getLinksHash(array_keys($linksNodes)); // combine and store links data if (!$this->storage->isStored($linksHash)) { $combinedData = ''; $baseDir = $this->getLinksBaseDir(); foreach ($linksNodes as $link => $data) { $linkPath = SpeedOut_Utils::getLinkPath(SpeedOut_Utils::getRealLink(html_entity_decode($link), $baseDir), $baseDir); $linkData = $this->getLinkData($linkPath); $combinedData .= $this->getCombinedDataPart($linkData, $linkPath); } $this->handleCombinedData($combinedData); $this->storage->store($linksHash, $combinedData); } $html = str_replace($linksNodes, '', $html); $this->addStringInCommonPlaceholder($html, $this->getCommonLinkHtml($this->storage->getUrl($linksHash))); } }