Exemplo n.º 1
0
 /**
  * Check if asset in exclude list
  *
  * @param LocalInterface $asset
  * @return bool
  */
 protected function isExcluded(LocalInterface $asset)
 {
     $excludedFiles = array_merge($this->bundleConfig->getConfig($asset->getContext())->getExcludedFiles(), $this->excluded);
     if (in_array($asset->getFilePath(), $excludedFiles)) {
         return true;
     }
     // check if file in excluded directory
     $assetDirectory = dirname($asset->getFilePath());
     foreach ($this->bundleConfig->getConfig($asset->getContext())->getExcludedDir() as $dir) {
         if (strpos($assetDirectory, $dir) !== false) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * Check if asset in exclude list
  *
  * @param LocalInterface $asset
  * @return bool
  */
 protected function isExcluded(LocalInterface $asset)
 {
     $excludedFiles = array_merge($this->bundleConfig->getConfig($asset->getContext())->getExcludedFiles(), $this->excluded);
     foreach ($excludedFiles as $file) {
         if ($this->isExcludedFile($file, $asset)) {
             return true;
         }
     }
     foreach ($this->bundleConfig->getConfig($asset->getContext())->getExcludedDir() as $directory) {
         if ($this->isExcludedDirectory($directory, $asset)) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 3
0
 public function testAddAsset()
 {
     $dirRead = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->disableOriginalConstructor()->getMock();
     $context = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File\\FallbackContext')->disableOriginalConstructor()->getMock();
     $configView = $this->getMockBuilder('Magento\\Framework\\Config\\View')->disableOriginalConstructor()->getMock();
     $this->filesystem->expects($this->once())->method('getDirectoryRead')->with(\Magento\Framework\App\Filesystem\DirectoryList::APP)->willReturn($dirRead);
     $this->asset->expects($this->atLeastOnce())->method('getSourceFile')->willReturn('/path/to/source/file.min.js');
     $this->asset->expects($this->atLeastOnce())->method('getContentType')->willReturn('js');
     $this->asset->expects($this->once())->method('getPath')->willReturn('/path/to/file.js');
     $this->asset->expects($this->atLeastOnce())->method('getContext')->willReturn($context);
     $this->bundleConfig->expects($this->atLeastOnce())->method('getConfig')->with($context)->willReturn($configView);
     $configView->expects($this->once())->method('getExcludedFiles')->willReturn([]);
     $configView->expects($this->once())->method('getExcludedDir')->willReturn([]);
     $this->bundle->expects($this->once())->method('addAsset')->with($this->asset);
     $this->assertTrue($this->manager->addAsset($this->asset));
 }
Exemplo n.º 4
0
 /**
  * @param array $parts
  * @param FallbackContext $context
  * @return void
  */
 protected function fillContent($parts, $context)
 {
     $index = count($this->content) > 0 ? count($this->content) - 1 : 0;
     foreach ($parts as $part) {
         if (!isset($this->content[$index])) {
             $this->content[$index] = '';
         } elseif ($this->bundleConfig->isSplit($context)) {
             ++$index;
             $this->content[$index] = '';
         }
         $this->content[$index] .= $this->getPartContent($part['assets']);
     }
 }
Exemplo n.º 5
0
    public function testAddAsset()
    {
        $context = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContext')
            ->disableOriginalConstructor()
            ->getMock();
        $configView = $this->getMockBuilder('Magento\Framework\Config\View')
            ->disableOriginalConstructor()
            ->getMock();

        $this->asset->expects($this->atLeastOnce())
            ->method('getContentType')
            ->willReturn('js');
        $this->asset->expects($this->once())
            ->method('getSourceFile')
            ->willReturn('/source/file');
        $this->asset->expects($this->atLeastOnce())
            ->method('getFilePath')
            ->willReturn('file/path.js');
        $this->assetConfig->expects($this->once())
            ->method('isAssetMinification')
            ->willReturn(false);
        $this->asset->expects($this->atLeastOnce())
            ->method('getContext')
            ->willReturn($context);
        $this->bundleConfig
            ->expects($this->atLeastOnce())
            ->method('getConfig')
            ->with($context)
            ->willReturn($configView);
        $configView->expects($this->once())
            ->method('getExcludedFiles')
            ->willReturn([]);
        $configView->expects($this->once())
            ->method('getExcludedDir')
            ->willReturn([]);
        $this->bundle->expects($this->once())
            ->method('addAsset')
            ->with($this->asset);

        $this->assertTrue($this->manager->addAsset($this->asset));
    }