Esempio n. 1
0
 /**
  * Transform content and/or content type for the specified preprocessing chain object
  *
  * @param PreProcessor\Chain $chain
  * @return void
  */
 public function process(PreProcessor\Chain $chain)
 {
     if (WorkflowType::CLIENT_SIDE_COMPILATION === $this->scopeConfig->getValue(WorkflowType::CONFIG_NAME_PATH)) {
         $this->frontendCompilation->process($chain);
     } else {
         $this->alternativeSource->process($chain);
     }
 }
 /**
  * Run test for process method
  */
 public function testProcessAlternativeSource()
 {
     $chainMock = $this->getChainMock();
     $this->scopeConfigMock->expects(self::once())->method('getValue')->with(WorkflowType::CONFIG_NAME_PATH)->willReturn('off');
     $this->alternativeSourceMock->expects(self::once())->method('process')->with($chainMock);
     $this->frontendCompilationMock->expects(self::never())->method('process');
     $this->preprocessorStrategy->process($chainMock);
 }
 /**
  * Preparation of content for the destination file
  *
  * @param string $path
  * @param string $content
  * @param string $module
  * @param FallbackContext $context
  * @return string
  */
 private function processContent($path, $content, $module, FallbackContext $context)
 {
     foreach ($this->alternativeSource->getAlternativesExtensionsNames() as $name) {
         $asset = $this->assetBuilder->setArea($context->getAreaCode())->setTheme($context->getThemePath())->setLocale($context->getLocale())->setModule($module)->setPath(preg_replace('#\\.' . preg_quote(pathinfo($path, PATHINFO_EXTENSION)) . '$#', '.' . $name, $path))->build();
         $processedContent = $this->assetSource->getContent($asset);
         if (trim($processedContent) !== '') {
             return $processedContent;
         }
     }
     return $content;
 }
 /**
  * Run test for process method
  */
 public function testProcess()
 {
     $this->lockerProcessMock->expects(self::once())->method('lockProcess')->with(self::isType('string'));
     $this->lockerProcessMock->expects(self::once())->method('unlockProcess');
     $assetMock = $this->getAssetNew();
     $this->assetBuilderMock->expects(self::once())->method('setArea')->with(self::AREA)->willReturnSelf();
     $this->assetBuilderMock->expects(self::once())->method('setTheme')->with(self::THEME)->willReturnSelf();
     $this->assetBuilderMock->expects(self::once())->method('setLocale')->with(self::LOCALE)->willReturnSelf();
     $this->assetBuilderMock->expects(self::once())->method('setModule')->with(self::MODULE)->willReturnSelf();
     $this->assetBuilderMock->expects(self::once())->method('setPath')->with(self::FILE_PATH)->willReturnSelf();
     $this->assetBuilderMock->expects(self::once())->method('build')->willReturn($assetMock);
     $this->alternativeSourceMock->expects(self::once())->method('getAlternativesExtensionsNames')->willReturn(['less']);
     $this->assetSourceMock->expects(self::once())->method('getContent')->with($assetMock)->willReturn(self::NEW_CONTENT);
     $frontendCompilation = new FrontendCompilation($this->assetSourceMock, $this->assetBuilderMock, $this->alternativeSourceMock, $this->lockerProcessMock, 'lock');
     $frontendCompilation->process($this->getChainMockExpects());
 }