Esempio n. 1
0
 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));
 }
Esempio n. 2
0
 /**
  * @dataProvider isExternalLinkProvider
  */
 public function testIsExternalLink($link, $expectedIsExternal)
 {
     $this->assertEquals($expectedIsExternal, SpeedOut_Utils::isExternalLink($link));
 }
Esempio n. 3
0
 protected function getLinksNodes($html)
 {
     $html = $this->removeHtmlComments($html);
     $linksData = array();
     foreach ($this->getLinksNodesRegexps() as $regexp) {
         if (SpeedOut_Utils::safePregMatchAll($regexp, $html, $m)) {
             foreach ($m[1] as $i => $link) {
                 if (!SpeedOut_Utils::isExternalLink($link) && $this->linksFilter->isMatch($link)) {
                     $linksData[$link] = $m[0][$i];
                 }
             }
         }
     }
     return $linksData;
 }
Esempio n. 4
0
 protected function replaceImportsInLinkedData(&$linkedFileData, $linkPath)
 {
     $linkBaseDir = dirname($linkPath);
     $importsRegexp = '~@import\\s*?["\'](.*?)["\'].*?;~';
     $replaceLinksDataRegexps = array();
     $importedLinksPaths =& $this->handlingProcessData[__METHOD__ . 'importsLinksPaths'];
     if (!$importedLinksPaths) {
         $importedLinksPaths = array();
     }
     if (SpeedOut_Utils::safePregMatchAll($importsRegexp, $linkedFileData, $m)) {
         foreach ($m[1] as $i => $importLink) {
             $importLinkPath = SpeedOut_Utils::getLinkPath($importLink, $linkBaseDir);
             if (!SpeedOut_Utils::isExternalLink($importLink) && !in_array($importLinkPath, $importedLinksPaths) && $this->isValidInternalLink($importLinkPath, 'combined CSS data')) {
                 $importedLinksPaths[] = $importLinkPath;
                 $replaceLinksDataRegexps['~' . preg_quote($m[0][$i], '~') . '~'] = $this->getLinkData($importLinkPath);
             }
         }
     }
     foreach ($replaceLinksDataRegexps as $regexp => $replace) {
         $linkedFileData = SpeedOut_Utils::safePregReplace($regexp, $replace, $linkedFileData, 1);
     }
     $linkedFileData = SpeedOut_Utils::safePregReplace($importsRegexp, '', $linkedFileData);
 }