Exemplo n.º 1
0
 public function testExternalSource()
 {
     $asset = new StringAsset('body { background: url(../images/bg.gif); }', array(), 'http://www.example.com', 'css/main.css');
     $asset->setTargetPath('css/packed/main.css');
     $asset->load();
     $filter = new CssRewriteFilter();
     $filter->filterDump($asset);
     $this->assertContains('http://www.example.com/css/../images/bg.gif', $asset->getContent(), '->filterDump() rewrites references in external stylesheets');
 }
Exemplo n.º 2
0
 public function testEmptyUrl()
 {
     $asset = new StringAsset('body { background: url(); }', array(), 'http://www.example.com', 'css/main.css');
     $asset->setTargetPath('css/packed/main.css');
     $asset->load();
     $filter = new CssRewriteFilter();
     $filter->filterDump($asset);
     // no error is thrown
 }
 public function testNoTargetPath()
 {
     $content = 'body{url(foo.gif)}';
     $asset = new StringAsset($content);
     $asset->load();
     $filter = new CssRewriteFilter();
     $filter->filterDump($asset);
     $this->assertEquals($content, $asset->getContent(), '->filterDump() urls are not changed without urls');
 }
Exemplo n.º 4
0
 public function filterDump(AssetInterface $asset)
 {
     $originalTargetPath = $asset->getTargetPath();
     $targetPath = str_replace('_controller/', '', $originalTargetPath);
     $asset->setTargetPath($targetPath);
     try {
         parent::filterDump($asset);
     } catch (\Exception $e) {
         if ($targetPath === $asset->getTargetPath()) {
             $asset->setTargetPath($originalTargetPath);
         }
         throw $e;
     }
     if ($targetPath === $asset->getTargetPath()) {
         $asset->setTargetPath($originalTargetPath);
     }
 }