/**
  * Builds asset file path based off url
  *
  * @param string $url Asset URL
  * @return string|void Absolute path for asset file
  */
 protected function _getAssetFile($url)
 {
     $parts = explode('/', $url);
     if ($parts[0] === 'ASSETS') {
         unset($parts[0]);
         $url = array_values($parts);
         return APP . 'Assets' . DS . join(DS, $url);
     }
     return parent::_getAssetFile($url);
 }
Ejemplo n.º 2
0
 /**
  * Test assets
  *
  * @dataProvider assetProvider
  * @return void
  * @triggers Dispatcher.beforeDispatch $this, compact('request', 'response')
  */
 public function testAsset($url, $file)
 {
     Plugin::load(['Company/TestPluginThree', 'TestPlugin', 'PluginJs']);
     $filter = new AssetFilter();
     $response = $this->getMock('Cake\\Network\\Response', ['_sendHeader']);
     $request = new Request($url);
     $event = new Event('Dispatcher.beforeDispatch', $this, compact('request', 'response'));
     ob_start();
     $filter->beforeDispatch($event);
     $result = ob_get_contents();
     ob_end_clean();
     $path = TEST_APP . str_replace('/', DS, $file);
     $file = file_get_contents($path);
     $this->assertEquals($file, $result);
     $expected = filesize($path);
     $headers = $response->header();
     $this->assertEquals($expected, $headers['Content-Length']);
 }