From 9bd170df9fb459cd3d5fb6fcc76cd1e3ce63919f Mon Sep 17 00:00:00 2001 From: Ievgen Kolesov Date: Thu, 6 Oct 2016 13:30:28 +0300 Subject: [PATCH] MAGETWO-55510: "Client side less compilation" does not work properly #3325 --- .../PreProcessor/FrontendCompilation.php | 12 +++---- .../PreProcessor/FrontendCompilationTest.php | 32 ------------------- 2 files changed, 4 insertions(+), 40 deletions(-) diff --git a/app/code/Magento/Developer/Model/View/Asset/PreProcessor/FrontendCompilation.php b/app/code/Magento/Developer/Model/View/Asset/PreProcessor/FrontendCompilation.php index 4573f15b016fa..8cd04f7d1e4c5 100644 --- a/app/code/Magento/Developer/Model/View/Asset/PreProcessor/FrontendCompilation.php +++ b/app/code/Magento/Developer/Model/View/Asset/PreProcessor/FrontendCompilation.php @@ -74,10 +74,6 @@ public function __construct( */ public function process(PreProcessor\Chain $chain) { - $content = $chain->getContent(); - if (trim($content) !== '') { - return; - } try { $this->lockerProcess->lockProcess($this->lockName); @@ -88,7 +84,7 @@ public function process(PreProcessor\Chain $chain) /** @var FallbackContext $context */ $context = $chain->getAsset()->getContext(); - $result = $this->processContent($path, $content, $module, $context); + $result = $this->processContent($path, $chain->getContent(), $module, $context); $chain->setContent($result['content']); $chain->setContentType($result['sourceType']); } finally { @@ -107,14 +103,14 @@ public function process(PreProcessor\Chain $chain) */ private function processContent($path, $content, $module, FallbackContext $context) { - $sourceType = '#\.' . preg_quote(pathinfo($path, PATHINFO_EXTENSION), '#') . '$#'; + $sourceTypePattern = '#\.' . preg_quote(pathinfo($path, PATHINFO_EXTENSION), '#') . '$#'; foreach ($this->alternativeSource->getAlternativesExtensionsNames() as $name) { $asset = $this->assetBuilder->setArea($context->getAreaCode()) ->setTheme($context->getThemePath()) ->setLocale($context->getLocale()) ->setModule($module) - ->setPath(preg_replace($sourceType, '.' . $name, $path)) + ->setPath(preg_replace($sourceTypePattern, '.' . $name, $path)) ->build(); $processedContent = $this->assetSource->getContent($asset); @@ -129,7 +125,7 @@ private function processContent($path, $content, $module, FallbackContext $conte return [ 'content' => $content, - 'sourceType' => $sourceType + 'sourceType' => pathinfo($path, PATHINFO_EXTENSION) ]; } } diff --git a/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/FrontendCompilationTest.php b/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/FrontendCompilationTest.php index 97f0b1d5a6bdb..b43d91c5e4dc6 100644 --- a/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/FrontendCompilationTest.php +++ b/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/FrontendCompilationTest.php @@ -189,38 +189,6 @@ public function testProcess() $frontendCompilation->process($this->getChainMockExpects('', 1, 1, $newContentType)); } - /** - * Run test for process method (content not empty) - */ - public function testProcessContentNotEmpty() - { - $chainMock = $this->getChainMock(); - $assetMock = $this->getAssetMock(); - - $chainMock->expects(self::once()) - ->method('getContent') - ->willReturn('test-content'); - - $chainMock->expects(self::never()) - ->method('getAsset') - ->willReturn($assetMock); - - $this->lockerProcessMock->expects(self::never()) - ->method('lockProcess'); - $this->lockerProcessMock->expects(self::never()) - ->method('unlockProcess'); - - $frontendCompilation = new FrontendCompilation( - $this->assetSourceMock, - $this->assetBuilderMock, - $this->alternativeSourceMock, - $this->lockerProcessMock, - 'lock' - ); - - $frontendCompilation->process($chainMock); - } - /** * @return Chain|\PHPUnit_Framework_MockObject_MockObject */